Overview
S Balance
0 S
S Value
-More Info
Private Name Tags
ContractCreator
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Source Code Verified (Exact Match)
Contract Name:
PaintSwapMarketplace
Compiler Version
v0.8.28+commit.7893614a
Optimization Enabled:
Yes with 99999 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.28; import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import {ReentrancyGuardTransientUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardTransientUpgradeable.sol"; import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import {PaintSwapMarketplaceBase, FeePercentage, MarketplaceWhitelist, NFT} from "./PaintSwapMarketplaceBase.sol"; import {IPaintSwapMarketplaceP2PSwaps} from "../interfaces/IPaintSwapMarketplaceP2PSwaps.sol"; import {IPaintSwapMarketplaceListAndComplete, Listing} from "../interfaces/IPaintSwapMarketplaceListAndComplete.sol"; import {PaintSwapLibrary} from "../PaintSwapLibrary.sol"; contract PaintSwapMarketplace is IPaintSwapMarketplaceP2PSwaps, UUPSUpgradeable, OwnableUpgradeable, ReentrancyGuardTransientUpgradeable, PaintSwapMarketplaceBase { /// @custom:oz-upgrades-unsafe-allow constructor constructor() PaintSwapMarketplaceBase(address(0), 0) { _disableInitializers(); } function initialize( address marketplaceWhitelist, address collectionRoyalties, address vaultFactory, address implBuyEditListing, address implMakeAndEditOffers, address implBids, address implAcceptOffers, address implListAndComplete, address implBatchTransferNFT, address implP2PSwaps, address feePercentage, uint96 listingFeeInit, address devFeeAddress, address salesFeeAddress, uint128 swapCostNative, uint256 startId ) external initializer { __Ownable_init(_msgSender()); __UUPSUpgradeable_init(); __ReentrancyGuardTransient_init(); _vaultFactory = vaultFactory; _devFeeAddress = devFeeAddress; _salesFeeAddress = salesFeeAddress; _marketplaceWhitelist = MarketplaceWhitelist(marketplaceWhitelist); _currentMarketplaceId = startId; _feePercentage = FeePercentage(feePercentage); _implBuyEditListing = implBuyEditListing; _implMakeAndEditOffers = implMakeAndEditOffers; _implBids = implBids; _implAcceptOffers = implAcceptOffers; _implListAndComplete = implListAndComplete; _implBatchTransferNFT = implBatchTransferNFT; _implP2PSwaps = implP2PSwaps; _setSwapCostNative(uint128(swapCostNative)); _setListingFee(listingFeeInit); // Include sale % _royaltyInfo.collectionRoyalties = collectionRoyalties; _setMaxRoyalty(750); // 7.5% _setMaxCallGasLimit(1_000_000); _isSellingEnabled = true; _minDuration = 1 days; _maxDuration = 200 days; _minAuctionDuration = 30 minutes; _minFlashAuctionDuration = 5 minutes; _maxAuctionDuration = 1 weeks; _auctionGracePeriodForCancelling = 10 minutes; _flashAuctionGracePeriodForCancelling = 1 minutes; _auctionEndTimeIncreaseCutOff = 3 minutes; _flashAuctionEndTimeIncreaseCutOff = 1 minutes; _minIncreasedBidPercent = 100; // 1%. 10000 basis points, 945 means 9.45% _callGasLimit = 250_000; _offerId = 1; _maxActiveOfferCount = 1000; _minOfferDuration = 1 days; _maxOfferDuration = 200 days; } // Sell many nfts as different listings function addListingBatch(Listing[] calldata listings) external payable nonReentrant { _delegatecall( _implListAndComplete, abi.encodeWithSelector(IPaintSwapMarketplaceListAndComplete.addListingBatch.selector, listings) ); } function addListing(Listing calldata listing) external payable nonReentrant { _delegatecall( _implListAndComplete, abi.encodeWithSelector(IPaintSwapMarketplaceListAndComplete.addListing.selector, listing) ); } // Currently just used for tests function addListingRaw( address nft, uint256 tokenId, uint96 price, uint40 duration, uint40 amount, bool isVaultListing, bool isAuctionListing, bool isAntisnipe, bool isFlashAuction, bool isNSFW, string calldata searchKeywords, address donationAddress, uint16 donationPercent ) external payable nonReentrant { Listing memory listing = Listing({ nft: nft, tokenId: tokenId, price: price, duration: duration, amount: amount, isUsingVault: isVaultListing, isAuction: isAuctionListing, isAntisnipe: isAntisnipe, isFlashAuction: isFlashAuction, isNSFW: isNSFW, searchKeywords: searchKeywords, donationAddress: donationAddress, donationPercent: donationPercent }); _delegatecall( _implListAndComplete, abi.encodeWithSelector(IPaintSwapMarketplaceListAndComplete.addListing.selector, listing) ); } function completeMarketplaceEntry(uint256 marketplaceId) external nonReentrant { _delegatecall(_implListAndComplete, abi.encodeWithSignature("completeMarketplaceEntry(uint256)", marketplaceId)); } function buy(uint256 marketplaceId, NFT calldata expectedNFT, uint40 quantity) external payable nonReentrant { _delegatecall( _implBuyEditListing, abi.encodeWithSignature("buy(uint256,(address,uint256),uint40)", marketplaceId, expectedNFT, quantity) ); } function buyBatch( uint256[] calldata marketplaceIds, NFT[] calldata expectedNFTs, uint40[] calldata quantities ) external payable nonReentrant { _delegatecall( _implBuyEditListing, abi.encodeWithSignature( "buyBatch(uint256[],(address,uint256)[],uint40[])", marketplaceIds, expectedNFTs, quantities ) ); } function makeOfferSingle( address nft, uint256 tokenId, uint40 quantity, uint96 price, uint40 duration, string calldata searchKeywords ) external payable nonReentrant { _delegatecall( _implMakeAndEditOffers, abi.encodeWithSignature( "makeOfferSingle(address,uint256,uint40,uint96,uint40,string)", nft, tokenId, quantity, price, duration, searchKeywords ) ); } function makeOfferSingleBatch( address[] calldata nfts, uint256[] calldata tokenIds, uint40[] calldata quantities, uint96[] calldata prices, uint40[] calldata durations, string[] calldata searchKeywords ) external payable nonReentrant { _delegatecall( _implMakeAndEditOffers, abi.encodeWithSignature( "makeOfferSingleBatch(address[],uint256[],uint40[],uint96[],uint40[],string[])", nfts, tokenIds, quantities, prices, durations, searchKeywords ) ); } function makeOffer( uint256 marketplaceId, NFT calldata expectedNFT, uint40 quantity, uint96 price, uint40 duration // pass in 0 means the end of the sale ) external payable nonReentrant { _delegatecall( _implMakeAndEditOffers, abi.encodeWithSignature( "makeOffer(uint256,(address,uint256),uint40,uint96,uint40)", marketplaceId, expectedNFT, quantity, price, duration ) ); } function makeCollectionOffer( address nft, uint40 quantity, uint96 price, uint40 duration, string calldata searchKeywords ) external payable nonReentrant { _delegatecall( _implMakeAndEditOffers, abi.encodeWithSignature( "makeCollectionOffer(address,uint40,uint96,uint40,string)", nft, quantity, price, duration, searchKeywords ) ); } function hasExistingActiveOffers( address[] calldata nfts, uint256[] calldata tokenIds, address user ) external view returns (bool[] memory) { bool[] memory activeOffers = new bool[](nfts.length); for (uint256 i = 0; i < nfts.length; ++i) { address nft = nfts[i]; uint256 tokenId = tokenIds[i]; uint256 existingOfferId = _userOffersMade[user][nft][tokenId]; if (existingOfferId != 0) { Offer storage offer = _offers[existingOfferId]; if (offer.expires > block.timestamp) { activeOffers[i] = true; } } existingOfferId = _userFilteredCollectionOffersMade[user][nft]; if (existingOfferId != 0) { Offer storage offer = _offers[existingOfferId]; for (uint256 j = 0; j < offer.tokenIds.length; ++j) { if (tokenId == offer.tokenIds[j]) { if (offer.expires > block.timestamp) { activeOffers[i] = true; break; } } } } } return activeOffers; } function makeFilteredCollectionOffer( address nft, uint256[] calldata tokenIds, uint40 quantity, uint96[] calldata prices, uint40 duration, string[] calldata searchKeywords ) external payable nonReentrant { _delegatecall( _implMakeAndEditOffers, abi.encodeWithSignature( "makeFilteredCollectionOffer(address,uint256[],uint40,uint96[],uint40,string[])", nft, tokenIds, quantity, prices, duration, searchKeywords ) ); } function makeFilteredCollectionOfferBatch( address[] calldata nfts, uint256[][] calldata tokenIds, uint40[] calldata quantities, uint96[][] calldata prices, uint40[] calldata durations, string[][] calldata searchKeywords ) external payable nonReentrant { _delegatecall( _implMakeAndEditOffers, abi.encodeWithSignature( "makeFilteredCollectionOfferBatch(address[],uint256[][],uint40[],uint96[][],uint40[],string[][])", nfts, tokenIds, quantities, prices, durations, searchKeywords ) ); } function acceptOnSaleOffer( uint256 acceptOfferId, uint256 marketplaceId, NFT calldata expectedNFT, uint40 quantity, uint96 expectedTotal ) external nonReentrant { _delegatecall( _implAcceptOffers, abi.encodeWithSignature( "acceptOnSaleOffer(uint256,uint256,(address,uint256),uint40,uint96)", acceptOfferId, marketplaceId, expectedNFT, quantity, expectedTotal ) ); } function acceptOffer( uint256 acceptOfferId, NFT calldata expectedNFT, uint40 quantity, string calldata searchKeywords, uint96 expectedTotal ) external nonReentrant { _delegatecall( _implAcceptOffers, abi.encodeWithSignature( "acceptOffer(uint256,(address,uint256),uint40,string,uint96)", acceptOfferId, expectedNFT, quantity, searchKeywords, expectedTotal ) ); } function acceptOfferBatch(OfferInfo[] calldata offerInfos, uint96 expectedTotal) external nonReentrant { _delegatecall( _implAcceptOffers, abi.encodeWithSignature( "acceptOfferBatch((uint256,(address,uint256),uint256,uint40,string)[],uint96)", offerInfos, expectedTotal ) ); } function cancelOffer(uint256 cancelOfferId) external nonReentrant { _delegatecall(_implMakeAndEditOffers, abi.encodeWithSignature("cancelOffer(uint256)", cancelOfferId)); } function cancelOfferBatch(uint256[] calldata cancelOfferIds) external nonReentrant { _delegatecall(_implMakeAndEditOffers, abi.encodeWithSignature("cancelOfferBatch(uint256[])", cancelOfferIds)); } function expireOffers(uint256[] calldata expireOfferIds) external nonReentrant { _delegatecall(_implMakeAndEditOffers, abi.encodeWithSignature("expireOffers(uint256[])", expireOfferIds)); } function makeBid( uint256 marketplaceId, NFT calldata expectedNFT, uint40 quantity, uint96 bid ) external payable nonReentrant { _delegatecall( _implBids, abi.encodeWithSignature( "makeBid(uint256,(address,uint256),uint40,uint96)", marketplaceId, expectedNFT, quantity, bid ) ); } // Cannot cancel up to cancelCutoffAuction for auctions // Called by the seller if they want to cancel the sale of their nft so the users who made an offer get back the locked brush and the seller gets back the nft function cancelListing(uint256 marketplaceId) external nonReentrant { _delegatecall(_implBuyEditListing, abi.encodeWithSignature("cancelListing(uint256)", marketplaceId)); } function cancelListingBatch(uint256[] calldata marketplaceIds) external nonReentrant { _delegatecall(_implBuyEditListing, abi.encodeWithSignature("cancelListingBatch(uint256[])", marketplaceIds)); } function safeNFTTransferBulkOrdered( BulkTransferInfo[] calldata nftsInfo, uint256 chainId, // not used address destination, // not used bytes calldata data // not used ) external nonReentrant { _delegatecall( _implBatchTransferNFT, abi.encodeWithSignature( "safeNFTTransferBulkOrdered((address,uint256[],uint256[],address)[],uint256,address,bytes)", nftsInfo, chainId, destination, data ) ); } function editPrice(uint256 marketplaceId, uint96 price) external nonReentrant { _delegatecall(_implBuyEditListing, abi.encodeWithSignature("editPrice(uint256,uint96)", marketplaceId, price)); } function editPriceBatch(uint256[] calldata marketplaceIds, uint96[] calldata prices) external nonReentrant { _delegatecall( _implBuyEditListing, abi.encodeWithSignature("editPriceBatch(uint256[],uint96[])", marketplaceIds, prices) ); } function editQuantity(uint256 marketplaceId, uint40 newQuantity) external nonReentrant { _delegatecall( _implBuyEditListing, abi.encodeWithSignature("editQuantity(uint256,uint40)", marketplaceId, newQuantity) ); } function editPriceAndQuantity(uint256 marketplaceId, uint96 newPrice, uint40 newQuantity) external nonReentrant { _delegatecall( _implBuyEditListing, abi.encodeWithSignature("editPriceAndQuantity(uint256,uint96,uint40)", marketplaceId, newPrice, newQuantity) ); } function editOffer( uint256 id, address nft, uint256 tokenId, uint40 newQuantity, uint96 newOfferPrice, uint40 newOfferDuration ) external payable nonReentrant { _delegatecall( _implMakeAndEditOffers, abi.encodeWithSignature( "editOffer(uint256,address,uint256,uint40,uint96,uint40)", id, nft, tokenId, newQuantity, newOfferPrice, newOfferDuration ) ); } function editOfferBatch( uint256[] calldata offerIds, address[] calldata nfts, uint256[] calldata tokenIds, uint40[] calldata newQuantities, uint96[] calldata newOfferPrices, uint40[] calldata newOfferDurations ) external payable nonReentrant { _delegatecall( _implMakeAndEditOffers, abi.encodeWithSignature( "editOfferBatch(uint256[],address[],uint256[],uint96[],uint96[],uint40[])", offerIds, nfts, tokenIds, newQuantities, newOfferPrices, newOfferDurations ) ); } function getSaleDetails(uint256 marketplaceId) external view returns (FullDetails memory) { return listingDetailsToFullDetails(marketplaceId); } function nextMinimumBid(uint256 marketplaceId) public view returns (uint96) { ListingDetails storage listingDetails = _listings[marketplaceId]; if (isAuction(listingDetails.flags)) { uint96 price = listingDetails.price; uint96 highestBid = listingDetails.highestBid; return PaintSwapLibrary.nextMinimumBid(price, highestBid, _minIncreasedBidPercent); } return 0; } function getOffer(uint256 id) external view returns (Offer memory) { return _offers[id]; } // Should be moved down, but dunno if that will affect verification :/ function setOfferDuration(uint256 min, uint256 max) external onlyOwner { require(min != 0, MinCannotBeZero()); require(max >= min, MaxCannotBeLessThanMin()); _minOfferDuration = min; _maxOfferDuration = max; } function setImpls( address implBuyEditListing, address implMakeAndEditOffers, address implBids, address implAcceptOffers, address implListAndComplete, address implBatchTransferNFT, address implP2PSwaps ) external onlyOwner { _implBuyEditListing = implBuyEditListing; _implMakeAndEditOffers = implMakeAndEditOffers; _implBids = implBids; _implAcceptOffers = implAcceptOffers; _implListAndComplete = implListAndComplete; _implBatchTransferNFT = implBatchTransferNFT; _implP2PSwaps = implP2PSwaps; } function auctionGracePeriodForCancelling() external view returns (uint40) { return _auctionGracePeriodForCancelling; } function auctionEndTimeIncreaseCutOff() external view returns (uint40) { return _auctionEndTimeIncreaseCutOff; } function listingFee() external view returns (uint256) { return _listingFee; } function minDuration() external view returns (uint256) { return _minDuration; } function maxDuration() external view returns (uint256) { return _maxDuration; } function minFlashAuctionDuration() external view returns (uint256) { return _minFlashAuctionDuration; } function minAuctionDuration() external view returns (uint256) { return _minAuctionDuration; } function minOfferDuration() external view returns (uint256) { return _minOfferDuration; } function maxOfferDuration() external view returns (uint256) { return _maxOfferDuration; } function flashAuctionEndTimeIncreaseCutOff() external view returns (uint40) { return _flashAuctionEndTimeIncreaseCutOff; } function flashAuctionGracePeriodForCancelling() external view returns (uint40) { return _flashAuctionGracePeriodForCancelling; } function offerCounts(address user) external view returns (uint256 offerCount) { return _offerCounts[user]; } function setDurations( uint256 min, uint256 max, uint256 minAuction, uint256 minFlashAuction, uint256 maxAuction ) external onlyOwner { require(min != 0, MinCannotBeZero()); require(min <= max, MaxCannotBeLessThanMin()); _minDuration = min; _maxDuration = max; require(minAuction != 0, MinCannotBeZero()); require(minAuction <= maxAuction, MaxCannotBeLessThanMin()); require(minFlashAuction != 0, MinCannotBeZero()); require(minFlashAuction <= maxAuction, MaxCannotBeLessThanMin()); _minAuctionDuration = minAuction; _minFlashAuctionDuration = minFlashAuction; _maxAuctionDuration = maxAuction; } function setEnableSelling(bool enable) external onlyOwner { _isSellingEnabled = enable; } function setFeeAddresses(address dev, address salesFee) external onlyOwner { require(dev != address(0)); require(salesFee != address(0)); _devFeeAddress = dev; _salesFeeAddress = salesFee; } // Basis points 10000 function setVariousTimes( uint40 auctionCancellingGracePeriod, uint40 flashAuctionCancellingGracePeriod, uint40 auctionCutOffEndTimeIncrease, uint40 flashAuctionCutOffEndTimeIncrease, uint96 minIncreasedBidPercent ) external onlyOwner { _auctionGracePeriodForCancelling = auctionCancellingGracePeriod; _flashAuctionGracePeriodForCancelling = flashAuctionCancellingGracePeriod; _auctionEndTimeIncreaseCutOff = auctionCutOffEndTimeIncrease; _flashAuctionEndTimeIncreaseCutOff = flashAuctionCutOffEndTimeIncrease; require(minIncreasedBidPercent <= 2000); // 20% _minIncreasedBidPercent = minIncreasedBidPercent; } function setMaxRoyalty(uint256 _maxRoyalty) external onlyOwner { _setMaxRoyalty(_maxRoyalty); } function _setMaxRoyalty(uint256 _maxRoyalty) private { require(_maxRoyalty <= 1000); _royaltyInfo.maxRoyalty = _maxRoyalty; emit MaxRoyaltyInfo(_maxRoyalty); } function setMaxCallGasLimit(uint256 callGasLimit) external onlyOwner { _setMaxCallGasLimit(callGasLimit); } function _setMaxCallGasLimit(uint256 callGasLimit) private { require(callGasLimit < 5000000); _callGasLimit = callGasLimit; emit CallGasLimitInfo(callGasLimit); } function setMaxActiveOfferCount(uint256 maxActiveOfferCount) external onlyOwner { require(maxActiveOfferCount != 0); _maxActiveOfferCount = maxActiveOfferCount; } function setFeePercentage(address feePercentage) external onlyOwner { require(feePercentage != address(0)); _feePercentage = FeePercentage(feePercentage); } function setListingFee(uint96 newListingFee) external onlyOwner { _setListingFee(newListingFee); } function _setListingFee(uint96 newListingFee) private { _listingFee = newListingFee; emit ListingFeeInfo(newListingFee); } // P2P swaps function setUpSwap( Items[] calldata offeringNFTs, uint128 offeringNative, address to, Items[] calldata expectingNFTs, uint128 expectingNative, uint40 duration, string calldata searchKeywords ) external payable override { _delegatecall( _implP2PSwaps, abi.encodeWithSelector( IPaintSwapMarketplaceP2PSwaps.setUpSwap.selector, offeringNFTs, offeringNative, to, expectingNFTs, expectingNative, duration, searchKeywords ) ); } function acceptSwap( Items[] calldata offeringNFTs, uint128 offeringNative, address to, Items[] calldata expectingNFTs, uint128 expectingNative, bool useAvailableWFTM ) external payable override { _delegatecall( _implP2PSwaps, abi.encodeWithSelector( IPaintSwapMarketplaceP2PSwaps.acceptSwap.selector, offeringNFTs, offeringNative, to, expectingNFTs, expectingNative, useAvailableWFTM ) ); } function rejectSwap(address to) external override { _delegatecall(_implP2PSwaps, abi.encodeWithSelector(IPaintSwapMarketplaceP2PSwaps.rejectSwap.selector, to)); } function setSwapCostNative(uint128 swapCostNative) external onlyOwner { _setSwapCostNative(swapCostNative); } function _setSwapCostNative(uint128 swapCostNative) private { _swapCostNative = swapCostNative; emit P2PValues(_swapMaxNFTs, swapCostNative); } function getSwapCostNative() external view returns (uint128) { return _swapCostNative; } // End of P2P Swaps // Various getters to reduce gas cost on the other derived contracts, and trying to be // as compatible with the Fantom contracts as possible function getUserOffersMade(address user, address nft, uint256 tokenId) external view returns (uint256) { return _userOffersMade[user][nft][tokenId]; } function getUserCollectionOffersMade(address user, address nft) external view returns (uint256) { return _userCollectionOffersMade[user][nft]; } function getUserFilteredCollectionOffersMade(address user, address nft) external view returns (uint256) { return _userFilteredCollectionOffersMade[user][nft]; } function getSingleNFTListings(address user, address nft, uint256 tokenId) external view returns (uint256) { return _singleNFTListings[user][nft][tokenId]; } function offerId() external view returns (uint256) { return _offerId; } function _delegatecall(address target, bytes memory data) private returns (bytes memory returndata) { bool success; (success, returndata) = target.delegatecall(data); if (!success) { if (returndata.length == 0) revert(); assembly ("memory-safe") { revert(add(32, returndata), mload(returndata)) } } } function _authorizeUpgrade(address newImplementation) internal override onlyOwner {} receive() external payable {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is set to the address provided by the deployer. This can * later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { /// @custom:storage-location erc7201:openzeppelin.storage.Ownable struct OwnableStorage { address _owner; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300; function _getOwnableStorage() private pure returns (OwnableStorage storage $) { assembly ("memory-safe") { $.slot := OwnableStorageLocation } } /** * @dev The caller account is not authorized to perform an operation. */ error OwnableUnauthorizedAccount(address account); /** * @dev The owner is not a valid owner account. (eg. `address(0)`) */ error OwnableInvalidOwner(address owner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the address provided by the deployer as the initial owner. */ function __Ownable_init(address initialOwner) internal onlyInitializing { __Ownable_init_unchained(initialOwner); } function __Ownable_init_unchained(address initialOwner) internal onlyInitializing { if (initialOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(initialOwner); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { OwnableStorage storage $ = _getOwnableStorage(); return $._owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { if (owner() != _msgSender()) { revert OwnableUnauthorizedAccount(_msgSender()); } } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { if (newOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { OwnableStorage storage $ = _getOwnableStorage(); address oldOwner = $._owner; $._owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.20; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Storage of the initializable contract. * * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions * when using with upgradeable contracts. * * @custom:storage-location erc7201:openzeppelin.storage.Initializable */ struct InitializableStorage { /** * @dev Indicates that the contract has been initialized. */ uint64 _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool _initializing; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00; /** * @dev The contract is already initialized. */ error InvalidInitialization(); /** * @dev The contract is not initializing. */ error NotInitializing(); /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint64 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in * production. * * Emits an {Initialized} event. */ modifier initializer() { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); // Cache values to avoid duplicated sloads bool isTopLevelCall = !$._initializing; uint64 initialized = $._initialized; // Allowed calls: // - initialSetup: the contract is not in the initializing state and no previous version was // initialized // - construction: the contract is initialized at version 1 (no reininitialization) and the // current contract is just being deployed bool initialSetup = initialized == 0 && isTopLevelCall; bool construction = initialized == 1 && address(this).code.length == 0; if (!initialSetup && !construction) { revert InvalidInitialization(); } $._initialized = 1; if (isTopLevelCall) { $._initializing = true; } _; if (isTopLevelCall) { $._initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint64 version) { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing || $._initialized >= version) { revert InvalidInitialization(); } $._initialized = version; $._initializing = true; _; $._initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { _checkInitializing(); _; } /** * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}. */ function _checkInitializing() internal view virtual { if (!_isInitializing()) { revert NotInitializing(); } } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing) { revert InvalidInitialization(); } if ($._initialized != type(uint64).max) { $._initialized = type(uint64).max; emit Initialized(type(uint64).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint64) { return _getInitializableStorage()._initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _getInitializableStorage()._initializing; } /** * @dev Returns a pointer to the storage namespace. */ // solhint-disable-next-line var-name-mixedcase function _getInitializableStorage() private pure returns (InitializableStorage storage $) { assembly ("memory-safe") { $.slot := INITIALIZABLE_STORAGE } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.20; import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol"; import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol"; import {Initializable} from "./Initializable.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. */ abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable { /// @custom:oz-upgrades-unsafe-allow state-variable-immutable address private immutable __self = address(this); /** * @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)` * and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called, * while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string. * If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must * be the empty byte string if no function should be called, making it impossible to invoke the `receive` function * during an upgrade. */ string public constant UPGRADE_INTERFACE_VERSION = "5.0.0"; /** * @dev The call is from an unauthorized context. */ error UUPSUnauthorizedCallContext(); /** * @dev The storage `slot` is unsupported as a UUID. */ error UUPSUnsupportedProxiableUUID(bytes32 slot); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC-1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC-1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { _checkProxy(); _; } /** * @dev Check that the execution is not being performed through a delegate call. This allows a function to be * callable on the implementing contract but not through proxies. */ modifier notDelegated() { _checkNotDelegated(); _; } function __UUPSUpgradeable_init() internal onlyInitializing { } function __UUPSUpgradeable_init_unchained() internal onlyInitializing { } /** * @dev Implementation of the ERC-1822 {proxiableUUID} function. This returns the storage slot used by the * implementation. It is used to validate the implementation's compatibility when performing an upgrade. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier. */ function proxiableUUID() external view virtual notDelegated returns (bytes32) { return ERC1967Utils.IMPLEMENTATION_SLOT; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. * * @custom:oz-upgrades-unsafe-allow-reachable delegatecall */ function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, data); } /** * @dev Reverts if the execution is not performed via delegatecall or the execution * context is not of a proxy with an ERC-1967 compliant implementation pointing to self. * See {_onlyProxy}. */ function _checkProxy() internal view virtual { if ( address(this) == __self || // Must be called through delegatecall ERC1967Utils.getImplementation() != __self // Must be called through an active proxy ) { revert UUPSUnauthorizedCallContext(); } } /** * @dev Reverts if the execution is performed via delegatecall. * See {notDelegated}. */ function _checkNotDelegated() internal view virtual { if (address(this) != __self) { // Must not be called through delegatecall revert UUPSUnauthorizedCallContext(); } } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; /** * @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call. * * As a security check, {proxiableUUID} is invoked in the new implementation, and the return value * is expected to be the implementation slot in ERC-1967. * * Emits an {IERC1967-Upgraded} event. */ function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private { try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) { if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) { revert UUPSUnsupportedProxiableUUID(slot); } ERC1967Utils.upgradeToAndCall(newImplementation, data); } catch { // The implementation is not UUPS revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @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 ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuardTransient.sol) pragma solidity ^0.8.24; import {TransientSlot} from "@openzeppelin/contracts/utils/TransientSlot.sol"; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Variant of {ReentrancyGuard} that uses transient storage. * * NOTE: This variant only works on networks where EIP-1153 is available. * * _Available since v5.1._ */ abstract contract ReentrancyGuardTransientUpgradeable is Initializable { using TransientSlot for *; // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant REENTRANCY_GUARD_STORAGE = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00; /** * @dev Unauthorized reentrant call. */ error ReentrancyGuardReentrantCall(); /** * @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 __ReentrancyGuardTransient_init() internal onlyInitializing { } function __ReentrancyGuardTransient_init_unchained() internal onlyInitializing { } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be NOT_ENTERED if (_reentrancyGuardEntered()) { revert ReentrancyGuardReentrantCall(); } // Any calls to nonReentrant after this point will fail REENTRANCY_GUARD_STORAGE.asBoolean().tstore(true); } function _nonReentrantAfter() private { REENTRANCY_GUARD_STORAGE.asBoolean().tstore(false); } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { return REENTRANCY_GUARD_STORAGE.asBoolean().tload(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {Context} from "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is set to the address provided by the deployer. This can * later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; /** * @dev The caller account is not authorized to perform an operation. */ error OwnableUnauthorizedAccount(address account); /** * @dev The owner is not a valid owner account. (eg. `address(0)`) */ error OwnableInvalidOwner(address owner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the address provided by the deployer as the initial owner. */ constructor(address initialOwner) { if (initialOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(initialOwner); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { if (owner() != _msgSender()) { revert OwnableUnauthorizedAccount(_msgSender()); } } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { if (newOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.20; /** * @dev ERC-1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified * proxy whose upgrades are fully controlled by the current implementation. */ interface IERC1822Proxiable { /** * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation * address. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. */ function proxiableUUID() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC6093.sol) pragma solidity ^0.8.20; /** * @dev Standard ERC-20 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens. */ interface IERC20Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC20InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC20InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers. * @param spender Address that may be allowed to operate on tokens without being their owner. * @param allowance Amount of tokens a `spender` is allowed to operate with. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC20InvalidApprover(address approver); /** * @dev Indicates a failure with the `spender` to be approved. Used in approvals. * @param spender Address that may be allowed to operate on tokens without being their owner. */ error ERC20InvalidSpender(address spender); } /** * @dev Standard ERC-721 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens. */ interface IERC721Errors { /** * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20. * Used in balance queries. * @param owner Address of the current owner of a token. */ error ERC721InvalidOwner(address owner); /** * @dev Indicates a `tokenId` whose `owner` is the zero address. * @param tokenId Identifier number of a token. */ error ERC721NonexistentToken(uint256 tokenId); /** * @dev Indicates an error related to the ownership over a particular token. Used in transfers. * @param sender Address whose tokens are being transferred. * @param tokenId Identifier number of a token. * @param owner Address of the current owner of a token. */ error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC721InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC721InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param tokenId Identifier number of a token. */ error ERC721InsufficientApproval(address operator, uint256 tokenId); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC721InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC721InvalidOperator(address operator); } /** * @dev Standard ERC-1155 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens. */ interface IERC1155Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. * @param tokenId Identifier number of a token. */ error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC1155InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC1155InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param owner Address of the current owner of a token. */ error ERC1155MissingApprovalForAll(address operator, address owner); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC1155InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC1155InvalidOperator(address operator); /** * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation. * Used in batch transfers. * @param idsLength Length of the array of token identifiers * @param valuesLength Length of the array of token amounts */ error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1967.sol) pragma solidity ^0.8.20; /** * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC. */ interface IERC1967 { /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Emitted when the beacon is changed. */ event BeaconUpgraded(address indexed beacon); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.20; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeacon { /** * @dev Must return an address that can be used as a delegate call target. * * {UpgradeableBeacon} will check that this address is a contract. */ function implementation() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (proxy/ERC1967/ERC1967Utils.sol) pragma solidity ^0.8.21; import {IBeacon} from "../beacon/IBeacon.sol"; import {IERC1967} from "../../interfaces/IERC1967.sol"; import {Address} from "../../utils/Address.sol"; import {StorageSlot} from "../../utils/StorageSlot.sol"; /** * @dev This library provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] slots. */ library ERC1967Utils { /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev The `implementation` of the proxy is invalid. */ error ERC1967InvalidImplementation(address implementation); /** * @dev The `admin` of the proxy is invalid. */ error ERC1967InvalidAdmin(address admin); /** * @dev The `beacon` of the proxy is invalid. */ error ERC1967InvalidBeacon(address beacon); /** * @dev An upgrade function sees `msg.value > 0` that may be lost. */ error ERC1967NonPayable(); /** * @dev Returns the current implementation address. */ function getImplementation() internal view returns (address) { return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the ERC-1967 implementation slot. */ function _setImplementation(address newImplementation) private { if (newImplementation.code.length == 0) { revert ERC1967InvalidImplementation(newImplementation); } StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Performs implementation upgrade with additional setup call if data is nonempty. * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected * to avoid stuck value in the contract. * * Emits an {IERC1967-Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) internal { _setImplementation(newImplementation); emit IERC1967.Upgraded(newImplementation); if (data.length > 0) { Address.functionDelegateCall(newImplementation, data); } else { _checkNonPayable(); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Returns the current admin. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using * the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103` */ function getAdmin() internal view returns (address) { return StorageSlot.getAddressSlot(ADMIN_SLOT).value; } /** * @dev Stores a new address in the ERC-1967 admin slot. */ function _setAdmin(address newAdmin) private { if (newAdmin == address(0)) { revert ERC1967InvalidAdmin(address(0)); } StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {IERC1967-AdminChanged} event. */ function changeAdmin(address newAdmin) internal { emit IERC1967.AdminChanged(getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Returns the current beacon. */ function getBeacon() internal view returns (address) { return StorageSlot.getAddressSlot(BEACON_SLOT).value; } /** * @dev Stores a new beacon in the ERC-1967 beacon slot. */ function _setBeacon(address newBeacon) private { if (newBeacon.code.length == 0) { revert ERC1967InvalidBeacon(newBeacon); } StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon; address beaconImplementation = IBeacon(newBeacon).implementation(); if (beaconImplementation.code.length == 0) { revert ERC1967InvalidImplementation(beaconImplementation); } } /** * @dev Change the beacon and trigger a setup call if data is nonempty. * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected * to avoid stuck value in the contract. * * Emits an {IERC1967-BeaconUpgraded} event. * * CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since * it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for * efficiency. */ function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal { _setBeacon(newBeacon); emit IERC1967.BeaconUpgraded(newBeacon); if (data.length > 0) { Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data); } else { _checkNonPayable(); } } /** * @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract * if an upgrade doesn't perform an initialization call. */ function _checkNonPayable() private { if (msg.value > 0) { revert ERC1967NonPayable(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC1155/ERC1155.sol) pragma solidity ^0.8.20; import {IERC1155} from "./IERC1155.sol"; import {IERC1155MetadataURI} from "./extensions/IERC1155MetadataURI.sol"; import {ERC1155Utils} from "./utils/ERC1155Utils.sol"; import {Context} from "../../utils/Context.sol"; import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol"; import {Arrays} from "../../utils/Arrays.sol"; import {IERC1155Errors} from "../../interfaces/draft-IERC6093.sol"; /** * @dev Implementation of the basic standard multi-token. * See https://eips.ethereum.org/EIPS/eip-1155 * Originally based on code by Enjin: https://github.com/enjin/erc-1155 */ abstract contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI, IERC1155Errors { using Arrays for uint256[]; using Arrays for address[]; mapping(uint256 id => mapping(address account => uint256)) private _balances; mapping(address account => mapping(address operator => bool)) private _operatorApprovals; // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json string private _uri; /** * @dev See {_setURI}. */ constructor(string memory uri_) { _setURI(uri_); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC1155).interfaceId || interfaceId == type(IERC1155MetadataURI).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC1155MetadataURI-uri}. * * This implementation returns the same URI for *all* token types. It relies * on the token type ID substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the ERC]. * * Clients calling this function must replace the `\{id\}` substring with the * actual token type ID. */ function uri(uint256 /* id */) public view virtual returns (string memory) { return _uri; } /** * @dev See {IERC1155-balanceOf}. */ function balanceOf(address account, uint256 id) public view virtual returns (uint256) { return _balances[id][account]; } /** * @dev See {IERC1155-balanceOfBatch}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch( address[] memory accounts, uint256[] memory ids ) public view virtual returns (uint256[] memory) { if (accounts.length != ids.length) { revert ERC1155InvalidArrayLength(ids.length, accounts.length); } uint256[] memory batchBalances = new uint256[](accounts.length); for (uint256 i = 0; i < accounts.length; ++i) { batchBalances[i] = balanceOf(accounts.unsafeMemoryAccess(i), ids.unsafeMemoryAccess(i)); } return batchBalances; } /** * @dev See {IERC1155-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC1155-isApprovedForAll}. */ function isApprovedForAll(address account, address operator) public view virtual returns (bool) { return _operatorApprovals[account][operator]; } /** * @dev See {IERC1155-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) public virtual { address sender = _msgSender(); if (from != sender && !isApprovedForAll(from, sender)) { revert ERC1155MissingApprovalForAll(sender, from); } _safeTransferFrom(from, to, id, value, data); } /** * @dev See {IERC1155-safeBatchTransferFrom}. */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory values, bytes memory data ) public virtual { address sender = _msgSender(); if (from != sender && !isApprovedForAll(from, sender)) { revert ERC1155MissingApprovalForAll(sender, from); } _safeBatchTransferFrom(from, to, ids, values, data); } /** * @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`. Will mint (or burn) if `from` * (or `to`) is the zero address. * * Emits a {TransferSingle} event if the arrays contain one element, and {TransferBatch} otherwise. * * Requirements: * * - If `to` refers to a smart contract, it must implement either {IERC1155Receiver-onERC1155Received} * or {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value. * - `ids` and `values` must have the same length. * * NOTE: The ERC-1155 acceptance check is not performed in this function. See {_updateWithAcceptanceCheck} instead. */ function _update(address from, address to, uint256[] memory ids, uint256[] memory values) internal virtual { if (ids.length != values.length) { revert ERC1155InvalidArrayLength(ids.length, values.length); } address operator = _msgSender(); for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids.unsafeMemoryAccess(i); uint256 value = values.unsafeMemoryAccess(i); if (from != address(0)) { uint256 fromBalance = _balances[id][from]; if (fromBalance < value) { revert ERC1155InsufficientBalance(from, fromBalance, value, id); } unchecked { // Overflow not possible: value <= fromBalance _balances[id][from] = fromBalance - value; } } if (to != address(0)) { _balances[id][to] += value; } } if (ids.length == 1) { uint256 id = ids.unsafeMemoryAccess(0); uint256 value = values.unsafeMemoryAccess(0); emit TransferSingle(operator, from, to, id, value); } else { emit TransferBatch(operator, from, to, ids, values); } } /** * @dev Version of {_update} that performs the token acceptance check by calling * {IERC1155Receiver-onERC1155Received} or {IERC1155Receiver-onERC1155BatchReceived} on the receiver address if it * contains code (eg. is a smart contract at the moment of execution). * * IMPORTANT: Overriding this function is discouraged because it poses a reentrancy risk from the receiver. So any * update to the contract state after this function would break the check-effect-interaction pattern. Consider * overriding {_update} instead. */ function _updateWithAcceptanceCheck( address from, address to, uint256[] memory ids, uint256[] memory values, bytes memory data ) internal virtual { _update(from, to, ids, values); if (to != address(0)) { address operator = _msgSender(); if (ids.length == 1) { uint256 id = ids.unsafeMemoryAccess(0); uint256 value = values.unsafeMemoryAccess(0); ERC1155Utils.checkOnERC1155Received(operator, from, to, id, value, data); } else { ERC1155Utils.checkOnERC1155BatchReceived(operator, from, to, ids, values, data); } } } /** * @dev Transfers a `value` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - `from` must have a balance of tokens of type `id` of at least `value` amount. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) internal { if (to == address(0)) { revert ERC1155InvalidReceiver(address(0)); } if (from == address(0)) { revert ERC1155InvalidSender(address(0)); } (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value); _updateWithAcceptanceCheck(from, to, ids, values, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. * - `ids` and `values` must have the same length. */ function _safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory values, bytes memory data ) internal { if (to == address(0)) { revert ERC1155InvalidReceiver(address(0)); } if (from == address(0)) { revert ERC1155InvalidSender(address(0)); } _updateWithAcceptanceCheck(from, to, ids, values, data); } /** * @dev Sets a new URI for all token types, by relying on the token type ID * substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the ERC]. * * By this mechanism, any occurrence of the `\{id\}` substring in either the * URI or any of the values in the JSON file at said URI will be replaced by * clients with the token type ID. * * For example, the `https://token-cdn-domain/\{id\}.json` URI would be * interpreted by clients as * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json` * for token type ID 0x4cce0. * * See {uri}. * * Because these URIs cannot be meaningfully represented by the {URI} event, * this function emits no events. */ function _setURI(string memory newuri) internal virtual { _uri = newuri; } /** * @dev Creates a `value` amount of tokens of type `id`, and assigns them to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint(address to, uint256 id, uint256 value, bytes memory data) internal { if (to == address(0)) { revert ERC1155InvalidReceiver(address(0)); } (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value); _updateWithAcceptanceCheck(address(0), to, ids, values, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `values` must have the same length. * - `to` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _mintBatch(address to, uint256[] memory ids, uint256[] memory values, bytes memory data) internal { if (to == address(0)) { revert ERC1155InvalidReceiver(address(0)); } _updateWithAcceptanceCheck(address(0), to, ids, values, data); } /** * @dev Destroys a `value` amount of tokens of type `id` from `from` * * Emits a {TransferSingle} event. * * Requirements: * * - `from` cannot be the zero address. * - `from` must have at least `value` amount of tokens of type `id`. */ function _burn(address from, uint256 id, uint256 value) internal { if (from == address(0)) { revert ERC1155InvalidSender(address(0)); } (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value); _updateWithAcceptanceCheck(from, address(0), ids, values, ""); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}. * * Emits a {TransferBatch} event. * * Requirements: * * - `from` cannot be the zero address. * - `from` must have at least `value` amount of tokens of type `id`. * - `ids` and `values` must have the same length. */ function _burnBatch(address from, uint256[] memory ids, uint256[] memory values) internal { if (from == address(0)) { revert ERC1155InvalidSender(address(0)); } _updateWithAcceptanceCheck(from, address(0), ids, values, ""); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the zero address. */ function _setApprovalForAll(address owner, address operator, bool approved) internal virtual { if (operator == address(0)) { revert ERC1155InvalidOperator(address(0)); } _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Creates an array in memory with only one value for each of the elements provided. */ function _asSingletonArrays( uint256 element1, uint256 element2 ) private pure returns (uint256[] memory array1, uint256[] memory array2) { assembly ("memory-safe") { // Load the free memory pointer array1 := mload(0x40) // Set array length to 1 mstore(array1, 1) // Store the single element at the next word after the length (where content starts) mstore(add(array1, 0x20), element1) // Repeat for next array locating it right after the first array array2 := add(array1, 0x40) mstore(array2, 1) mstore(add(array2, 0x20), element2) // Update the free memory pointer by pointing after the second array mstore(0x40, add(array2, 0x40)) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC1155/extensions/IERC1155MetadataURI.sol) pragma solidity ^0.8.20; import {IERC1155} from "../IERC1155.sol"; /** * @dev Interface of the optional ERC1155MetadataExtension interface, as defined * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[ERC]. */ interface IERC1155MetadataURI is IERC1155 { /** * @dev Returns the URI for token type `id`. * * If the `\{id\}` substring is present in the URI, it must be replaced by * clients with the actual token type ID. */ function uri(uint256 id) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC1155/IERC1155.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC-1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[ERC]. */ interface IERC1155 is IERC165 { /** * @dev Emitted when `value` amount of tokens of type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the value of tokens of token type `id` owned by `account`. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch( address[] calldata accounts, uint256[] calldata ids ) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the zero address. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`. * * WARNING: This function can potentially allow a reentrancy attack when transferring tokens * to an untrusted contract, when invoking {onERC1155Received} on the receiver. * Ensure to follow the checks-effects-interactions pattern and consider employing * reentrancy guards when interacting with untrusted contracts. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `value` amount. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * WARNING: This function can potentially allow a reentrancy attack when transferring tokens * to an untrusted contract, when invoking {onERC1155BatchReceived} on the receiver. * Ensure to follow the checks-effects-interactions pattern and consider employing * reentrancy guards when interacting with untrusted contracts. * * Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments. * * Requirements: * * - `ids` and `values` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC1155/IERC1155Receiver.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Interface that must be implemented by smart contracts in order to receive * ERC-1155 token transfers. */ interface IERC1155Receiver is IERC165 { /** * @dev Handles the receipt of a single ERC-1155 token type. This function is * called at the end of a `safeTransferFrom` after the balance has been updated. * * NOTE: To accept the transfer, this must return * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` * (i.e. 0xf23a6e61, or its own function selector). * * @param operator The address which initiated the transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param id The ID of the token being transferred * @param value The amount of tokens being transferred * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4); /** * @dev Handles the receipt of a multiple ERC-1155 token types. This function * is called at the end of a `safeBatchTransferFrom` after the balances have * been updated. * * NOTE: To accept the transfer(s), this must return * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` * (i.e. 0xbc197c81, or its own function selector). * * @param operator The address which initiated the batch transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param ids An array containing ids of each token being transferred (order and length must match values array) * @param values An array containing amounts of each token being transferred (order and length must match ids array) * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC1155/utils/ERC1155Utils.sol) pragma solidity ^0.8.20; import {IERC1155Receiver} from "../IERC1155Receiver.sol"; import {IERC1155Errors} from "../../../interfaces/draft-IERC6093.sol"; /** * @dev Library that provide common ERC-1155 utility functions. * * See https://eips.ethereum.org/EIPS/eip-1155[ERC-1155]. * * _Available since v5.1._ */ library ERC1155Utils { /** * @dev Performs an acceptance check for the provided `operator` by calling {IERC1155-onERC1155Received} * on the `to` address. The `operator` is generally the address that initiated the token transfer (i.e. `msg.sender`). * * The acceptance call is not executed and treated as a no-op if the target address doesn't contain code (i.e. an EOA). * Otherwise, the recipient must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value to accept * the transfer. */ function checkOnERC1155Received( address operator, address from, address to, uint256 id, uint256 value, bytes memory data ) internal { if (to.code.length > 0) { try IERC1155Receiver(to).onERC1155Received(operator, from, id, value, data) returns (bytes4 response) { if (response != IERC1155Receiver.onERC1155Received.selector) { // Tokens rejected revert IERC1155Errors.ERC1155InvalidReceiver(to); } } catch (bytes memory reason) { if (reason.length == 0) { // non-IERC1155Receiver implementer revert IERC1155Errors.ERC1155InvalidReceiver(to); } else { assembly ("memory-safe") { revert(add(32, reason), mload(reason)) } } } } } /** * @dev Performs a batch acceptance check for the provided `operator` by calling {IERC1155-onERC1155BatchReceived} * on the `to` address. The `operator` is generally the address that initiated the token transfer (i.e. `msg.sender`). * * The acceptance call is not executed and treated as a no-op if the target address doesn't contain code (i.e. an EOA). * Otherwise, the recipient must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value to accept * the transfer. */ function checkOnERC1155BatchReceived( address operator, address from, address to, uint256[] memory ids, uint256[] memory values, bytes memory data ) internal { if (to.code.length > 0) { try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, values, data) returns ( bytes4 response ) { if (response != IERC1155Receiver.onERC1155BatchReceived.selector) { // Tokens rejected revert IERC1155Errors.ERC1155InvalidReceiver(to); } } catch (bytes memory reason) { if (reason.length == 0) { // non-IERC1155Receiver implementer revert IERC1155Errors.ERC1155InvalidReceiver(to); } else { assembly ("memory-safe") { revert(add(32, reason), mload(reason)) } } } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "./IERC20.sol"; import {IERC20Metadata} from "./extensions/IERC20Metadata.sol"; import {Context} from "../../utils/Context.sol"; import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * * TIP: For a detailed writeup see our guide * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * The default value of {decimals} is 18. To change this, you should override * this function so it returns a different value. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC-20 * applications. */ abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors { mapping(address account => uint256) private _balances; mapping(address account => mapping(address spender => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * 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 returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the default value returned by this function, unless * it's overridden. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `value`. */ function transfer(address to, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _transfer(owner, to, value); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, value); return true; } /** * @dev See {IERC20-transferFrom}. * * Skips emitting an {Approval} event indicating an allowance update. This is not * required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve]. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `value`. * - the caller must have allowance for ``from``'s tokens of at least * `value`. */ function transferFrom(address from, address to, uint256 value) public virtual returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, value); _transfer(from, to, value); return true; } /** * @dev Moves a `value` amount of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _transfer(address from, address to, uint256 value) internal { if (from == address(0)) { revert ERC20InvalidSender(address(0)); } if (to == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(from, to, value); } /** * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from` * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding * this function. * * Emits a {Transfer} event. */ function _update(address from, address to, uint256 value) internal virtual { if (from == address(0)) { // Overflow check required: The rest of the code assumes that totalSupply never overflows _totalSupply += value; } else { uint256 fromBalance = _balances[from]; if (fromBalance < value) { revert ERC20InsufficientBalance(from, fromBalance, value); } unchecked { // Overflow not possible: value <= fromBalance <= totalSupply. _balances[from] = fromBalance - value; } } if (to == address(0)) { unchecked { // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply. _totalSupply -= value; } } else { unchecked { // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256. _balances[to] += value; } } emit Transfer(from, to, value); } /** * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0). * Relies on the `_update` mechanism * * Emits a {Transfer} event with `from` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _mint(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(address(0), account, value); } /** * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply. * Relies on the `_update` mechanism. * * Emits a {Transfer} event with `to` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead */ function _burn(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidSender(address(0)); } _update(account, address(0), value); } /** * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. * * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument. */ function _approve(address owner, address spender, uint256 value) internal { _approve(owner, spender, value, true); } /** * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event. * * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any * `Approval` event during `transferFrom` operations. * * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to * true using the following override: * * ```solidity * function _approve(address owner, address spender, uint256 value, bool) internal virtual override { * super._approve(owner, spender, value, true); * } * ``` * * Requirements are the same as {_approve}. */ function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual { if (owner == address(0)) { revert ERC20InvalidApprover(address(0)); } if (spender == address(0)) { revert ERC20InvalidSpender(address(0)); } _allowances[owner][spender] = value; if (emitEvent) { emit Approval(owner, spender, value); } } /** * @dev Updates `owner` s allowance for `spender` based on spent `value`. * * Does not update the allowance value in case of infinite allowance. * Revert if not enough allowance is available. * * Does not emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 value) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { if (currentAllowance < value) { revert ERC20InsufficientAllowance(spender, currentAllowance, value); } unchecked { _approve(owner, spender, currentAllowance - value, false); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC-20 standard. */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC-20 standard as defined in the ERC. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 value) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.20; import {IERC721} from "./IERC721.sol"; import {IERC721Metadata} from "./extensions/IERC721Metadata.sol"; import {ERC721Utils} from "./utils/ERC721Utils.sol"; import {Context} from "../../utils/Context.sol"; import {Strings} from "../../utils/Strings.sol"; import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol"; import {IERC721Errors} from "../../interfaces/draft-IERC6093.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC-721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Errors { using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; mapping(uint256 tokenId => address) private _owners; mapping(address owner => uint256) private _balances; mapping(uint256 tokenId => address) private _tokenApprovals; mapping(address owner => mapping(address operator => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual returns (uint256) { if (owner == address(0)) { revert ERC721InvalidOwner(address(0)); } return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual returns (address) { return _requireOwned(tokenId); } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual returns (string memory) { _requireOwned(tokenId); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string.concat(baseURI, tokenId.toString()) : ""; } /** * @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, can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual { _approve(to, tokenId, _msgSender()); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual returns (address) { _requireOwned(tokenId); return _getApproved(tokenId); } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom(address from, address to, uint256 tokenId) public virtual { if (to == address(0)) { revert ERC721InvalidReceiver(address(0)); } // Setting an "auth" arguments enables the `_isAuthorized` check which verifies that the token exists // (from != 0). Therefore, it is not needed to verify that the return value is not 0 here. address previousOwner = _update(to, tokenId, _msgSender()); if (previousOwner != from) { revert ERC721IncorrectOwner(from, tokenId, previousOwner); } } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual { transferFrom(from, to, tokenId); ERC721Utils.checkOnERC721Received(_msgSender(), from, to, tokenId, data); } /** * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist * * IMPORTANT: Any overrides to this function that add ownership of tokens not tracked by the * core ERC-721 logic MUST be matched with the use of {_increaseBalance} to keep balances * consistent with ownership. The invariant to preserve is that for any address `a` the value returned by * `balanceOf(a)` must be equal to the number of tokens such that `_ownerOf(tokenId)` is `a`. */ function _ownerOf(uint256 tokenId) internal view virtual returns (address) { return _owners[tokenId]; } /** * @dev Returns the approved address for `tokenId`. Returns 0 if `tokenId` is not minted. */ function _getApproved(uint256 tokenId) internal view virtual returns (address) { return _tokenApprovals[tokenId]; } /** * @dev Returns whether `spender` is allowed to manage `owner`'s tokens, or `tokenId` in * particular (ignoring whether it is owned by `owner`). * * WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this * assumption. */ function _isAuthorized(address owner, address spender, uint256 tokenId) internal view virtual returns (bool) { return spender != address(0) && (owner == spender || isApprovedForAll(owner, spender) || _getApproved(tokenId) == spender); } /** * @dev Checks if `spender` can operate on `tokenId`, assuming the provided `owner` is the actual owner. * Reverts if: * - `spender` does not have approval from `owner` for `tokenId`. * - `spender` does not have approval to manage all of `owner`'s assets. * * WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this * assumption. */ function _checkAuthorized(address owner, address spender, uint256 tokenId) internal view virtual { if (!_isAuthorized(owner, spender, tokenId)) { if (owner == address(0)) { revert ERC721NonexistentToken(tokenId); } else { revert ERC721InsufficientApproval(spender, tokenId); } } } /** * @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override. * * NOTE: the value is limited to type(uint128).max. This protect against _balance overflow. It is unrealistic that * a uint256 would ever overflow from increments when these increments are bounded to uint128 values. * * WARNING: Increasing an account's balance using this function tends to be paired with an override of the * {_ownerOf} function to resolve the ownership of the corresponding tokens so that balances and ownership * remain consistent with one another. */ function _increaseBalance(address account, uint128 value) internal virtual { unchecked { _balances[account] += value; } } /** * @dev Transfers `tokenId` from its current owner to `to`, or alternatively mints (or burns) if the current owner * (or `to`) is the zero address. Returns the owner of the `tokenId` before the update. * * The `auth` argument is optional. If the value passed is non 0, then this function will check that * `auth` is either the owner of the token, or approved to operate on the token (by the owner). * * Emits a {Transfer} event. * * NOTE: If overriding this function in a way that tracks balances, see also {_increaseBalance}. */ function _update(address to, uint256 tokenId, address auth) internal virtual returns (address) { address from = _ownerOf(tokenId); // Perform (optional) operator check if (auth != address(0)) { _checkAuthorized(from, auth, tokenId); } // Execute the update if (from != address(0)) { // Clear approval. No need to re-authorize or emit the Approval event _approve(address(0), tokenId, address(0), false); unchecked { _balances[from] -= 1; } } if (to != address(0)) { unchecked { _balances[to] += 1; } } _owners[tokenId] = to; emit Transfer(from, to, tokenId); return from; } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal { if (to == address(0)) { revert ERC721InvalidReceiver(address(0)); } address previousOwner = _update(to, tokenId, address(0)); if (previousOwner != address(0)) { revert ERC721InvalidSender(address(0)); } } /** * @dev Mints `tokenId`, transfers it to `to` and checks for `to` acceptance. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual { _mint(to, tokenId); ERC721Utils.checkOnERC721Received(_msgSender(), address(0), to, tokenId, data); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * This is an internal function that does not check if the sender is authorized to operate on the token. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal { address previousOwner = _update(address(0), tokenId, address(0)); if (previousOwner == address(0)) { revert ERC721NonexistentToken(tokenId); } } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal { if (to == address(0)) { revert ERC721InvalidReceiver(address(0)); } address previousOwner = _update(to, tokenId, address(0)); if (previousOwner == address(0)) { revert ERC721NonexistentToken(tokenId); } else if (previousOwner != from) { revert ERC721IncorrectOwner(from, tokenId, previousOwner); } } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking that contract recipients * are aware of the ERC-721 standard to prevent tokens from being forever locked. * * `data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is like {safeTransferFrom} in the sense that it invokes * {IERC721Receiver-onERC721Received} on the receiver, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `tokenId` token must exist and be owned by `from`. * - `to` cannot be the zero address. * - `from` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer(address from, address to, uint256 tokenId) internal { _safeTransfer(from, to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeTransfer-address-address-uint256-}[`_safeTransfer`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual { _transfer(from, to, tokenId); ERC721Utils.checkOnERC721Received(_msgSender(), from, to, tokenId, data); } /** * @dev Approve `to` to operate on `tokenId` * * The `auth` argument is optional. If the value passed is non 0, then this function will check that `auth` is * either the owner of the token, or approved to operate on all tokens held by this owner. * * Emits an {Approval} event. * * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument. */ function _approve(address to, uint256 tokenId, address auth) internal { _approve(to, tokenId, auth, true); } /** * @dev Variant of `_approve` with an optional flag to enable or disable the {Approval} event. The event is not * emitted in the context of transfers. */ function _approve(address to, uint256 tokenId, address auth, bool emitEvent) internal virtual { // Avoid reading the owner unless necessary if (emitEvent || auth != address(0)) { address owner = _requireOwned(tokenId); // We do not use _isAuthorized because single-token approvals should not be able to call approve if (auth != address(0) && owner != auth && !isApprovedForAll(owner, auth)) { revert ERC721InvalidApprover(auth); } if (emitEvent) { emit Approval(owner, to, tokenId); } } _tokenApprovals[tokenId] = to; } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Requirements: * - operator can't be the address zero. * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll(address owner, address operator, bool approved) internal virtual { if (operator == address(0)) { revert ERC721InvalidOperator(operator); } _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Reverts if the `tokenId` doesn't have a current owner (it hasn't been minted, or it has been burned). * Returns the owner. * * Overrides to ownership logic should be done to {_ownerOf}. */ function _requireOwned(uint256 tokenId) internal view returns (address) { address owner = _ownerOf(tokenId); if (owner == address(0)) { revert ERC721NonexistentToken(tokenId); } return owner; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.20; import {IERC721} from "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC-721 compliant contract. */ interface IERC721 is IERC165 { /** * @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 ERC-721 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 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: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC-721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * 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 address zero. * * 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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.20; /** * @title ERC-721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC-721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be * reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/utils/ERC721Utils.sol) pragma solidity ^0.8.20; import {IERC721Receiver} from "../IERC721Receiver.sol"; import {IERC721Errors} from "../../../interfaces/draft-IERC6093.sol"; /** * @dev Library that provide common ERC-721 utility functions. * * See https://eips.ethereum.org/EIPS/eip-721[ERC-721]. * * _Available since v5.1._ */ library ERC721Utils { /** * @dev Performs an acceptance check for the provided `operator` by calling {IERC721-onERC721Received} * on the `to` address. The `operator` is generally the address that initiated the token transfer (i.e. `msg.sender`). * * The acceptance call is not executed and treated as a no-op if the target address doesn't contain code (i.e. an EOA). * Otherwise, the recipient must implement {IERC721Receiver-onERC721Received} and return the acceptance magic value to accept * the transfer. */ function checkOnERC721Received( address operator, address from, address to, uint256 tokenId, bytes memory data ) internal { if (to.code.length > 0) { try IERC721Receiver(to).onERC721Received(operator, from, tokenId, data) returns (bytes4 retval) { if (retval != IERC721Receiver.onERC721Received.selector) { // Token rejected revert IERC721Errors.ERC721InvalidReceiver(to); } } catch (bytes memory reason) { if (reason.length == 0) { // non-IERC721Receiver implementer revert IERC721Errors.ERC721InvalidReceiver(to); } else { assembly ("memory-safe") { revert(add(32, reason), mload(reason)) } } } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Address.sol) pragma solidity ^0.8.20; import {Errors} from "./Errors.sol"; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @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://consensys.net/diligence/blog/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.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert Errors.InsufficientBalance(address(this).balance, amount); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert Errors.FailedCall(); } } /** * @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 or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {Errors.FailedCall} error. * * 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. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @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`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert Errors.InsufficientBalance(address(this).balance, value); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case * of an unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {Errors.FailedCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}. */ function _revert(bytes memory returndata) 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 assembly ("memory-safe") { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert Errors.FailedCall(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Arrays.sol) // This file was procedurally generated from scripts/generate/templates/Arrays.js. pragma solidity ^0.8.20; import {Comparators} from "./Comparators.sol"; import {SlotDerivation} from "./SlotDerivation.sol"; import {StorageSlot} from "./StorageSlot.sol"; import {Math} from "./math/Math.sol"; /** * @dev Collection of functions related to array types. */ library Arrays { using SlotDerivation for bytes32; using StorageSlot for bytes32; /** * @dev Sort an array of uint256 (in memory) following the provided comparator function. * * This function does the sorting "in place", meaning that it overrides the input. The object is returned for * convenience, but that returned value can be discarded safely if the caller has a memory pointer to the array. * * NOTE: this function's cost is `O(n · log(n))` in average and `O(n²)` in the worst case, with n the length of the * array. Using it in view functions that are executed through `eth_call` is safe, but one should be very careful * when executing this as part of a transaction. If the array being sorted is too large, the sort operation may * consume more gas than is available in a block, leading to potential DoS. * * IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way. */ function sort( uint256[] memory array, function(uint256, uint256) pure returns (bool) comp ) internal pure returns (uint256[] memory) { _quickSort(_begin(array), _end(array), comp); return array; } /** * @dev Variant of {sort} that sorts an array of uint256 in increasing order. */ function sort(uint256[] memory array) internal pure returns (uint256[] memory) { sort(array, Comparators.lt); return array; } /** * @dev Sort an array of address (in memory) following the provided comparator function. * * This function does the sorting "in place", meaning that it overrides the input. The object is returned for * convenience, but that returned value can be discarded safely if the caller has a memory pointer to the array. * * NOTE: this function's cost is `O(n · log(n))` in average and `O(n²)` in the worst case, with n the length of the * array. Using it in view functions that are executed through `eth_call` is safe, but one should be very careful * when executing this as part of a transaction. If the array being sorted is too large, the sort operation may * consume more gas than is available in a block, leading to potential DoS. * * IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way. */ function sort( address[] memory array, function(address, address) pure returns (bool) comp ) internal pure returns (address[] memory) { sort(_castToUint256Array(array), _castToUint256Comp(comp)); return array; } /** * @dev Variant of {sort} that sorts an array of address in increasing order. */ function sort(address[] memory array) internal pure returns (address[] memory) { sort(_castToUint256Array(array), Comparators.lt); return array; } /** * @dev Sort an array of bytes32 (in memory) following the provided comparator function. * * This function does the sorting "in place", meaning that it overrides the input. The object is returned for * convenience, but that returned value can be discarded safely if the caller has a memory pointer to the array. * * NOTE: this function's cost is `O(n · log(n))` in average and `O(n²)` in the worst case, with n the length of the * array. Using it in view functions that are executed through `eth_call` is safe, but one should be very careful * when executing this as part of a transaction. If the array being sorted is too large, the sort operation may * consume more gas than is available in a block, leading to potential DoS. * * IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way. */ function sort( bytes32[] memory array, function(bytes32, bytes32) pure returns (bool) comp ) internal pure returns (bytes32[] memory) { sort(_castToUint256Array(array), _castToUint256Comp(comp)); return array; } /** * @dev Variant of {sort} that sorts an array of bytes32 in increasing order. */ function sort(bytes32[] memory array) internal pure returns (bytes32[] memory) { sort(_castToUint256Array(array), Comparators.lt); return array; } /** * @dev Performs a quick sort of a segment of memory. The segment sorted starts at `begin` (inclusive), and stops * at end (exclusive). Sorting follows the `comp` comparator. * * Invariant: `begin <= end`. This is the case when initially called by {sort} and is preserved in subcalls. * * IMPORTANT: Memory locations between `begin` and `end` are not validated/zeroed. This function should * be used only if the limits are within a memory array. */ function _quickSort(uint256 begin, uint256 end, function(uint256, uint256) pure returns (bool) comp) private pure { unchecked { if (end - begin < 0x40) return; // Use first element as pivot uint256 pivot = _mload(begin); // Position where the pivot should be at the end of the loop uint256 pos = begin; for (uint256 it = begin + 0x20; it < end; it += 0x20) { if (comp(_mload(it), pivot)) { // If the value stored at the iterator's position comes before the pivot, we increment the // position of the pivot and move the value there. pos += 0x20; _swap(pos, it); } } _swap(begin, pos); // Swap pivot into place _quickSort(begin, pos, comp); // Sort the left side of the pivot _quickSort(pos + 0x20, end, comp); // Sort the right side of the pivot } } /** * @dev Pointer to the memory location of the first element of `array`. */ function _begin(uint256[] memory array) private pure returns (uint256 ptr) { assembly ("memory-safe") { ptr := add(array, 0x20) } } /** * @dev Pointer to the memory location of the first memory word (32bytes) after `array`. This is the memory word * that comes just after the last element of the array. */ function _end(uint256[] memory array) private pure returns (uint256 ptr) { unchecked { return _begin(array) + array.length * 0x20; } } /** * @dev Load memory word (as a uint256) at location `ptr`. */ function _mload(uint256 ptr) private pure returns (uint256 value) { assembly ("memory-safe") { value := mload(ptr) } } /** * @dev Swaps the elements memory location `ptr1` and `ptr2`. */ function _swap(uint256 ptr1, uint256 ptr2) private pure { assembly ("memory-safe") { let value1 := mload(ptr1) let value2 := mload(ptr2) mstore(ptr1, value2) mstore(ptr2, value1) } } /// @dev Helper: low level cast address memory array to uint256 memory array function _castToUint256Array(address[] memory input) private pure returns (uint256[] memory output) { assembly ("memory-safe") { output := input } } /// @dev Helper: low level cast bytes32 memory array to uint256 memory array function _castToUint256Array(bytes32[] memory input) private pure returns (uint256[] memory output) { assembly ("memory-safe") { output := input } } /// @dev Helper: low level cast address comp function to uint256 comp function function _castToUint256Comp( function(address, address) pure returns (bool) input ) private pure returns (function(uint256, uint256) pure returns (bool) output) { assembly ("memory-safe") { output := input } } /// @dev Helper: low level cast bytes32 comp function to uint256 comp function function _castToUint256Comp( function(bytes32, bytes32) pure returns (bool) input ) private pure returns (function(uint256, uint256) pure returns (bool) output) { assembly ("memory-safe") { output := input } } /** * @dev Searches a sorted `array` and returns the first index that contains * a value greater or equal to `element`. If no such index exists (i.e. all * values in the array are strictly less than `element`), the array length is * returned. Time complexity O(log n). * * NOTE: The `array` is expected to be sorted in ascending order, and to * contain no repeated elements. * * IMPORTANT: Deprecated. This implementation behaves as {lowerBound} but lacks * support for repeated elements in the array. The {lowerBound} function should * be used instead. */ function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) { uint256 low = 0; uint256 high = array.length; if (high == 0) { return 0; } while (low < high) { uint256 mid = Math.average(low, high); // Note that mid will always be strictly less than high (i.e. it will be a valid array index) // because Math.average rounds towards zero (it does integer division with truncation). if (unsafeAccess(array, mid).value > element) { high = mid; } else { low = mid + 1; } } // At this point `low` is the exclusive upper bound. We will return the inclusive upper bound. if (low > 0 && unsafeAccess(array, low - 1).value == element) { return low - 1; } else { return low; } } /** * @dev Searches an `array` sorted in ascending order and returns the first * index that contains a value greater or equal than `element`. If no such index * exists (i.e. all values in the array are strictly less than `element`), the array * length is returned. Time complexity O(log n). * * See C++'s https://en.cppreference.com/w/cpp/algorithm/lower_bound[lower_bound]. */ function lowerBound(uint256[] storage array, uint256 element) internal view returns (uint256) { uint256 low = 0; uint256 high = array.length; if (high == 0) { return 0; } while (low < high) { uint256 mid = Math.average(low, high); // Note that mid will always be strictly less than high (i.e. it will be a valid array index) // because Math.average rounds towards zero (it does integer division with truncation). if (unsafeAccess(array, mid).value < element) { // this cannot overflow because mid < high unchecked { low = mid + 1; } } else { high = mid; } } return low; } /** * @dev Searches an `array` sorted in ascending order and returns the first * index that contains a value strictly greater than `element`. If no such index * exists (i.e. all values in the array are strictly less than `element`), the array * length is returned. Time complexity O(log n). * * See C++'s https://en.cppreference.com/w/cpp/algorithm/upper_bound[upper_bound]. */ function upperBound(uint256[] storage array, uint256 element) internal view returns (uint256) { uint256 low = 0; uint256 high = array.length; if (high == 0) { return 0; } while (low < high) { uint256 mid = Math.average(low, high); // Note that mid will always be strictly less than high (i.e. it will be a valid array index) // because Math.average rounds towards zero (it does integer division with truncation). if (unsafeAccess(array, mid).value > element) { high = mid; } else { // this cannot overflow because mid < high unchecked { low = mid + 1; } } } return low; } /** * @dev Same as {lowerBound}, but with an array in memory. */ function lowerBoundMemory(uint256[] memory array, uint256 element) internal pure returns (uint256) { uint256 low = 0; uint256 high = array.length; if (high == 0) { return 0; } while (low < high) { uint256 mid = Math.average(low, high); // Note that mid will always be strictly less than high (i.e. it will be a valid array index) // because Math.average rounds towards zero (it does integer division with truncation). if (unsafeMemoryAccess(array, mid) < element) { // this cannot overflow because mid < high unchecked { low = mid + 1; } } else { high = mid; } } return low; } /** * @dev Same as {upperBound}, but with an array in memory. */ function upperBoundMemory(uint256[] memory array, uint256 element) internal pure returns (uint256) { uint256 low = 0; uint256 high = array.length; if (high == 0) { return 0; } while (low < high) { uint256 mid = Math.average(low, high); // Note that mid will always be strictly less than high (i.e. it will be a valid array index) // because Math.average rounds towards zero (it does integer division with truncation). if (unsafeMemoryAccess(array, mid) > element) { high = mid; } else { // this cannot overflow because mid < high unchecked { low = mid + 1; } } } return low; } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeAccess(address[] storage arr, uint256 pos) internal pure returns (StorageSlot.AddressSlot storage) { bytes32 slot; assembly ("memory-safe") { slot := arr.slot } return slot.deriveArray().offset(pos).getAddressSlot(); } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeAccess(bytes32[] storage arr, uint256 pos) internal pure returns (StorageSlot.Bytes32Slot storage) { bytes32 slot; assembly ("memory-safe") { slot := arr.slot } return slot.deriveArray().offset(pos).getBytes32Slot(); } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeAccess(uint256[] storage arr, uint256 pos) internal pure returns (StorageSlot.Uint256Slot storage) { bytes32 slot; assembly ("memory-safe") { slot := arr.slot } return slot.deriveArray().offset(pos).getUint256Slot(); } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeMemoryAccess(address[] memory arr, uint256 pos) internal pure returns (address res) { assembly ("memory-safe") { res := mload(add(add(arr, 0x20), mul(pos, 0x20))) } } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeMemoryAccess(bytes32[] memory arr, uint256 pos) internal pure returns (bytes32 res) { assembly ("memory-safe") { res := mload(add(add(arr, 0x20), mul(pos, 0x20))) } } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeMemoryAccess(uint256[] memory arr, uint256 pos) internal pure returns (uint256 res) { assembly ("memory-safe") { res := mload(add(add(arr, 0x20), mul(pos, 0x20))) } } /** * @dev Helper to set the length of an dynamic array. Directly writing to `.length` is forbidden. * * WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased. */ function unsafeSetLength(address[] storage array, uint256 len) internal { assembly ("memory-safe") { sstore(array.slot, len) } } /** * @dev Helper to set the length of an dynamic array. Directly writing to `.length` is forbidden. * * WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased. */ function unsafeSetLength(bytes32[] storage array, uint256 len) internal { assembly ("memory-safe") { sstore(array.slot, len) } } /** * @dev Helper to set the length of an dynamic array. Directly writing to `.length` is forbidden. * * WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased. */ function unsafeSetLength(uint256[] storage array, uint256 len) internal { assembly ("memory-safe") { sstore(array.slot, len) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Comparators.sol) pragma solidity ^0.8.20; /** * @dev Provides a set of functions to compare values. * * _Available since v5.1._ */ library Comparators { function lt(uint256 a, uint256 b) internal pure returns (bool) { return a < b; } function gt(uint256 a, uint256 b) internal pure returns (bool) { return a > b; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol) pragma solidity ^0.8.20; /** * @dev Collection of common custom errors used in multiple contracts * * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library. * It is recommended to avoid relying on the error API for critical functionality. * * _Available since v5.1._ */ library Errors { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error InsufficientBalance(uint256 balance, uint256 needed); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedCall(); /** * @dev The deployment failed. */ error FailedDeployment(); /** * @dev A necessary precompile is missing. */ error MissingPrecompile(address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/ERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC-165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[ERC]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface 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[ERC 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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/math/Math.sol) pragma solidity ^0.8.20; import {Panic} from "../Panic.sol"; import {SafeCast} from "./SafeCast.sol"; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an success flag (no overflow). */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an success flag (no overflow). */ function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an success flag (no overflow). */ function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a success flag (no division by zero). */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero). */ function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant. * * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone. * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute * one branch when needed, making this function more expensive. */ function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) { unchecked { // branchless ternary works because: // b ^ (a ^ b) == a // b ^ 0 == b return b ^ ((a ^ b) * SafeCast.toUint(condition)); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return ternary(a > b, a, b); } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return ternary(a < b, a, b); } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. Panic.panic(Panic.DIVISION_BY_ZERO); } // The following calculation ensures accurate ceiling division without overflow. // Since a is non-zero, (a - 1) / b will not overflow. // The largest possible result occurs when (a - 1) / b is type(uint256).max, // but the largest value we can obtain is type(uint256).max - 1, which happens // when a = type(uint256).max and b = 1. unchecked { return SafeCast.toUint(a > 0) * ((a - 1) / b + 1); } } /** * @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * * Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by * Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2²⁵⁶ and mod 2²⁵⁶ - 1, then use // the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2²⁵⁶ + prod0. uint256 prod0 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly ("memory-safe") { let mm := mulmod(x, y, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0. if (denominator <= prod1) { Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW)); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly ("memory-safe") { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. // Always >= 1. See https://cs.stackexchange.com/q/138556/92363. uint256 twos = denominator & (0 - denominator); assembly ("memory-safe") { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2²⁵⁶ / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such // that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv ≡ 1 mod 2⁴. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also // works in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2⁸ inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶ inverse *= 2 - denominator * inverse; // inverse mod 2³² inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴ inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸ inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶ // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2²⁵⁶. Since the preconditions guarantee that the outcome is // less than 2²⁵⁶, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @dev Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0); } /** * @dev Calculate the modular multiplicative inverse of a number in Z/nZ. * * If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0. * If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible. * * If the input value is not inversible, 0 is returned. * * NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the * inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}. */ function invMod(uint256 a, uint256 n) internal pure returns (uint256) { unchecked { if (n == 0) return 0; // The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version) // Used to compute integers x and y such that: ax + ny = gcd(a, n). // When the gcd is 1, then the inverse of a modulo n exists and it's x. // ax + ny = 1 // ax = 1 + (-y)n // ax ≡ 1 (mod n) # x is the inverse of a modulo n // If the remainder is 0 the gcd is n right away. uint256 remainder = a % n; uint256 gcd = n; // Therefore the initial coefficients are: // ax + ny = gcd(a, n) = n // 0a + 1n = n int256 x = 0; int256 y = 1; while (remainder != 0) { uint256 quotient = gcd / remainder; (gcd, remainder) = ( // The old remainder is the next gcd to try. remainder, // Compute the next remainder. // Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd // where gcd is at most n (capped to type(uint256).max) gcd - remainder * quotient ); (x, y) = ( // Increment the coefficient of a. y, // Decrement the coefficient of n. // Can overflow, but the result is casted to uint256 so that the // next value of y is "wrapped around" to a value between 0 and n - 1. x - y * int256(quotient) ); } if (gcd != 1) return 0; // No inverse exists. return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative. } } /** * @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`. * * From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is * prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that * `a**(p-2)` is the modular multiplicative inverse of a in Fp. * * NOTE: this function does NOT check that `p` is a prime greater than `2`. */ function invModPrime(uint256 a, uint256 p) internal view returns (uint256) { unchecked { return Math.modExp(a, p - 2, p); } } /** * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m) * * Requirements: * - modulus can't be zero * - underlying staticcall to precompile must succeed * * IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make * sure the chain you're using it on supports the precompiled contract for modular exponentiation * at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, * the underlying function will succeed given the lack of a revert, but the result may be incorrectly * interpreted as 0. */ function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) { (bool success, uint256 result) = tryModExp(b, e, m); if (!success) { Panic.panic(Panic.DIVISION_BY_ZERO); } return result; } /** * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m). * It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying * to operate modulo 0 or if the underlying precompile reverted. * * IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain * you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in * https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack * of a revert, but the result may be incorrectly interpreted as 0. */ function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) { if (m == 0) return (false, 0); assembly ("memory-safe") { let ptr := mload(0x40) // | Offset | Content | Content (Hex) | // |-----------|------------|--------------------------------------------------------------------| // | 0x00:0x1f | size of b | 0x0000000000000000000000000000000000000000000000000000000000000020 | // | 0x20:0x3f | size of e | 0x0000000000000000000000000000000000000000000000000000000000000020 | // | 0x40:0x5f | size of m | 0x0000000000000000000000000000000000000000000000000000000000000020 | // | 0x60:0x7f | value of b | 0x<.............................................................b> | // | 0x80:0x9f | value of e | 0x<.............................................................e> | // | 0xa0:0xbf | value of m | 0x<.............................................................m> | mstore(ptr, 0x20) mstore(add(ptr, 0x20), 0x20) mstore(add(ptr, 0x40), 0x20) mstore(add(ptr, 0x60), b) mstore(add(ptr, 0x80), e) mstore(add(ptr, 0xa0), m) // Given the result < m, it's guaranteed to fit in 32 bytes, // so we can use the memory scratch space located at offset 0. success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20) result := mload(0x00) } } /** * @dev Variant of {modExp} that supports inputs of arbitrary length. */ function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) { (bool success, bytes memory result) = tryModExp(b, e, m); if (!success) { Panic.panic(Panic.DIVISION_BY_ZERO); } return result; } /** * @dev Variant of {tryModExp} that supports inputs of arbitrary length. */ function tryModExp( bytes memory b, bytes memory e, bytes memory m ) internal view returns (bool success, bytes memory result) { if (_zeroBytes(m)) return (false, new bytes(0)); uint256 mLen = m.length; // Encode call args in result and move the free memory pointer result = abi.encodePacked(b.length, e.length, mLen, b, e, m); assembly ("memory-safe") { let dataPtr := add(result, 0x20) // Write result on top of args to avoid allocating extra memory. success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen) // Overwrite the length. // result.length > returndatasize() is guaranteed because returndatasize() == m.length mstore(result, mLen) // Set the memory pointer after the returned data. mstore(0x40, add(dataPtr, mLen)) } } /** * @dev Returns whether the provided byte array is zero. */ function _zeroBytes(bytes memory byteArray) private pure returns (bool) { for (uint256 i = 0; i < byteArray.length; ++i) { if (byteArray[i] != 0) { return false; } } return true; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * This method is based on Newton's method for computing square roots; the algorithm is restricted to only * using integer operations. */ function sqrt(uint256 a) internal pure returns (uint256) { unchecked { // Take care of easy edge cases when a == 0 or a == 1 if (a <= 1) { return a; } // In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a // sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between // the current value as `ε_n = | x_n - sqrt(a) |`. // // For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root // of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is // bigger than any uint256. // // By noticing that // `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)` // we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar // to the msb function. uint256 aa = a; uint256 xn = 1; if (aa >= (1 << 128)) { aa >>= 128; xn <<= 64; } if (aa >= (1 << 64)) { aa >>= 64; xn <<= 32; } if (aa >= (1 << 32)) { aa >>= 32; xn <<= 16; } if (aa >= (1 << 16)) { aa >>= 16; xn <<= 8; } if (aa >= (1 << 8)) { aa >>= 8; xn <<= 4; } if (aa >= (1 << 4)) { aa >>= 4; xn <<= 2; } if (aa >= (1 << 2)) { xn <<= 1; } // We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1). // // We can refine our estimation by noticing that the middle of that interval minimizes the error. // If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2). // This is going to be our x_0 (and ε_0) xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2) // From here, Newton's method give us: // x_{n+1} = (x_n + a / x_n) / 2 // // One should note that: // x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a // = ((x_n² + a) / (2 * x_n))² - a // = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a // = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²) // = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²) // = (x_n² - a)² / (2 * x_n)² // = ((x_n² - a) / (2 * x_n))² // ≥ 0 // Which proves that for all n ≥ 1, sqrt(a) ≤ x_n // // This gives us the proof of quadratic convergence of the sequence: // ε_{n+1} = | x_{n+1} - sqrt(a) | // = | (x_n + a / x_n) / 2 - sqrt(a) | // = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) | // = | (x_n - sqrt(a))² / (2 * x_n) | // = | ε_n² / (2 * x_n) | // = ε_n² / | (2 * x_n) | // // For the first iteration, we have a special case where x_0 is known: // ε_1 = ε_0² / | (2 * x_0) | // ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2))) // ≤ 2**(2*e-4) / (3 * 2**(e-1)) // ≤ 2**(e-3) / 3 // ≤ 2**(e-3-log2(3)) // ≤ 2**(e-4.5) // // For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n: // ε_{n+1} = ε_n² / | (2 * x_n) | // ≤ (2**(e-k))² / (2 * 2**(e-1)) // ≤ 2**(2*e-2*k) / 2**e // ≤ 2**(e-2*k) xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5) -- special case, see above xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9) -- general case with k = 4.5 xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18) -- general case with k = 9 xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36) -- general case with k = 18 xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72) -- general case with k = 36 xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144) -- general case with k = 72 // Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision // ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either // sqrt(a) or sqrt(a) + 1. return xn - SafeCast.toUint(xn > a / xn); } } /** * @dev Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; uint256 exp; unchecked { exp = 128 * SafeCast.toUint(value > (1 << 128) - 1); value >>= exp; result += exp; exp = 64 * SafeCast.toUint(value > (1 << 64) - 1); value >>= exp; result += exp; exp = 32 * SafeCast.toUint(value > (1 << 32) - 1); value >>= exp; result += exp; exp = 16 * SafeCast.toUint(value > (1 << 16) - 1); value >>= exp; result += exp; exp = 8 * SafeCast.toUint(value > (1 << 8) - 1); value >>= exp; result += exp; exp = 4 * SafeCast.toUint(value > (1 << 4) - 1); value >>= exp; result += exp; exp = 2 * SafeCast.toUint(value > (1 << 2) - 1); value >>= exp; result += exp; result += SafeCast.toUint(value > 1); } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; uint256 isGt; unchecked { isGt = SafeCast.toUint(value > (1 << 128) - 1); value >>= isGt * 128; result += isGt * 16; isGt = SafeCast.toUint(value > (1 << 64) - 1); value >>= isGt * 64; result += isGt * 8; isGt = SafeCast.toUint(value > (1 << 32) - 1); value >>= isGt * 32; result += isGt * 4; isGt = SafeCast.toUint(value > (1 << 16) - 1); value >>= isGt * 16; result += isGt * 2; result += SafeCast.toUint(value > (1 << 8) - 1); } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.20; /** * @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeCast { /** * @dev Value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value); /** * @dev An int value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedIntToUint(int256 value); /** * @dev Value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedIntDowncast(uint8 bits, int256 value); /** * @dev An uint value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedUintToInt(uint256 value); /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits */ function toUint248(uint256 value) internal pure returns (uint248) { if (value > type(uint248).max) { revert SafeCastOverflowedUintDowncast(248, value); } return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits */ function toUint240(uint256 value) internal pure returns (uint240) { if (value > type(uint240).max) { revert SafeCastOverflowedUintDowncast(240, value); } return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits */ function toUint232(uint256 value) internal pure returns (uint232) { if (value > type(uint232).max) { revert SafeCastOverflowedUintDowncast(232, value); } return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits */ function toUint224(uint256 value) internal pure returns (uint224) { if (value > type(uint224).max) { revert SafeCastOverflowedUintDowncast(224, value); } return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits */ function toUint216(uint256 value) internal pure returns (uint216) { if (value > type(uint216).max) { revert SafeCastOverflowedUintDowncast(216, value); } return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits */ function toUint208(uint256 value) internal pure returns (uint208) { if (value > type(uint208).max) { revert SafeCastOverflowedUintDowncast(208, value); } return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits */ function toUint200(uint256 value) internal pure returns (uint200) { if (value > type(uint200).max) { revert SafeCastOverflowedUintDowncast(200, value); } return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits */ function toUint192(uint256 value) internal pure returns (uint192) { if (value > type(uint192).max) { revert SafeCastOverflowedUintDowncast(192, value); } return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits */ function toUint184(uint256 value) internal pure returns (uint184) { if (value > type(uint184).max) { revert SafeCastOverflowedUintDowncast(184, value); } return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits */ function toUint176(uint256 value) internal pure returns (uint176) { if (value > type(uint176).max) { revert SafeCastOverflowedUintDowncast(176, value); } return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits */ function toUint168(uint256 value) internal pure returns (uint168) { if (value > type(uint168).max) { revert SafeCastOverflowedUintDowncast(168, value); } return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits */ function toUint160(uint256 value) internal pure returns (uint160) { if (value > type(uint160).max) { revert SafeCastOverflowedUintDowncast(160, value); } return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits */ function toUint152(uint256 value) internal pure returns (uint152) { if (value > type(uint152).max) { revert SafeCastOverflowedUintDowncast(152, value); } return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits */ function toUint144(uint256 value) internal pure returns (uint144) { if (value > type(uint144).max) { revert SafeCastOverflowedUintDowncast(144, value); } return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits */ function toUint136(uint256 value) internal pure returns (uint136) { if (value > type(uint136).max) { revert SafeCastOverflowedUintDowncast(136, value); } return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { if (value > type(uint128).max) { revert SafeCastOverflowedUintDowncast(128, value); } return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits */ function toUint120(uint256 value) internal pure returns (uint120) { if (value > type(uint120).max) { revert SafeCastOverflowedUintDowncast(120, value); } return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits */ function toUint112(uint256 value) internal pure returns (uint112) { if (value > type(uint112).max) { revert SafeCastOverflowedUintDowncast(112, value); } return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits */ function toUint104(uint256 value) internal pure returns (uint104) { if (value > type(uint104).max) { revert SafeCastOverflowedUintDowncast(104, value); } return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits */ function toUint96(uint256 value) internal pure returns (uint96) { if (value > type(uint96).max) { revert SafeCastOverflowedUintDowncast(96, value); } return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits */ function toUint88(uint256 value) internal pure returns (uint88) { if (value > type(uint88).max) { revert SafeCastOverflowedUintDowncast(88, value); } return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits */ function toUint80(uint256 value) internal pure returns (uint80) { if (value > type(uint80).max) { revert SafeCastOverflowedUintDowncast(80, value); } return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits */ function toUint72(uint256 value) internal pure returns (uint72) { if (value > type(uint72).max) { revert SafeCastOverflowedUintDowncast(72, value); } return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { if (value > type(uint64).max) { revert SafeCastOverflowedUintDowncast(64, value); } return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits */ function toUint56(uint256 value) internal pure returns (uint56) { if (value > type(uint56).max) { revert SafeCastOverflowedUintDowncast(56, value); } return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits */ function toUint48(uint256 value) internal pure returns (uint48) { if (value > type(uint48).max) { revert SafeCastOverflowedUintDowncast(48, value); } return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits */ function toUint40(uint256 value) internal pure returns (uint40) { if (value > type(uint40).max) { revert SafeCastOverflowedUintDowncast(40, value); } return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { if (value > type(uint32).max) { revert SafeCastOverflowedUintDowncast(32, value); } return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits */ function toUint24(uint256 value) internal pure returns (uint24) { if (value > type(uint24).max) { revert SafeCastOverflowedUintDowncast(24, value); } return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { if (value > type(uint16).max) { revert SafeCastOverflowedUintDowncast(16, value); } return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits */ function toUint8(uint256 value) internal pure returns (uint8) { if (value > type(uint8).max) { revert SafeCastOverflowedUintDowncast(8, value); } return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { if (value < 0) { revert SafeCastOverflowedIntToUint(value); } return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(248, value); } } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(240, value); } } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(232, value); } } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(224, value); } } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(216, value); } } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(208, value); } } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(200, value); } } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(192, value); } } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(184, value); } } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(176, value); } } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(168, value); } } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(160, value); } } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(152, value); } } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(144, value); } } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(136, value); } } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(128, value); } } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(120, value); } } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(112, value); } } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(104, value); } } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(96, value); } } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(88, value); } } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(80, value); } } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(72, value); } } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(64, value); } } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(56, value); } } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(48, value); } } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(40, value); } } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(32, value); } } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(24, value); } } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(16, value); } } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(8, value); } } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive if (value > uint256(type(int256).max)) { revert SafeCastOverflowedUintToInt(value); } return int256(value); } /** * @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump. */ function toUint(bool b) internal pure returns (uint256 u) { assembly ("memory-safe") { u := iszero(iszero(b)) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.20; import {SafeCast} from "./SafeCast.sol"; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant. * * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone. * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute * one branch when needed, making this function more expensive. */ function ternary(bool condition, int256 a, int256 b) internal pure returns (int256) { unchecked { // branchless ternary works because: // b ^ (a ^ b) == a // b ^ 0 == b return b ^ ((a ^ b) * int256(SafeCast.toUint(condition))); } } /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return ternary(a > b, a, b); } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return ternary(a < b, a, b); } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // Formula from the "Bit Twiddling Hacks" by Sean Eron Anderson. // Since `n` is a signed integer, the generated bytecode will use the SAR opcode to perform the right shift, // taking advantage of the most significant (or "sign" bit) in two's complement representation. // This opcode adds new most significant bits set to the value of the previous most significant bit. As a result, // the mask will either be `bytes32(0)` (if n is positive) or `~bytes32(0)` (if n is negative). int256 mask = n >> 255; // A `bytes32(0)` mask leaves the input unchanged, while a `~bytes32(0)` mask complements it. return uint256((n + mask) ^ mask); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol) pragma solidity ^0.8.20; /** * @dev Helper library for emitting standardized panic codes. * * ```solidity * contract Example { * using Panic for uint256; * * // Use any of the declared internal constants * function foo() { Panic.GENERIC.panic(); } * * // Alternatively * function foo() { Panic.panic(Panic.GENERIC); } * } * ``` * * Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil]. * * _Available since v5.1._ */ // slither-disable-next-line unused-state library Panic { /// @dev generic / unspecified error uint256 internal constant GENERIC = 0x00; /// @dev used by the assert() builtin uint256 internal constant ASSERT = 0x01; /// @dev arithmetic underflow or overflow uint256 internal constant UNDER_OVERFLOW = 0x11; /// @dev division or modulo by zero uint256 internal constant DIVISION_BY_ZERO = 0x12; /// @dev enum conversion error uint256 internal constant ENUM_CONVERSION_ERROR = 0x21; /// @dev invalid encoding in storage uint256 internal constant STORAGE_ENCODING_ERROR = 0x22; /// @dev empty array pop uint256 internal constant EMPTY_ARRAY_POP = 0x31; /// @dev array out of bounds access uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32; /// @dev resource error (too large allocation or too large array) uint256 internal constant RESOURCE_ERROR = 0x41; /// @dev calling invalid internal function uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51; /// @dev Reverts with a panic code. Recommended to use with /// the internal constants with predefined codes. function panic(uint256 code) internal pure { assembly ("memory-safe") { mstore(0x00, 0x4e487b71) mstore(0x20, code) revert(0x1c, 0x24) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/SlotDerivation.sol) // This file was procedurally generated from scripts/generate/templates/SlotDerivation.js. pragma solidity ^0.8.20; /** * @dev Library for computing storage (and transient storage) locations from namespaces and deriving slots * corresponding to standard patterns. The derivation method for array and mapping matches the storage layout used by * the solidity language / compiler. * * See https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays[Solidity docs for mappings and dynamic arrays.]. * * Example usage: * ```solidity * contract Example { * // Add the library methods * using StorageSlot for bytes32; * using SlotDerivation for bytes32; * * // Declare a namespace * string private constant _NAMESPACE = "<namespace>" // eg. OpenZeppelin.Slot * * function setValueInNamespace(uint256 key, address newValue) internal { * _NAMESPACE.erc7201Slot().deriveMapping(key).getAddressSlot().value = newValue; * } * * function getValueInNamespace(uint256 key) internal view returns (address) { * return _NAMESPACE.erc7201Slot().deriveMapping(key).getAddressSlot().value; * } * } * ``` * * TIP: Consider using this library along with {StorageSlot}. * * NOTE: This library provides a way to manipulate storage locations in a non-standard way. Tooling for checking * upgrade safety will ignore the slots accessed through this library. * * _Available since v5.1._ */ library SlotDerivation { /** * @dev Derive an ERC-7201 slot from a string (namespace). */ function erc7201Slot(string memory namespace) internal pure returns (bytes32 slot) { assembly ("memory-safe") { mstore(0x00, sub(keccak256(add(namespace, 0x20), mload(namespace)), 1)) slot := and(keccak256(0x00, 0x20), not(0xff)) } } /** * @dev Add an offset to a slot to get the n-th element of a structure or an array. */ function offset(bytes32 slot, uint256 pos) internal pure returns (bytes32 result) { unchecked { return bytes32(uint256(slot) + pos); } } /** * @dev Derive the location of the first element in an array from the slot where the length is stored. */ function deriveArray(bytes32 slot) internal pure returns (bytes32 result) { assembly ("memory-safe") { mstore(0x00, slot) result := keccak256(0x00, 0x20) } } /** * @dev Derive the location of a mapping element from the key. */ function deriveMapping(bytes32 slot, address key) internal pure returns (bytes32 result) { assembly ("memory-safe") { mstore(0x00, and(key, shr(96, not(0)))) mstore(0x20, slot) result := keccak256(0x00, 0x40) } } /** * @dev Derive the location of a mapping element from the key. */ function deriveMapping(bytes32 slot, bool key) internal pure returns (bytes32 result) { assembly ("memory-safe") { mstore(0x00, iszero(iszero(key))) mstore(0x20, slot) result := keccak256(0x00, 0x40) } } /** * @dev Derive the location of a mapping element from the key. */ function deriveMapping(bytes32 slot, bytes32 key) internal pure returns (bytes32 result) { assembly ("memory-safe") { mstore(0x00, key) mstore(0x20, slot) result := keccak256(0x00, 0x40) } } /** * @dev Derive the location of a mapping element from the key. */ function deriveMapping(bytes32 slot, uint256 key) internal pure returns (bytes32 result) { assembly ("memory-safe") { mstore(0x00, key) mstore(0x20, slot) result := keccak256(0x00, 0x40) } } /** * @dev Derive the location of a mapping element from the key. */ function deriveMapping(bytes32 slot, int256 key) internal pure returns (bytes32 result) { assembly ("memory-safe") { mstore(0x00, key) mstore(0x20, slot) result := keccak256(0x00, 0x40) } } /** * @dev Derive the location of a mapping element from the key. */ function deriveMapping(bytes32 slot, string memory key) internal pure returns (bytes32 result) { assembly ("memory-safe") { let length := mload(key) let begin := add(key, 0x20) let end := add(begin, length) let cache := mload(end) mstore(end, slot) result := keccak256(begin, add(length, 0x20)) mstore(end, cache) } } /** * @dev Derive the location of a mapping element from the key. */ function deriveMapping(bytes32 slot, bytes memory key) internal pure returns (bytes32 result) { assembly ("memory-safe") { let length := mload(key) let begin := add(key, 0x20) let end := add(begin, length) let cache := mload(end) mstore(end, slot) result := keccak256(begin, add(length, 0x20)) mstore(end, cache) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol) // This file was procedurally generated from scripts/generate/templates/StorageSlot.js. pragma solidity ^0.8.20; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC-1967 implementation slot: * ```solidity * contract ERC1967 { * // Define the slot. Alternatively, use the SlotDerivation library to derive the slot. * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(newImplementation.code.length > 0); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * TIP: Consider using this library along with {SlotDerivation}. */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } struct Int256Slot { int256 value; } struct StringSlot { string value; } struct BytesSlot { bytes value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `Int256Slot` with member `value` located at `slot`. */ function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `StringSlot` with member `value` located at `slot`. */ function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns an `StringSlot` representation of the string storage pointer `store`. */ function getStringSlot(string storage store) internal pure returns (StringSlot storage r) { assembly ("memory-safe") { r.slot := store.slot } } /** * @dev Returns a `BytesSlot` with member `value` located at `slot`. */ function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`. */ function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) { assembly ("memory-safe") { r.slot := store.slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Strings.sol) pragma solidity ^0.8.20; import {Math} from "./math/Math.sol"; import {SignedMath} from "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant HEX_DIGITS = "0123456789abcdef"; uint8 private constant ADDRESS_LENGTH = 20; /** * @dev The `value` string doesn't fit in the specified `length`. */ error StringsInsufficientHexLength(uint256 value, uint256 length); /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; assembly ("memory-safe") { ptr := add(buffer, add(32, length)) } while (true) { ptr--; assembly ("memory-safe") { mstore8(ptr, byte(mod(value, 10), HEX_DIGITS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toStringSigned(int256 value) internal pure returns (string memory) { return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { uint256 localValue = value; bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = HEX_DIGITS[localValue & 0xf]; localValue >>= 4; } if (localValue != 0) { revert StringsInsufficientHexLength(value, length); } return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal * representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH); } /** * @dev Converts an `address` with fixed length of 20 bytes to its checksummed ASCII `string` hexadecimal * representation, according to EIP-55. */ function toChecksumHexString(address addr) internal pure returns (string memory) { bytes memory buffer = bytes(toHexString(addr)); // hash the hex part of buffer (skip length + 2 bytes, length 40) uint256 hashValue; assembly ("memory-safe") { hashValue := shr(96, keccak256(add(buffer, 0x22), 40)) } for (uint256 i = 41; i > 1; --i) { // possible values for buffer[i] are 48 (0) to 57 (9) and 97 (a) to 102 (f) if (hashValue & 0xf > 7 && uint8(buffer[i]) > 96) { // case shift by xoring with 0x20 buffer[i] ^= 0x20; } hashValue >>= 4; } return string(buffer); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/TransientSlot.sol) // This file was procedurally generated from scripts/generate/templates/TransientSlot.js. pragma solidity ^0.8.24; /** * @dev Library for reading and writing value-types to specific transient storage slots. * * Transient slots are often used to store temporary values that are removed after the current transaction. * This library helps with reading and writing to such slots without the need for inline assembly. * * * Example reading and writing values using transient storage: * ```solidity * contract Lock { * using TransientSlot for *; * * // Define the slot. Alternatively, use the SlotDerivation library to derive the slot. * bytes32 internal constant _LOCK_SLOT = 0xf4678858b2b588224636b8522b729e7722d32fc491da849ed75b3fdf3c84f542; * * modifier locked() { * require(!_LOCK_SLOT.asBoolean().tload()); * * _LOCK_SLOT.asBoolean().tstore(true); * _; * _LOCK_SLOT.asBoolean().tstore(false); * } * } * ``` * * TIP: Consider using this library along with {SlotDerivation}. */ library TransientSlot { /** * @dev UDVT that represent a slot holding a address. */ type AddressSlot is bytes32; /** * @dev Cast an arbitrary slot to a AddressSlot. */ function asAddress(bytes32 slot) internal pure returns (AddressSlot) { return AddressSlot.wrap(slot); } /** * @dev UDVT that represent a slot holding a bool. */ type BooleanSlot is bytes32; /** * @dev Cast an arbitrary slot to a BooleanSlot. */ function asBoolean(bytes32 slot) internal pure returns (BooleanSlot) { return BooleanSlot.wrap(slot); } /** * @dev UDVT that represent a slot holding a bytes32. */ type Bytes32Slot is bytes32; /** * @dev Cast an arbitrary slot to a Bytes32Slot. */ function asBytes32(bytes32 slot) internal pure returns (Bytes32Slot) { return Bytes32Slot.wrap(slot); } /** * @dev UDVT that represent a slot holding a uint256. */ type Uint256Slot is bytes32; /** * @dev Cast an arbitrary slot to a Uint256Slot. */ function asUint256(bytes32 slot) internal pure returns (Uint256Slot) { return Uint256Slot.wrap(slot); } /** * @dev UDVT that represent a slot holding a int256. */ type Int256Slot is bytes32; /** * @dev Cast an arbitrary slot to a Int256Slot. */ function asInt256(bytes32 slot) internal pure returns (Int256Slot) { return Int256Slot.wrap(slot); } /** * @dev Load the value held at location `slot` in transient storage. */ function tload(AddressSlot slot) internal view returns (address value) { assembly ("memory-safe") { value := tload(slot) } } /** * @dev Store `value` at location `slot` in transient storage. */ function tstore(AddressSlot slot, address value) internal { assembly ("memory-safe") { tstore(slot, value) } } /** * @dev Load the value held at location `slot` in transient storage. */ function tload(BooleanSlot slot) internal view returns (bool value) { assembly ("memory-safe") { value := tload(slot) } } /** * @dev Store `value` at location `slot` in transient storage. */ function tstore(BooleanSlot slot, bool value) internal { assembly ("memory-safe") { tstore(slot, value) } } /** * @dev Load the value held at location `slot` in transient storage. */ function tload(Bytes32Slot slot) internal view returns (bytes32 value) { assembly ("memory-safe") { value := tload(slot) } } /** * @dev Store `value` at location `slot` in transient storage. */ function tstore(Bytes32Slot slot, bytes32 value) internal { assembly ("memory-safe") { tstore(slot, value) } } /** * @dev Load the value held at location `slot` in transient storage. */ function tload(Uint256Slot slot) internal view returns (uint256 value) { assembly ("memory-safe") { value := tload(slot) } } /** * @dev Store `value` at location `slot` in transient storage. */ function tstore(Uint256Slot slot, uint256 value) internal { assembly ("memory-safe") { tstore(slot, value) } } /** * @dev Load the value held at location `slot` in transient storage. */ function tload(Int256Slot slot) internal view returns (int256 value) { assembly ("memory-safe") { value := tload(slot) } } /** * @dev Store `value` at location `slot` in transient storage. */ function tstore(Int256Slot slot, int256 value) internal { assembly ("memory-safe") { tstore(slot, value) } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.28; import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; contract CollectionRoyalties is UUPSUpgradeable, OwnableUpgradeable { event CollectionRoyaltyInfo(address nft, address recipient, uint256 fee); event CollectionRoyaltyRemoved(address nft); event CollectionAddedToBlacklist(address nft); event BaseCollectionRoyaltyInfo(uint16 fee); event MaxCollectionRoyaltyInfo(uint256 maxCollectionRoyalty); error RoyaltyFeeTooHigh(); error OnlyCallableByRecipient(); error OnlyCallableByNFTContractOwner(); error CollectionIsBlacklisted(); struct CollectionRoyalty { address recipient; uint16 fee; } // Contract to recipient royalties mapping(address collection => CollectionRoyalty) private _collectionRoyalties; uint16 private _baseCollectionRoyaltyFeePercentage; uint256 private _maxCollectionRoyalty; mapping(address => bool) private _collectionRoyaltyBlacklist; /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } function initialize() public initializer { __Ownable_init(_msgSender()); __UUPSUpgradeable_init(); // set first _setMaxCollectionRoyalty(1000); // 10% // set second _setBaseCollectionRoyalty(10); // 0.1% } function collectionRoyalties(address nft) external view returns (CollectionRoyalty memory) { return _collectionRoyalties[nft]; } function collectionRoyaltyBlacklist(address nft) external view returns (bool) { return _collectionRoyaltyBlacklist[nft]; } function setMaxCollectionRoyalty(uint256 maxCollectionRoyalty) external onlyOwner { _setMaxCollectionRoyalty(maxCollectionRoyalty); } function _setMaxCollectionRoyalty(uint256 maxCollectionRoyalty) internal { require(maxCollectionRoyalty <= 1000, RoyaltyFeeTooHigh()); _maxCollectionRoyalty = maxCollectionRoyalty; emit MaxCollectionRoyaltyInfo(maxCollectionRoyalty); } function setBaseCollectionRoyalty(uint16 feePercentage) external onlyOwner { _setBaseCollectionRoyalty(feePercentage); } function _setBaseCollectionRoyalty(uint16 feePercentage) internal { require(feePercentage < _maxCollectionRoyalty, RoyaltyFeeTooHigh()); _baseCollectionRoyaltyFeePercentage = feePercentage; emit BaseCollectionRoyaltyInfo(feePercentage); } // function updateRoyalty // TODO If I updated contracts again, otherwise delete and re-add function updateRoyalty(address nft, address recipient, uint16 fee) external { require(_collectionRoyalties[nft].recipient == _msgSender(), OnlyCallableByRecipient()); require(fee <= _maxCollectionRoyalty, RoyaltyFeeTooHigh()); _collectionRoyalties[nft] = CollectionRoyalty({recipient: recipient, fee: fee}); emit CollectionRoyaltyInfo(nft, recipient, fee); } function getCollectionRoyaltyInfo(address addr) external view returns (CollectionRoyalty memory) { return _collectionRoyalties[addr]; } function addCollectionRoyaltyFromOwner(address nft, address recipient) external { // Add they the owner? require(OwnableUpgradeable(nft).owner() == _msgSender(), OnlyCallableByNFTContractOwner()); require(!_collectionRoyaltyBlacklist[nft], CollectionIsBlacklisted()); _collectionRoyalties[nft] = CollectionRoyalty({recipient: recipient, fee: _baseCollectionRoyaltyFeePercentage}); emit CollectionRoyaltyInfo(nft, recipient, _baseCollectionRoyaltyFeePercentage); } function removeCollectionRoyaltyFromOwner(address nft) external onlyOwner { require(OwnableUpgradeable(nft).owner() == _msgSender(), OnlyCallableByNFTContractOwner()); delete _collectionRoyalties[nft]; emit CollectionRoyaltyRemoved(nft); } function addToCollectionRoyaltyBlacklist(address nft) external onlyOwner { _collectionRoyaltyBlacklist[nft] = true; emit CollectionAddedToBlacklist(nft); } function addCollectionRoyalty(address nft, address recipient, uint16 fee) external onlyOwner { require(fee <= _maxCollectionRoyalty, RoyaltyFeeTooHigh()); _collectionRoyalties[nft] = CollectionRoyalty({recipient: recipient, fee: fee}); emit CollectionRoyaltyInfo(nft, recipient, fee); } function removeCollectionRoyalty(address _nft) external onlyOwner { delete _collectionRoyalties[_nft]; // Only owner can add them emit CollectionRoyaltyRemoved(_nft); } function _authorizeUpgrade(address newImplementation) internal override onlyOwner {} }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.28; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; contract FeePercentage is Ownable { event AddFNFT(address nft); event RemoveFNFT(address nft); event DevFeePercentageInfo(uint16 feePercentage); event DevFeeFNFTPercentageInfo(uint16 feePercentage); error FeePercentageTooHigh(); // Basis points 10000, how much the dev address gets from each sale uint256 private _devFeePercentage; // Basis points 10000, how much the dev address gets from each sale for financial NFTs uint256 private _devFeeFNFTPercentage; mapping(address => bool) private _usesFNFT; constructor(uint16 devFeePercentage, uint16 devFeeFNFTPercentage) Ownable(_msgSender()) { _setDevFeePercentage(devFeePercentage); _setDevFeeFNFTPercentage(devFeeFNFTPercentage); } // Basis points 10000, 185 is 1.85% function setDevFeePercentage(uint16 feePercentage) external onlyOwner { _setDevFeePercentage(feePercentage); } function _setDevFeePercentage(uint16 feePercentage) internal { require(feePercentage <= 1000, FeePercentageTooHigh()); _devFeePercentage = feePercentage; emit DevFeePercentageInfo(feePercentage); } // Basis points 10000, 185 is 1.85% function setDevFeeFNFTPercentage(uint16 feePercentage) external onlyOwner { _setDevFeeFNFTPercentage(feePercentage); } function _setDevFeeFNFTPercentage(uint16 feePercentage) internal { require(feePercentage <= 1000, FeePercentageTooHigh()); _devFeeFNFTPercentage = feePercentage; emit DevFeeFNFTPercentageInfo(feePercentage); } function addFNFT(address nft) external onlyOwner { _usesFNFT[nft] = true; emit AddFNFT(nft); } function removeFNFT(address nft) external onlyOwner { _usesFNFT[nft] = false; emit RemoveFNFT(nft); } function getFee(address nft) external view returns (uint256) { return _usesFNFT[nft] ? _devFeeFNFTPercentage : _devFeePercentage; } function getDevFee(address nft) external view returns (uint256) { return _usesFNFT[nft] ? _devFeeFNFTPercentage : _devFeePercentage; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.28; struct NFT { address nft; uint256 tokenId; } enum PaymentFailureMode { ALLOW_FAILURE, NOT_ALLOWED }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.28; import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; interface IERC2981 is IERC165 { /// @notice Called with the sale price to determine how much royalty // is owed and to whom. /// @param tokenId - the NFT asset queried for royalty information /// @param salePrice - the sale price of the NFT asset specified by _tokenId /// @return receiver - address of who should be sent the royalty payment /// @return royaltyAmount - the royalty payment amount for _salePrice function royaltyInfo( uint256 tokenId, uint256 salePrice ) external view returns (address receiver, uint256 royaltyAmount); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.28; interface INFTVault { function owner() external view returns (address); function trySafeNFTTransfer(address nft, uint256 tokenId, uint256 amount, address to) external returns (bool); function safeNFTTransfer(address nft, uint256 tokenId, uint256 amount, address to) external; function excessNFTAmount(address nft, uint256 tokenId) external view returns (uint256); function withdrawExcessNFTsBatch(address[] calldata nfts, uint256[] calldata tokenIds) external; function withdrawExcessNFTs(address nft, uint256 tokenId) external; function excessTokenAmount(address token) external view returns (uint256); function withdrawExcessTokens(address token) external; function withdrawExcessTokensBatch(address[] calldata tokens) external; function initialize(address owner, address marketplace, address nftRegistry) external; function nftsInCustody(address nft, uint256 tokenId) external returns (uint256 quantity); function lock(address nft, uint256 tokenId, uint256 amount) external; function lock(address[] calldata nfts, uint256[] calldata tokenIds, uint256[] calldata amounts) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.28; interface INFTVaultFactory { function vaultAddresses(address user) external view returns (address); function createdHere(address vault) external view returns (bool); function createNFTVaultForUser(address user) external returns (address); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.28; struct Listing { address nft; uint256 tokenId; uint96 price; uint40 duration; uint40 amount; bool isUsingVault; bool isAuction; bool isAntisnipe; bool isFlashAuction; bool isNSFW; string searchKeywords; address donationAddress; uint16 donationPercent; } interface IPaintSwapMarketplaceListAndComplete { function addListing(Listing calldata listing) external payable; function addListingBatch(Listing[] calldata listings) external payable; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.28; interface IPaintSwapMarketplaceP2PSwaps { struct Items { address nft; uint256[] tokenIds; uint256[] amounts; } function setUpSwap( Items[] calldata _fferingNFTs, uint128 offeringNative, address to, Items[] calldata expectingNFTs, uint128 expectingNative, uint40 /* duration */, string calldata searchKeywords ) external payable; function acceptSwap( Items[] calldata offeringNFTs, uint128 offeringNative, address to, Items[] calldata expectingNFTs, uint128 expectingNative, bool useAvailableWFTM ) external payable; function rejectSwap(address to) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.28; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IWrappedToken is IERC20 { function deposit() external payable; function withdraw(uint256 amount) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.28; import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; contract MarketplaceWhitelist is UUPSUpgradeable, OwnableUpgradeable { event AddWhitelist(address[] nfts); event RemoveWhitelist(address[] nfts); event AddCommunity(address[] nfts); event RemoveCommunity(address[] nfts); error NotAdmin(); mapping(address => bool) private _whitelistNFTs; mapping(address => bool) private _communityNFTs; mapping(address => bool) private _admins; /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } function initialize() external initializer { __Ownable_init(_msgSender()); __UUPSUpgradeable_init(); } modifier isAdmin() { address sender = _msgSender(); require(_admins[sender] || owner() == sender, NotAdmin()); _; } function addWhitelist(address[] calldata nfts) external isAdmin { for (uint256 i; i < nfts.length; ++i) { _whitelistNFTs[nfts[i]] = true; } emit AddWhitelist(nfts); } function removeWhitelist(address[] calldata nfts) external isAdmin { for (uint256 i; i < nfts.length; ++i) { _whitelistNFTs[nfts[i]] = false; } emit RemoveWhitelist(nfts); } function addCommunity(address[] calldata nfts) external isAdmin { for (uint256 i; i < nfts.length; ++i) { _communityNFTs[nfts[i]] = true; } emit AddCommunity(nfts); } function removeCommunity(address[] calldata nfts) external isAdmin { for (uint256 i; i < nfts.length; ++i) { _communityNFTs[nfts[i]] = false; } emit RemoveCommunity(nfts); } function isWhitelisted(address nft) external view returns (bool) { return _whitelistNFTs[nft]; } function isCommunity(address nft) external view returns (bool) { return _communityNFTs[nft]; } function addAdmin(address admin) external onlyOwner { _admins[admin] = true; } function removeAdmin(address admin) external onlyOwner { _admins[admin] = false; } function _authorizeUpgrade(address newImplementation) internal override onlyOwner {} }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.28; import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IWrappedToken} from "./interfaces/IWrappedToken.sol"; import {IERC165, IERC2981} from "./interfaces/IERC2981.sol"; import {PaymentFailureMode} from "./globals.sol"; library PaintSwapLibrary { error InvalidNFT(); error InvalidERCType(); error InvalidAmountForERC721(); error InvalidPrice(); error SellingNotEnabled(); error InsufficientBalance(); error NotOwner(); error NotApproved(address operator); error InsufficientValue(); error CoinTransferFailed(address to); // Pre-condition is that the NFTS are either ERC721 or ERC1155 function safeNFTTransferFrom(address nft, uint256 tokenId, uint256 amount, address from, address to) external { if (isERC1155(nft)) { IERC1155(nft).safeTransferFrom(from, to, tokenId, amount, ""); } else { IERC721(nft).safeTransferFrom(from, to, tokenId); } } function checkBalance(address nft, uint256 tokenId, uint256 amount, address owner) external view { // Check that owner has these nfts and approved us if (isERC1155(nft)) { require(IERC1155(nft).balanceOf(owner, tokenId) >= amount, InsufficientBalance()); } else { require(IERC721(nft).ownerOf(tokenId) == owner, NotOwner()); } } function checkBalanceAndApproval( address nft, uint256 tokenId, uint256 amount, address owner, address operator ) external view { // Check that owner has these nfts and approved us if (isERC1155(nft)) { require(IERC1155(nft).balanceOf(owner, tokenId) >= amount, InsufficientBalance()); require(IERC1155(nft).isApprovedForAll(owner, operator), NotApproved(operator)); } else { require(IERC721(nft).ownerOf(tokenId) == owner, NotOwner()); require( IERC721(nft).isApprovedForAll(owner, operator) || IERC721(nft).getApproved(tokenId) == operator, NotApproved(operator) ); } } function safeTransferFromUs( address token, address receiver, uint256 amount, address wNative, PaymentFailureMode _paymentFailureMode ) external returns (bool success) { if (tokenIsNativeFtm(token)) { // Do an FTM transfer uint256 balance = address(this).balance; uint256 amountToSend = balance >= amount ? amount : balance; (success, ) = receiver.call{value: amountToSend}(""); if (_paymentFailureMode == PaymentFailureMode.ALLOW_FAILURE && !success) { // Send them wrapped native instead IWrappedToken(wNative).deposit{value: amountToSend}(); IERC20(wNative).transfer(receiver, amountToSend); success = true; } } else { uint256 balance = IERC20(token).balanceOf(address(this)); uint256 amountToSend = balance >= amount ? amount : balance; IERC20(token).transfer(receiver, amountToSend); success = true; } } function checkAddListing( address nft, uint96 price, uint256 amount, bool isSellingEnabled, uint96 maxNative ) external view { require(nft != address(0), InvalidNFT()); uint256 ercType = getNFTERCType(nft); require(ercType == 1155 || ercType == 721, InvalidERCType()); require((ercType == 1155 && amount != 0) || amount == 1, InvalidAmountForERC721()); require(price != 0 && price < maxNative, InvalidPrice()); require(isSellingEnabled, SellingNotEnabled()); } function isFinished(uint256 endTime) public view returns (bool) { return endTime <= block.timestamp; } function nextMinimumBid(uint96 price, uint96 highestBid, uint96 percentIncrease) public pure returns (uint96) { if (highestBid == 0) { return price; } else { return _nextMinimumBid(highestBid, percentIncrease); } } function _nextMinimumBid(uint96 highestBid, uint96 percentIncrease) private pure returns (uint96) { uint96 newMin = (highestBid + (highestBid * percentIncrease) / 10000); if (newMin == highestBid) { return highestBid + 1; // Increase by 1 } return newMin; } // The zero address is used to show that the token is native fantom function tokenIsNativeFtm(address token) public pure returns (bool) { return token == address(0); } // An NFT contract could be malicious and prevent a sale finishing. Try send NFT to our backup address, // if possible, otherwise it just gets lost forever. function tryRoyaltyInfo( address nft, uint256 tokenId, uint256 salePrice ) external view returns (address receiver, uint256 royaltyAmount) { try IERC2981(nft).royaltyInfo(tokenId, salePrice) returns (address _receiver, uint256 _royaltyAmount) { return (_receiver, _royaltyAmount); } catch {} return (address(0), 0); } function isValidNFTContract(address nft) public view returns (bool) { return isERC1155(nft) || isERC721(nft); } function getNFTERCType(address nft) public view returns (uint256) { if (isERC1155(nft)) { return 1155; } else if (isERC721(nft)) { return 721; } else { return 0; } } function isERC721(address nft) public view returns (bool) { try IERC165(nft).supportsInterface(type(IERC721).interfaceId) returns (bool supportsERC721) { return supportsERC721; } catch {} return false; } function isERC1155(address nft) public view returns (bool) { try IERC165(nft).supportsInterface(type(IERC1155).interfaceId) returns (bool supportsERC1155) { return supportsERC1155; } catch {} return false; } function wrapNative(address wNative) external { IWrappedToken(wNative).deposit{value: msg.value}(); IERC20(wNative).transfer(msg.sender, msg.value); } function addListingTransferFee(uint96 listingFee, address devFeeAddress) external { if (listingFee != 0) { // If paying with ftm require(msg.value >= listingFee, InsufficientValue()); (bool sent, ) = devFeeAddress.call{value: listingFee}(""); require(sent, CoinTransferFailed(devFeeAddress)); // Refund any excess FTM if (msg.value > listingFee) { (bool sent1, ) = msg.sender.call{value: msg.value - listingFee}(""); require(sent1, CoinTransferFailed(msg.sender)); } } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.28; import {IERC721, ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import {IERC1155, ERC1155} from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import {CollectionRoyalties} from "../CollectionRoyalties.sol"; import {MarketplaceWhitelist} from "../MarketplaceWhitelist.sol"; import {FeePercentage} from "../FeePercentage.sol"; import {IERC165, IERC2981} from "../interfaces/IERC2981.sol"; import {INFTVault} from "../interfaces/INFTVault.sol"; import {INFTVaultFactory} from "../interfaces/INFTVaultFactory.sol"; import {IPaintSwapMarketplaceListAndComplete, Listing} from "../interfaces/IPaintSwapMarketplaceListAndComplete.sol"; import {PaintSwapLibrary} from "../PaintSwapLibrary.sol"; import {NFT, PaymentFailureMode} from "../globals.sol"; contract PaintSwapMarketplaceBase { event SaleFinished(uint256 marketplaceId); event UpdatePrice(uint256 marketplaceId, uint96 price); event UpdateEndTime(uint256 marketplaceId, uint40 endTime); event Sold(uint256 marketplaceId, uint96 price, address buyer, uint40 amount, uint256 offerId); // These 2 should match. NewTempListing is used for accepting an offer, but don't want to show "new listing" events. event NewListing(uint256 marketplaceId, Listing listing, address seller); event NewTempListing(uint256 marketplaceId, Listing listing, address seller); event NewListingBatch(uint256 firstMarketplaceId, Listing[] listings, address seller); event CancelledListing(uint256 marketplaceId); event NewBid(uint256 marketplaceId, address bidder, uint96 bid, uint96 nextMinimum); event RemoveExpiredListing(uint256 marketplaceId); event UpdateQuantity(uint256 marketplaceId, uint40 newAmountRemaining); // Placing it on a marketplace sale is useful for bundles & FNFTs that require custody. Otherwise put 0 event NewOffer( uint256 offerId, uint256 marketplaceId, address nft, uint256 tokenId, address from, uint40 quantity, uint96 price, uint256 expires, string searchKeywords ); event NewCollectionOffer( uint256 offerId, address nft, address from, uint40 quantity, uint96 price, uint256 expires, string searchKeywords ); event NewFilteredCollectionOffer( uint256 offerId, address nft, uint256[] tokenIds, address from, uint40 quantity, uint96 price, uint96[] prices, uint40 expires, string[] searchKeywords ); event OfferAccepted(uint256 offerId, address nft, uint256 tokenId, uint40 quantity, uint256 marketplaceId); event OfferCompleted(uint256 offerId); event OfferRemoved(uint256 offerId); event OfferExpired(uint256 offerId); event UpdateOffer(uint256 offerId, address nft, uint256 tokenId, uint40 quantity, uint96 newPrice, uint40 expires); event TokenFailedTransfer(address token, address to, uint256 amount); error ListingDoesNotExist(); error OfferDoesNotExist(uint256 offerId); error InvalidOfferType(OfferType offerType); error NFTMismatch(); error TokenIdMismatch(); error TokenTransferNotSuccessful(address token, address to, uint256 amount); error MinCannotBeZero(); error MaxCannotBeLessThanMin(); error CoinTransferFailed(address recipient); error ListingHasFinished(); error NotTheSeller(); error CannotEditAuctionPrice(); error InvalidPrice(); error MustHaveMarketplaceIds(); error LengthMismatch(); error InsufficientPayment(); error CannotEditAuctionQuantity(); error QuantityUnchanged(); error CannotCancelAuction(); error CannotBuyFromSelf(); error CannotBuyAuction(); error NotEnoughRemaining(); error InvalidQuantity(); error OfferNotForThisListing(); error OfferMustMatchListing(); error OfferMustMatchExpected(); error CannotAcceptOwnOffer(); error CannotOfferOnOwnListing(); error OfferHasExpired(uint256 expires); error ListingExpired(uint256 expires); error ListingNotAnAction(); error SearchKeywordsTooLong(); error OfferIsOnSale(); error NoOffers(); error NoneExpected(); error TotalNotExpected(uint256 total); error InvalidDuration(); error TooManySearchKeywords(); error PriceInsufficient(); error AllowanceInsufficient(); error BalanceInsufficient(); error TooManyOffers(); error QuantityTooHigh(); error DurationsLengthMismatch(); error PricesLengthMismatch(); error TokenIdsLengthMismatch(); error QuantitiesLengthMismatch(); error SearchKeywordsLengthMismatch(); error NftAddressZero(); error TokenIdsNotSorted(); error SaleHasFinished(); error OfferNotFromSender(); error TokenIdNotFound(); error OfferIdsRequired(); error NftsRequired(); error NoListingsToAdd(); error InvalidAuctionDuration(); error AuctionsMustUseVault(); error InvalidAuctionType(); error InvalidDonationPercent(); error CannotDonateToSelf(); error VaultCreationFailed(); error SaleNotFinished(); error SaleHasRemainingAmount(uint256 amount); error ListingDoesNotHaveVault(); error SaleIsAuction(); error SaleIsNotAuction(); struct FullDetails { address nft; uint256 tokenId; uint40 endTime; uint96 price; // reserve price if auction address seller; // For auctions bool isAuction; uint40 auctionStartTime; uint96 highestBid; address highestBidder; bool antisnipe; bool flashAuction; // Donation info address donationAddress; // 0 if there is no donation uint16 donationPercent; // How many are they selling and how many remain uint40 amountRemaining; // The token payment is expected for address vault; // 0 if no vault is involved } enum OfferType { // Listing, SingleNFT, // Could be single sale too Bundle, Collection, FilteredCollection, AltNFT } /* nft nfts tokenIds saleid Offers 1 0 1 0/1 Bundles 0 2 2 1 Collections 1 0 0 0 Filtered 1 0 2 0 Alt 0 2 2 0 */ // TODO: Disable Alt & Bundles for now? // These are wNative offers. // Filtered collections can have an optimization if they are all in the same collection. struct Offer { address nft; // Only used for collection & filtered collection offers uint40 expires; uint48 quantityRemaining; OfferType offerType; address[] nfts; // Used for bundle offers & filtered collection offers uint256[] tokenIds; // empty if collection offer, more than 1 & nft is set for filtered collection. Otherwise if equal to 1 is normal offer, else bundle offer uint96[] prices; address from; uint96 price; uint256 marketplaceId; // 0 if not on sale } // Used for offer batches for now struct OfferInfo { uint256 offerId; NFT expectedNFT; uint256 marketplaceId; // Can be 0 if not on sale uint40 quantity; string searchKeywords; // Can be empty if not on sale } // Bulk transfer struct BulkTransferInfo { address nft; uint256[] tokenIds; uint256[] amounts; address to; } // End of bulk transfer // P2P swaps event SetUpSwap( address from, Item[] offeringItems, uint256 offeringFTM, address to, Item[] expectingItems, uint256 expectingFTM, uint40 expires, string searchKeywords ); event RejectSwap(address from, address to); event CompleteSwap(address from, address to); // contract values event ListingFeeInfo(uint96 listingFee); event MaxRoyaltyInfo(uint256 maxRoyalty); event P2PValues(uint256 swapMaxNFTs, uint256 swapCostNative); event CallGasLimitInfo(uint256 callGasLimit); struct Item { address nft; uint256 tokenId; uint256 amount; } struct Info { uint128 nativeProposing; uint40 expires; bool finalizedSwap; bool hasPaid; Item[] items; } struct ListingDetails { // Slot 1 address nft; uint96 price; // reserve price if auction // Slot 2 uint256 tokenId; // Slot 3 address seller; uint40 amountRemaining; // Max of 1 trillion uint40 endTime; bytes1 flags; // 1 bit for usingVault, 1 bit for isAuction, 1 bit for hasDonation // Slot 4 (Auction Details) address highestBidder; uint96 highestBid; // Slot 5 address vault; // Can also be used for non-auction listings uint40 startTime; // Only set for auctions currently bool antisnipe; bool flashAuction; // Slot 6 (Donation details) address donationAddress; uint16 donationPercent; } struct RoyaltyInfo { uint256 maxRoyalty; address collectionRoyalties; } bytes1 constant VAULT_MASK = hex"01"; bytes1 constant AUCTION_MASK = hex"02"; bytes1 constant DONATION_MASK = hex"04"; // All the NFTs currently for sale on the marketplace (includes auctions) mapping(uint256 listingId => ListingDetails listingDetails) internal _listings; // The address to send the fees address internal _devFeeAddress; // The address to send sales fees to address internal _salesFeeAddress; // Information about collection royalties RoyaltyInfo internal _royaltyInfo; // Which NFT addresses can be sold on the marketplace without a fee MarketplaceWhitelist internal _marketplaceWhitelist; // Whether selling is allowed on the marketplace bool internal _isSellingEnabled; // The minimum length of time an NFT can be put on the marketplace for sale (not auctions) uint256 internal _minDuration; // The maximum length of time an NFT can be put on the marketplace for sale (not auctions) uint256 internal _maxDuration; // The minimum length of time an NFT can be put on the marketplace for auction uint256 internal _minAuctionDuration; // The minimum length of time an NFT can be put on the marketplace for auction for flash sales uint256 internal _minFlashAuctionDuration; // The maximum length of time an NFT can be put on the marketplace for auction uint256 internal _maxAuctionDuration; // How much the next bid or offer must be, prevents +1ing someone else uint96 internal _minIncreasedBidPercent; // 10000 basis points, 945 means 9.45% // The current id of the marketplace uint256 internal _currentMarketplaceId; // Grace period for cancelling uint40 internal _auctionGracePeriodForCancelling; uint40 internal _flashAuctionGracePeriodForCancelling; // If antisnipe is enabled and an auction ends within this period increase the auction by this amount. uint40 internal _auctionEndTimeIncreaseCutOff; uint40 internal _flashAuctionEndTimeIncreaseCutOff; uint256 internal _callGasLimit; address internal immutable _wNative; uint96 internal immutable _maxNative; uint96 internal _listingFee; // Not needed most of the time, only read when listing a non-whitelisted contract, optimization not too important // Has a lot of the marketplace functionality in it. Helps with contract code size. address internal _implBuyEditListing; address internal _implMakeAndEditOffers; address internal _implBids; address internal _implAcceptOffers; address internal _implListAndComplete; address internal _implBatchTransferNFT; address internal _implP2PSwaps; address internal _reservedimpl; address internal _reservedimpl2; // This holds all offers whether on sale or on the nft itself mapping(uint256 offerId => Offer offer) internal _offers; uint256 internal _offerId; uint256 internal _maxActiveOfferCount; mapping(address user => uint256 offerCount) internal _offerCounts; // number of offers made from users uint256 internal _minOfferDuration; uint256 internal _maxOfferDuration; mapping(address user => mapping(address nft => mapping(uint256 tokenId => uint256 offerId))) internal _userOffersMade; // mapping(address user => mapping(uint256 marketplaceId => uint256 offerId)) public userBundleOffersMade; mapping(address user => mapping(address nft => uint256 offerId)) internal _userCollectionOffersMade; mapping(address user => mapping(address nft => uint256 offerId)) internal _userFilteredCollectionOffersMade; mapping(address user => uint256 offerId) internal _userAltOffersMade; FeePercentage internal _feePercentage; address internal _vaultFactory; // Can only have 1 listing per NFT mapping(address user => mapping(address nft => mapping(uint256 tokenId => uint256 marketPlaceId))) internal _singleNFTListings; // user => (nft address => tokenid) => marketplaceId; uint256 internal constant MAX_SEARCH_KEYWORDS = 1024; uint256 internal constant _swapMaxNFTs = 8; uint128 internal _swapCostNative; mapping(address from => mapping(address to => Info info)) internal _swapProposals; constructor(address wNative, uint96 maxNative) { _wNative = wNative; _maxNative = maxNative; } // Have a max of 7.5% in external royalties. If they support erc2981 & collection royalty, we only use the collection royalty function _transferPaymentFromSale( ListingDetails storage listingDetails, uint96 price, uint40 quantity, uint256 marketplaceId, bool isAuctionListing ) internal { _transferPaymentFromSale( listingDetails.nft, listingDetails.tokenId, listingDetails.seller, price, quantity, marketplaceId, hasDonation(listingDetails.flags), isAuctionListing ); } function _transferPaymentFromSale( address nft, uint256 tokenId, address seller, uint96 price, uint40 quantity, uint256 marketplaceId, bool listingHasDonation, bool isAuctionListing ) internal { // Check if there is a royalty which must be paid to the artist or collection holder uint256 totalRoyalty = 0; // Take appropriate action if there is an issue sending the funds, depending on the scenario. // If this is an auction, then we can't really leave this in an unusable state because we // have taken custody of the funds so we send wrapped tokens as a fallback. PaymentFailureMode failureMode = isAuctionListing ? PaymentFailureMode.ALLOW_FAILURE : PaymentFailureMode.NOT_ALLOWED; RoyaltyInfo memory royaltyInfo = _royaltyInfo; // Break the price down uint256 maxRoyaltyAmount = ((price * royaltyInfo.maxRoyalty) / 10000); uint256 devFee = 0; CollectionRoyalties.CollectionRoyalty memory collectionRoyalty = CollectionRoyalties( royaltyInfo.collectionRoyalties ).getCollectionRoyaltyInfo(nft); if (collectionRoyalty.fee != 0 && collectionRoyalty.recipient != address(0)) { uint96 collectionRoyaltyAmount = ((price * collectionRoyalty.fee) / 10000); _safeTransferFromUs(collectionRoyalty.recipient, collectionRoyaltyAmount * quantity, failureMode); totalRoyalty += collectionRoyaltyAmount; } else { // See if they support erc2981 address receiver; uint256 royaltyAmount; if (IERC165(nft).supportsInterface(type(IERC2981).interfaceId)) { (receiver, royaltyAmount) = PaintSwapLibrary.tryRoyaltyInfo(nft, tokenId, price); if (royaltyAmount != 0 && receiver != address(0)) { // Maximum in place in case the NFT contract can manipulate this. royaltyAmount = royaltyAmount > maxRoyaltyAmount ? maxRoyaltyAmount : royaltyAmount; _safeTransferFromUs(receiver, royaltyAmount * quantity, failureMode); totalRoyalty += royaltyAmount; } } } devFee += _feePercentage.getDevFee(nft); uint256 devAmount = (devFee * price * quantity) / 10000; // Transfer to any donation receipient uint256 donationAmount = 0; if (listingHasDonation) { ListingDetails storage listingDetails = _listings[marketplaceId]; if (listingDetails.donationAddress != address(0)) { donationAmount = (listingDetails.donationPercent * price * quantity) / 10000; uint256 remaining = ((price - totalRoyalty) * quantity) - devAmount; if (remaining < donationAmount) { donationAmount = remaining; } _safeTransferFromUs(listingDetails.donationAddress, donationAmount, failureMode); } } // Transfer to the dev sales address if (devAmount != 0) { _safeTransferFromUs(_salesFeeAddress, devAmount, failureMode); } // Send remaining to the seller _safeTransferFromUs(seller, ((price - totalRoyalty) * quantity) - devAmount - donationAmount, failureMode); } // Safe transfer from our contract. Checks the balance before transferring in case there isn't enough function _safeTransferFromUs(address to, uint256 amount, PaymentFailureMode failureMode) internal { bool success = PaintSwapLibrary.safeTransferFromUs(address(0), to, amount, _wNative, failureMode); if (!success) { // Transfers can not be allowed to fail (e.g just buying normally) require(failureMode == PaymentFailureMode.ALLOW_FAILURE, TokenTransferNotSuccessful(_wNative, to, amount)); } } function _listingFinished(uint256 marketplaceId) internal { ListingDetails storage listingDetails = _listings[marketplaceId]; require(_listingExists(listingDetails), ListingDoesNotExist()); emit SaleFinished(marketplaceId); } function _removeListing(ListingDetails storage listingDetails, uint256 marketplaceId) internal { delete _singleNFTListings[listingDetails.seller][listingDetails.nft][listingDetails.tokenId]; delete _listings[marketplaceId]; } function _trySafeNFTTransferFromVault( address vault, address nft, uint256 tokenId, uint256 amount, address to ) internal returns (bool) { // Return back to them return INFTVault(vault).trySafeNFTTransfer(nft, tokenId, amount, to); } function _removeOffer(Offer storage offer, uint256 offerId) internal { require(offer.from != address(0), OfferDoesNotExist(offerId)); // Check this offer actually exists if (offer.offerType == OfferType.Collection) { delete _userCollectionOffersMade[offer.from][offer.nft]; } else if (offer.offerType == OfferType.FilteredCollection) { delete _userFilteredCollectionOffersMade[offer.from][offer.nft]; } else if (offer.offerType == OfferType.AltNFT) { delete _userAltOffersMade[offer.from]; } else if (offer.offerType == OfferType.SingleNFT) { delete _userOffersMade[offer.from][offer.nft][offer.tokenIds[0]]; } else { revert InvalidOfferType(offer.offerType); } delete _offers[offerId]; } function _listingExists(uint256 marketplaceId) internal view returns (bool) { ListingDetails storage listingDetails = _listings[marketplaceId]; return _listingExists(listingDetails); } function _listingExists(ListingDetails storage listingDetails) internal view returns (bool) { return listingDetails.nft != address(0); } function _reduceOfferCount(Offer storage offer) internal { if (offer.offerType == OfferType.FilteredCollection) { _offerCounts[offer.from] -= offer.tokenIds.length; } else { --_offerCounts[offer.from]; } } function _requireMatchingExpectations(ListingDetails storage listings, NFT calldata nft) internal view { require(listings.nft == nft.nft, NFTMismatch()); require(listings.tokenId == nft.tokenId, TokenIdMismatch()); } function isUsingVault(bytes1 flags) internal pure returns (bool) { return flags & VAULT_MASK == VAULT_MASK; } function isAuction(bytes1 flags) internal pure returns (bool) { return flags & AUCTION_MASK == AUCTION_MASK; } function hasDonation(bytes1 flags) internal pure returns (bool) { return flags & DONATION_MASK == DONATION_MASK; } function listingDetailsToFullDetails(uint256 marketplaceId) internal view returns (FullDetails memory) { ListingDetails storage listingDetails = _listings[marketplaceId]; require(listingDetails.nft != address(0), ListingDoesNotExist()); return FullDetails({ nft: listingDetails.nft, tokenId: listingDetails.tokenId, endTime: listingDetails.endTime, price: listingDetails.price, seller: listingDetails.seller, isAuction: isAuction(listingDetails.flags), auctionStartTime: listingDetails.startTime, highestBid: listingDetails.highestBid, highestBidder: listingDetails.highestBidder, donationAddress: listingDetails.donationAddress, donationPercent: listingDetails.donationPercent, antisnipe: listingDetails.antisnipe, flashAuction: listingDetails.flashAuction, amountRemaining: listingDetails.amountRemaining, vault: listingDetails.vault }); } }
{ "optimizer": { "enabled": true, "runs": 99999, "details": { "yul": true } }, "evmVersion": "cancun", "viaIR": true, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": { "contracts/PaintSwapLibrary.sol": { "PaintSwapLibrary": "0xe0cb467a1a46d29682332e0ba8099aee26dee620" } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[],"name":"AllowanceInsufficient","type":"error"},{"inputs":[],"name":"AuctionsMustUseVault","type":"error"},{"inputs":[],"name":"BalanceInsufficient","type":"error"},{"inputs":[],"name":"CannotAcceptOwnOffer","type":"error"},{"inputs":[],"name":"CannotBuyAuction","type":"error"},{"inputs":[],"name":"CannotBuyFromSelf","type":"error"},{"inputs":[],"name":"CannotCancelAuction","type":"error"},{"inputs":[],"name":"CannotDonateToSelf","type":"error"},{"inputs":[],"name":"CannotEditAuctionPrice","type":"error"},{"inputs":[],"name":"CannotEditAuctionQuantity","type":"error"},{"inputs":[],"name":"CannotOfferOnOwnListing","type":"error"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"}],"name":"CoinTransferFailed","type":"error"},{"inputs":[],"name":"DurationsLengthMismatch","type":"error"},{"inputs":[{"internalType":"address","name":"implementation","type":"address"}],"name":"ERC1967InvalidImplementation","type":"error"},{"inputs":[],"name":"ERC1967NonPayable","type":"error"},{"inputs":[],"name":"FailedCall","type":"error"},{"inputs":[],"name":"InsufficientPayment","type":"error"},{"inputs":[],"name":"InvalidAuctionDuration","type":"error"},{"inputs":[],"name":"InvalidAuctionType","type":"error"},{"inputs":[],"name":"InvalidDonationPercent","type":"error"},{"inputs":[],"name":"InvalidDuration","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[{"internalType":"enum PaintSwapMarketplaceBase.OfferType","name":"offerType","type":"uint8"}],"name":"InvalidOfferType","type":"error"},{"inputs":[],"name":"InvalidPrice","type":"error"},{"inputs":[],"name":"InvalidQuantity","type":"error"},{"inputs":[],"name":"LengthMismatch","type":"error"},{"inputs":[],"name":"ListingDoesNotExist","type":"error"},{"inputs":[],"name":"ListingDoesNotHaveVault","type":"error"},{"inputs":[{"internalType":"uint256","name":"expires","type":"uint256"}],"name":"ListingExpired","type":"error"},{"inputs":[],"name":"ListingHasFinished","type":"error"},{"inputs":[],"name":"ListingNotAnAction","type":"error"},{"inputs":[],"name":"MaxCannotBeLessThanMin","type":"error"},{"inputs":[],"name":"MinCannotBeZero","type":"error"},{"inputs":[],"name":"MustHaveMarketplaceIds","type":"error"},{"inputs":[],"name":"NFTMismatch","type":"error"},{"inputs":[],"name":"NftAddressZero","type":"error"},{"inputs":[],"name":"NftsRequired","type":"error"},{"inputs":[],"name":"NoListingsToAdd","type":"error"},{"inputs":[],"name":"NoOffers","type":"error"},{"inputs":[],"name":"NoneExpected","type":"error"},{"inputs":[],"name":"NotEnoughRemaining","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"NotTheSeller","type":"error"},{"inputs":[{"internalType":"uint256","name":"offerId","type":"uint256"}],"name":"OfferDoesNotExist","type":"error"},{"inputs":[{"internalType":"uint256","name":"expires","type":"uint256"}],"name":"OfferHasExpired","type":"error"},{"inputs":[],"name":"OfferIdsRequired","type":"error"},{"inputs":[],"name":"OfferIsOnSale","type":"error"},{"inputs":[],"name":"OfferMustMatchExpected","type":"error"},{"inputs":[],"name":"OfferMustMatchListing","type":"error"},{"inputs":[],"name":"OfferNotForThisListing","type":"error"},{"inputs":[],"name":"OfferNotFromSender","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"PriceInsufficient","type":"error"},{"inputs":[],"name":"PricesLengthMismatch","type":"error"},{"inputs":[],"name":"QuantitiesLengthMismatch","type":"error"},{"inputs":[],"name":"QuantityTooHigh","type":"error"},{"inputs":[],"name":"QuantityUnchanged","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[],"name":"SaleHasFinished","type":"error"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"SaleHasRemainingAmount","type":"error"},{"inputs":[],"name":"SaleIsAuction","type":"error"},{"inputs":[],"name":"SaleIsNotAuction","type":"error"},{"inputs":[],"name":"SaleNotFinished","type":"error"},{"inputs":[],"name":"SearchKeywordsLengthMismatch","type":"error"},{"inputs":[],"name":"SearchKeywordsTooLong","type":"error"},{"inputs":[],"name":"TokenIdMismatch","type":"error"},{"inputs":[],"name":"TokenIdNotFound","type":"error"},{"inputs":[],"name":"TokenIdsLengthMismatch","type":"error"},{"inputs":[],"name":"TokenIdsNotSorted","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TokenTransferNotSuccessful","type":"error"},{"inputs":[],"name":"TooManyOffers","type":"error"},{"inputs":[],"name":"TooManySearchKeywords","type":"error"},{"inputs":[{"internalType":"uint256","name":"total","type":"uint256"}],"name":"TotalNotExpected","type":"error"},{"inputs":[],"name":"UUPSUnauthorizedCallContext","type":"error"},{"inputs":[{"internalType":"bytes32","name":"slot","type":"bytes32"}],"name":"UUPSUnsupportedProxiableUUID","type":"error"},{"inputs":[],"name":"VaultCreationFailed","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"callGasLimit","type":"uint256"}],"name":"CallGasLimitInfo","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"marketplaceId","type":"uint256"}],"name":"CancelledListing","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"}],"name":"CompleteSwap","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint96","name":"listingFee","type":"uint96"}],"name":"ListingFeeInfo","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"maxRoyalty","type":"uint256"}],"name":"MaxRoyaltyInfo","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"marketplaceId","type":"uint256"},{"indexed":false,"internalType":"address","name":"bidder","type":"address"},{"indexed":false,"internalType":"uint96","name":"bid","type":"uint96"},{"indexed":false,"internalType":"uint96","name":"nextMinimum","type":"uint96"}],"name":"NewBid","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"offerId","type":"uint256"},{"indexed":false,"internalType":"address","name":"nft","type":"address"},{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint40","name":"quantity","type":"uint40"},{"indexed":false,"internalType":"uint96","name":"price","type":"uint96"},{"indexed":false,"internalType":"uint256","name":"expires","type":"uint256"},{"indexed":false,"internalType":"string","name":"searchKeywords","type":"string"}],"name":"NewCollectionOffer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"offerId","type":"uint256"},{"indexed":false,"internalType":"address","name":"nft","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint40","name":"quantity","type":"uint40"},{"indexed":false,"internalType":"uint96","name":"price","type":"uint96"},{"indexed":false,"internalType":"uint96[]","name":"prices","type":"uint96[]"},{"indexed":false,"internalType":"uint40","name":"expires","type":"uint40"},{"indexed":false,"internalType":"string[]","name":"searchKeywords","type":"string[]"}],"name":"NewFilteredCollectionOffer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"marketplaceId","type":"uint256"},{"components":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint96","name":"price","type":"uint96"},{"internalType":"uint40","name":"duration","type":"uint40"},{"internalType":"uint40","name":"amount","type":"uint40"},{"internalType":"bool","name":"isUsingVault","type":"bool"},{"internalType":"bool","name":"isAuction","type":"bool"},{"internalType":"bool","name":"isAntisnipe","type":"bool"},{"internalType":"bool","name":"isFlashAuction","type":"bool"},{"internalType":"bool","name":"isNSFW","type":"bool"},{"internalType":"string","name":"searchKeywords","type":"string"},{"internalType":"address","name":"donationAddress","type":"address"},{"internalType":"uint16","name":"donationPercent","type":"uint16"}],"indexed":false,"internalType":"struct Listing","name":"listing","type":"tuple"},{"indexed":false,"internalType":"address","name":"seller","type":"address"}],"name":"NewListing","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"firstMarketplaceId","type":"uint256"},{"components":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint96","name":"price","type":"uint96"},{"internalType":"uint40","name":"duration","type":"uint40"},{"internalType":"uint40","name":"amount","type":"uint40"},{"internalType":"bool","name":"isUsingVault","type":"bool"},{"internalType":"bool","name":"isAuction","type":"bool"},{"internalType":"bool","name":"isAntisnipe","type":"bool"},{"internalType":"bool","name":"isFlashAuction","type":"bool"},{"internalType":"bool","name":"isNSFW","type":"bool"},{"internalType":"string","name":"searchKeywords","type":"string"},{"internalType":"address","name":"donationAddress","type":"address"},{"internalType":"uint16","name":"donationPercent","type":"uint16"}],"indexed":false,"internalType":"struct Listing[]","name":"listings","type":"tuple[]"},{"indexed":false,"internalType":"address","name":"seller","type":"address"}],"name":"NewListingBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"offerId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"marketplaceId","type":"uint256"},{"indexed":false,"internalType":"address","name":"nft","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint40","name":"quantity","type":"uint40"},{"indexed":false,"internalType":"uint96","name":"price","type":"uint96"},{"indexed":false,"internalType":"uint256","name":"expires","type":"uint256"},{"indexed":false,"internalType":"string","name":"searchKeywords","type":"string"}],"name":"NewOffer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"marketplaceId","type":"uint256"},{"components":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint96","name":"price","type":"uint96"},{"internalType":"uint40","name":"duration","type":"uint40"},{"internalType":"uint40","name":"amount","type":"uint40"},{"internalType":"bool","name":"isUsingVault","type":"bool"},{"internalType":"bool","name":"isAuction","type":"bool"},{"internalType":"bool","name":"isAntisnipe","type":"bool"},{"internalType":"bool","name":"isFlashAuction","type":"bool"},{"internalType":"bool","name":"isNSFW","type":"bool"},{"internalType":"string","name":"searchKeywords","type":"string"},{"internalType":"address","name":"donationAddress","type":"address"},{"internalType":"uint16","name":"donationPercent","type":"uint16"}],"indexed":false,"internalType":"struct Listing","name":"listing","type":"tuple"},{"indexed":false,"internalType":"address","name":"seller","type":"address"}],"name":"NewTempListing","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"offerId","type":"uint256"},{"indexed":false,"internalType":"address","name":"nft","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint40","name":"quantity","type":"uint40"},{"indexed":false,"internalType":"uint256","name":"marketplaceId","type":"uint256"}],"name":"OfferAccepted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"offerId","type":"uint256"}],"name":"OfferCompleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"offerId","type":"uint256"}],"name":"OfferExpired","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"offerId","type":"uint256"}],"name":"OfferRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"swapMaxNFTs","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"swapCostNative","type":"uint256"}],"name":"P2PValues","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"}],"name":"RejectSwap","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"marketplaceId","type":"uint256"}],"name":"RemoveExpiredListing","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"marketplaceId","type":"uint256"}],"name":"SaleFinished","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"components":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"indexed":false,"internalType":"struct PaintSwapMarketplaceBase.Item[]","name":"offeringItems","type":"tuple[]"},{"indexed":false,"internalType":"uint256","name":"offeringFTM","type":"uint256"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"components":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"indexed":false,"internalType":"struct PaintSwapMarketplaceBase.Item[]","name":"expectingItems","type":"tuple[]"},{"indexed":false,"internalType":"uint256","name":"expectingFTM","type":"uint256"},{"indexed":false,"internalType":"uint40","name":"expires","type":"uint40"},{"indexed":false,"internalType":"string","name":"searchKeywords","type":"string"}],"name":"SetUpSwap","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"marketplaceId","type":"uint256"},{"indexed":false,"internalType":"uint96","name":"price","type":"uint96"},{"indexed":false,"internalType":"address","name":"buyer","type":"address"},{"indexed":false,"internalType":"uint40","name":"amount","type":"uint40"},{"indexed":false,"internalType":"uint256","name":"offerId","type":"uint256"}],"name":"Sold","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TokenFailedTransfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"marketplaceId","type":"uint256"},{"indexed":false,"internalType":"uint40","name":"endTime","type":"uint40"}],"name":"UpdateEndTime","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"offerId","type":"uint256"},{"indexed":false,"internalType":"address","name":"nft","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint40","name":"quantity","type":"uint40"},{"indexed":false,"internalType":"uint96","name":"newPrice","type":"uint96"},{"indexed":false,"internalType":"uint40","name":"expires","type":"uint40"}],"name":"UpdateOffer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"marketplaceId","type":"uint256"},{"indexed":false,"internalType":"uint96","name":"price","type":"uint96"}],"name":"UpdatePrice","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"marketplaceId","type":"uint256"},{"indexed":false,"internalType":"uint40","name":"newAmountRemaining","type":"uint40"}],"name":"UpdateQuantity","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"UPGRADE_INTERFACE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"acceptOfferId","type":"uint256"},{"components":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"internalType":"struct NFT","name":"expectedNFT","type":"tuple"},{"internalType":"uint40","name":"quantity","type":"uint40"},{"internalType":"string","name":"searchKeywords","type":"string"},{"internalType":"uint96","name":"expectedTotal","type":"uint96"}],"name":"acceptOffer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"offerId","type":"uint256"},{"components":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"internalType":"struct NFT","name":"expectedNFT","type":"tuple"},{"internalType":"uint256","name":"marketplaceId","type":"uint256"},{"internalType":"uint40","name":"quantity","type":"uint40"},{"internalType":"string","name":"searchKeywords","type":"string"}],"internalType":"struct PaintSwapMarketplaceBase.OfferInfo[]","name":"offerInfos","type":"tuple[]"},{"internalType":"uint96","name":"expectedTotal","type":"uint96"}],"name":"acceptOfferBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"acceptOfferId","type":"uint256"},{"internalType":"uint256","name":"marketplaceId","type":"uint256"},{"components":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"internalType":"struct NFT","name":"expectedNFT","type":"tuple"},{"internalType":"uint40","name":"quantity","type":"uint40"},{"internalType":"uint96","name":"expectedTotal","type":"uint96"}],"name":"acceptOnSaleOffer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"internalType":"struct IPaintSwapMarketplaceP2PSwaps.Items[]","name":"offeringNFTs","type":"tuple[]"},{"internalType":"uint128","name":"offeringNative","type":"uint128"},{"internalType":"address","name":"to","type":"address"},{"components":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"internalType":"struct IPaintSwapMarketplaceP2PSwaps.Items[]","name":"expectingNFTs","type":"tuple[]"},{"internalType":"uint128","name":"expectingNative","type":"uint128"},{"internalType":"bool","name":"useAvailableWFTM","type":"bool"}],"name":"acceptSwap","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint96","name":"price","type":"uint96"},{"internalType":"uint40","name":"duration","type":"uint40"},{"internalType":"uint40","name":"amount","type":"uint40"},{"internalType":"bool","name":"isUsingVault","type":"bool"},{"internalType":"bool","name":"isAuction","type":"bool"},{"internalType":"bool","name":"isAntisnipe","type":"bool"},{"internalType":"bool","name":"isFlashAuction","type":"bool"},{"internalType":"bool","name":"isNSFW","type":"bool"},{"internalType":"string","name":"searchKeywords","type":"string"},{"internalType":"address","name":"donationAddress","type":"address"},{"internalType":"uint16","name":"donationPercent","type":"uint16"}],"internalType":"struct Listing","name":"listing","type":"tuple"}],"name":"addListing","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint96","name":"price","type":"uint96"},{"internalType":"uint40","name":"duration","type":"uint40"},{"internalType":"uint40","name":"amount","type":"uint40"},{"internalType":"bool","name":"isUsingVault","type":"bool"},{"internalType":"bool","name":"isAuction","type":"bool"},{"internalType":"bool","name":"isAntisnipe","type":"bool"},{"internalType":"bool","name":"isFlashAuction","type":"bool"},{"internalType":"bool","name":"isNSFW","type":"bool"},{"internalType":"string","name":"searchKeywords","type":"string"},{"internalType":"address","name":"donationAddress","type":"address"},{"internalType":"uint16","name":"donationPercent","type":"uint16"}],"internalType":"struct Listing[]","name":"listings","type":"tuple[]"}],"name":"addListingBatch","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint96","name":"price","type":"uint96"},{"internalType":"uint40","name":"duration","type":"uint40"},{"internalType":"uint40","name":"amount","type":"uint40"},{"internalType":"bool","name":"isVaultListing","type":"bool"},{"internalType":"bool","name":"isAuctionListing","type":"bool"},{"internalType":"bool","name":"isAntisnipe","type":"bool"},{"internalType":"bool","name":"isFlashAuction","type":"bool"},{"internalType":"bool","name":"isNSFW","type":"bool"},{"internalType":"string","name":"searchKeywords","type":"string"},{"internalType":"address","name":"donationAddress","type":"address"},{"internalType":"uint16","name":"donationPercent","type":"uint16"}],"name":"addListingRaw","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"auctionEndTimeIncreaseCutOff","outputs":[{"internalType":"uint40","name":"","type":"uint40"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"auctionGracePeriodForCancelling","outputs":[{"internalType":"uint40","name":"","type":"uint40"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketplaceId","type":"uint256"},{"components":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"internalType":"struct NFT","name":"expectedNFT","type":"tuple"},{"internalType":"uint40","name":"quantity","type":"uint40"}],"name":"buy","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"marketplaceIds","type":"uint256[]"},{"components":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"internalType":"struct NFT[]","name":"expectedNFTs","type":"tuple[]"},{"internalType":"uint40[]","name":"quantities","type":"uint40[]"}],"name":"buyBatch","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketplaceId","type":"uint256"}],"name":"cancelListing","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"marketplaceIds","type":"uint256[]"}],"name":"cancelListingBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"cancelOfferId","type":"uint256"}],"name":"cancelOffer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"cancelOfferIds","type":"uint256[]"}],"name":"cancelOfferBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketplaceId","type":"uint256"}],"name":"completeMarketplaceEntry","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint40","name":"newQuantity","type":"uint40"},{"internalType":"uint96","name":"newOfferPrice","type":"uint96"},{"internalType":"uint40","name":"newOfferDuration","type":"uint40"}],"name":"editOffer","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"offerIds","type":"uint256[]"},{"internalType":"address[]","name":"nfts","type":"address[]"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint40[]","name":"newQuantities","type":"uint40[]"},{"internalType":"uint96[]","name":"newOfferPrices","type":"uint96[]"},{"internalType":"uint40[]","name":"newOfferDurations","type":"uint40[]"}],"name":"editOfferBatch","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketplaceId","type":"uint256"},{"internalType":"uint96","name":"price","type":"uint96"}],"name":"editPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketplaceId","type":"uint256"},{"internalType":"uint96","name":"newPrice","type":"uint96"},{"internalType":"uint40","name":"newQuantity","type":"uint40"}],"name":"editPriceAndQuantity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"marketplaceIds","type":"uint256[]"},{"internalType":"uint96[]","name":"prices","type":"uint96[]"}],"name":"editPriceBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketplaceId","type":"uint256"},{"internalType":"uint40","name":"newQuantity","type":"uint40"}],"name":"editQuantity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"expireOfferIds","type":"uint256[]"}],"name":"expireOffers","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"flashAuctionEndTimeIncreaseCutOff","outputs":[{"internalType":"uint40","name":"","type":"uint40"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"flashAuctionGracePeriodForCancelling","outputs":[{"internalType":"uint40","name":"","type":"uint40"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getOffer","outputs":[{"components":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint40","name":"expires","type":"uint40"},{"internalType":"uint48","name":"quantityRemaining","type":"uint48"},{"internalType":"enum PaintSwapMarketplaceBase.OfferType","name":"offerType","type":"uint8"},{"internalType":"address[]","name":"nfts","type":"address[]"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint96[]","name":"prices","type":"uint96[]"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint96","name":"price","type":"uint96"},{"internalType":"uint256","name":"marketplaceId","type":"uint256"}],"internalType":"struct PaintSwapMarketplaceBase.Offer","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketplaceId","type":"uint256"}],"name":"getSaleDetails","outputs":[{"components":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint40","name":"endTime","type":"uint40"},{"internalType":"uint96","name":"price","type":"uint96"},{"internalType":"address","name":"seller","type":"address"},{"internalType":"bool","name":"isAuction","type":"bool"},{"internalType":"uint40","name":"auctionStartTime","type":"uint40"},{"internalType":"uint96","name":"highestBid","type":"uint96"},{"internalType":"address","name":"highestBidder","type":"address"},{"internalType":"bool","name":"antisnipe","type":"bool"},{"internalType":"bool","name":"flashAuction","type":"bool"},{"internalType":"address","name":"donationAddress","type":"address"},{"internalType":"uint16","name":"donationPercent","type":"uint16"},{"internalType":"uint40","name":"amountRemaining","type":"uint40"},{"internalType":"address","name":"vault","type":"address"}],"internalType":"struct PaintSwapMarketplaceBase.FullDetails","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getSingleNFTListings","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSwapCostNative","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"nft","type":"address"}],"name":"getUserCollectionOffersMade","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"nft","type":"address"}],"name":"getUserFilteredCollectionOffersMade","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getUserOffersMade","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"nfts","type":"address[]"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"address","name":"user","type":"address"}],"name":"hasExistingActiveOffers","outputs":[{"internalType":"bool[]","name":"","type":"bool[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"marketplaceWhitelist","type":"address"},{"internalType":"address","name":"collectionRoyalties","type":"address"},{"internalType":"address","name":"vaultFactory","type":"address"},{"internalType":"address","name":"implBuyEditListing","type":"address"},{"internalType":"address","name":"implMakeAndEditOffers","type":"address"},{"internalType":"address","name":"implBids","type":"address"},{"internalType":"address","name":"implAcceptOffers","type":"address"},{"internalType":"address","name":"implListAndComplete","type":"address"},{"internalType":"address","name":"implBatchTransferNFT","type":"address"},{"internalType":"address","name":"implP2PSwaps","type":"address"},{"internalType":"address","name":"feePercentage","type":"address"},{"internalType":"uint96","name":"listingFeeInit","type":"uint96"},{"internalType":"address","name":"devFeeAddress","type":"address"},{"internalType":"address","name":"salesFeeAddress","type":"address"},{"internalType":"uint128","name":"swapCostNative","type":"uint128"},{"internalType":"uint256","name":"startId","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"listingFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketplaceId","type":"uint256"},{"components":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"internalType":"struct NFT","name":"expectedNFT","type":"tuple"},{"internalType":"uint40","name":"quantity","type":"uint40"},{"internalType":"uint96","name":"bid","type":"uint96"}],"name":"makeBid","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint40","name":"quantity","type":"uint40"},{"internalType":"uint96","name":"price","type":"uint96"},{"internalType":"uint40","name":"duration","type":"uint40"},{"internalType":"string","name":"searchKeywords","type":"string"}],"name":"makeCollectionOffer","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint40","name":"quantity","type":"uint40"},{"internalType":"uint96[]","name":"prices","type":"uint96[]"},{"internalType":"uint40","name":"duration","type":"uint40"},{"internalType":"string[]","name":"searchKeywords","type":"string[]"}],"name":"makeFilteredCollectionOffer","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address[]","name":"nfts","type":"address[]"},{"internalType":"uint256[][]","name":"tokenIds","type":"uint256[][]"},{"internalType":"uint40[]","name":"quantities","type":"uint40[]"},{"internalType":"uint96[][]","name":"prices","type":"uint96[][]"},{"internalType":"uint40[]","name":"durations","type":"uint40[]"},{"internalType":"string[][]","name":"searchKeywords","type":"string[][]"}],"name":"makeFilteredCollectionOfferBatch","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketplaceId","type":"uint256"},{"components":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"internalType":"struct NFT","name":"expectedNFT","type":"tuple"},{"internalType":"uint40","name":"quantity","type":"uint40"},{"internalType":"uint96","name":"price","type":"uint96"},{"internalType":"uint40","name":"duration","type":"uint40"}],"name":"makeOffer","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint40","name":"quantity","type":"uint40"},{"internalType":"uint96","name":"price","type":"uint96"},{"internalType":"uint40","name":"duration","type":"uint40"},{"internalType":"string","name":"searchKeywords","type":"string"}],"name":"makeOfferSingle","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address[]","name":"nfts","type":"address[]"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint40[]","name":"quantities","type":"uint40[]"},{"internalType":"uint96[]","name":"prices","type":"uint96[]"},{"internalType":"uint40[]","name":"durations","type":"uint40[]"},{"internalType":"string[]","name":"searchKeywords","type":"string[]"}],"name":"makeOfferSingleBatch","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"maxDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxOfferDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minAuctionDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minFlashAuctionDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minOfferDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketplaceId","type":"uint256"}],"name":"nextMinimumBid","outputs":[{"internalType":"uint96","name":"","type":"uint96"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"offerCounts","outputs":[{"internalType":"uint256","name":"offerCount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"offerId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"rejectSwap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"address","name":"to","type":"address"}],"internalType":"struct PaintSwapMarketplaceBase.BulkTransferInfo[]","name":"nftsInfo","type":"tuple[]"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"destination","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeNFTTransferBulkOrdered","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"min","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"},{"internalType":"uint256","name":"minAuction","type":"uint256"},{"internalType":"uint256","name":"minFlashAuction","type":"uint256"},{"internalType":"uint256","name":"maxAuction","type":"uint256"}],"name":"setDurations","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"enable","type":"bool"}],"name":"setEnableSelling","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"dev","type":"address"},{"internalType":"address","name":"salesFee","type":"address"}],"name":"setFeeAddresses","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"feePercentage","type":"address"}],"name":"setFeePercentage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"implBuyEditListing","type":"address"},{"internalType":"address","name":"implMakeAndEditOffers","type":"address"},{"internalType":"address","name":"implBids","type":"address"},{"internalType":"address","name":"implAcceptOffers","type":"address"},{"internalType":"address","name":"implListAndComplete","type":"address"},{"internalType":"address","name":"implBatchTransferNFT","type":"address"},{"internalType":"address","name":"implP2PSwaps","type":"address"}],"name":"setImpls","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint96","name":"newListingFee","type":"uint96"}],"name":"setListingFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"maxActiveOfferCount","type":"uint256"}],"name":"setMaxActiveOfferCount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"callGasLimit","type":"uint256"}],"name":"setMaxCallGasLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxRoyalty","type":"uint256"}],"name":"setMaxRoyalty","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"min","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"setOfferDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"swapCostNative","type":"uint128"}],"name":"setSwapCostNative","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"internalType":"struct IPaintSwapMarketplaceP2PSwaps.Items[]","name":"offeringNFTs","type":"tuple[]"},{"internalType":"uint128","name":"offeringNative","type":"uint128"},{"internalType":"address","name":"to","type":"address"},{"components":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"internalType":"struct IPaintSwapMarketplaceP2PSwaps.Items[]","name":"expectingNFTs","type":"tuple[]"},{"internalType":"uint128","name":"expectingNative","type":"uint128"},{"internalType":"uint40","name":"duration","type":"uint40"},{"internalType":"string","name":"searchKeywords","type":"string"}],"name":"setUpSwap","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint40","name":"auctionCancellingGracePeriod","type":"uint40"},{"internalType":"uint40","name":"flashAuctionCancellingGracePeriod","type":"uint40"},{"internalType":"uint40","name":"auctionCutOffEndTimeIncrease","type":"uint40"},{"internalType":"uint40","name":"flashAuctionCutOffEndTimeIncrease","type":"uint40"},{"internalType":"uint96","name":"minIncreasedBidPercent","type":"uint96"}],"name":"setVariousTimes","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60e080604052346100d657306080525f60a0525f60c0525f51602061593a5f395f51905f525460ff8160401c166100c7576002600160401b03196001600160401b03821601610074575b60405161585f90816100db82396080518181816129310152612b91015260a05181505060c051815050f35b6001600160401b0319166001600160401b039081175f51602061593a5f395f51905f525581527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a15f80610049565b63f92ee8a960e01b5f5260045ffd5b5f80fdfe610240604052600436101561001b575b3615610019575f80fd5b005b5f3560e01c80630c697fdf146147ba5780630ec4a1221461463d57806311c841201461458357806316ee930014613d1c578063192d1e4f14613c4557806319ea375814613b3c5780631db84f7c14613b1557806321ce9f9114613af8578063222ac42c14613ad157806323c7985714613a53578063305a67a8146139f05780633092a388146139c95780633574abaf1461379b5780633ef748f61461375657806342f90ed9146135ac5780634579268a1461315a57806349ae64b0146131365780634e8b56ae14612e275780634f1ef28614612b355780634f75081b14612a8d5780634fa0d46014612a1657806352a8bb4d146129a957806352d1902d1461290a57806354134876146128ed57806354b0fe991461279a578063561ffcc31461261657806356715761146125f957806357664b971461247c578063585b3e4d1461240e5780635e66bb8714612116578063687d471f146120d85780636a10c93e146120a95780636a1b7ecc1461207e5780636db5c8fd1461206157806370ba9ae714611f7b578063715018a614611ebf57806371d0bcf414611de15780637ab9b23214611caa5780637cdc8e2c14611c83578063847339ea14611c1c578063858122fd14611bff57806385ca7e3a14611a165780638642683f146119a75780638c746d8b146116bc5780638da5cb5b1461166a5780638ec1c4c71461158e578063981cadf5146115055780639ef305d61461146c578063a4e44fdd1461140c578063ad3cb1cc146113a9578063b8f22d88146112b6578063c074034014611230578063c96e9f4b146111da578063c99e0ffc146111bd578063cc2c754e14611156578063ce98a60714611036578063d1449f8a14610ec2578063d58d360c14610e29578063da1a200e14610e0c578063dada900414610c4a578063dd99146614610bc6578063ec4a7bbd14610b33578063ec7b2b5e14610af9578063ee7e7ba814610aa1578063eefb986c14610a08578063ef706adf14610992578063f2332635146107ce578063f2fde38b146107a5578063f743303514610691578063f92171e81461065d578063f968d006146103dc5763fc60698b0361000f57346103d85760206003193601126103d857610350615595565b6103b273ffffffffffffffffffffffffffffffffffffffff60135416604051907ffc60698b0000000000000000000000000000000000000000000000000000000060208301526004356024830152602482526103ad604483614bea565b615638565b505f7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005d005b5f80fd5b346103d85760606003193601126103d85760043567ffffffffffffffff81116103d85761040d90369060040161493a565b60243567ffffffffffffffff81116103d85761042d90369060040161493a565b9261043661486a565b90610440846154c0565b9461044e6040519687614bea565b84865261045a856154c0565b947fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe060208801960136873773ffffffffffffffffffffffffffffffffffffffff5f9416935b8181106104ec578688604051918291602083019060208452518091526040830191905f5b8181106104d1575050500390f35b825115158452859450602093840193909201916001016104c3565b6104f78183866154d8565b3573ffffffffffffffffffffffffffffffffffffffff811681036103d8576105208285896154d8565b3590865f52601e60205260405f2073ffffffffffffffffffffffffffffffffffffffff82165f5260205260405f20825f5260205260405f205480610628575b50865f526020805273ffffffffffffffffffffffffffffffffffffffff60405f2091165f5260205260405f20548061059c575b505060010161049f565b5f9996959892979194939952601860205260405f20945f98600287019485549a5b8b81101561061457865f528060205f20015488146105de575b6001016105bd565b64ffffffffff895460a01c164210156105d6575095509550959892509560018092985061060b828b615515565b525b9089610592565b50955095509598925095600191975061060d565b5f52601860205264ffffffffff60405f205460a01c16421061064b575b8a61055f565b6001610657848c615515565b52610645565b346103d85760206003193601126103d857602061067b6004356153af565b6bffffffffffffffffffffffff60405191168152f35b60a06003193601126103d8576106a5614824565b6106ad614b34565b6106b5614a9a565b906106be614b0c565b6084359367ffffffffffffffff85116103d85761077973ffffffffffffffffffffffffffffffffffffffff946bffffffffffffffffffffffff64ffffffffff6103ad956107126103b29a3690600401614b82565b93909461071d615595565b838b601054169a6040519c8d9a7ff74330350000000000000000000000000000000000000000000000000000000060208d01521660248b015216604489015216606487015216608485015260a060a485015260c4840191614f0a565b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101845283614bea565b346103d85760206003193601126103d8576100196107c1614824565b6107c9615529565b6152c2565b60c06003193601126103d8576107e2614824565b60243567ffffffffffffffff81116103d85761080290369060040161493a565b909161080c614b5c565b60643567ffffffffffffffff81116103d85761082c90369060040161493a565b91610835614b20565b9160a43567ffffffffffffffff81116103d85761085690369060040161493a565b929094610861615595565b60105473ffffffffffffffffffffffffffffffffffffffff169860405198899860208a017ff233263500000000000000000000000000000000000000000000000000000000905273ffffffffffffffffffffffffffffffffffffffff1660248a01526044890160c0905260e48901906108d992614d4e565b9164ffffffffff1660648801528682037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc01608488015261091992614e18565b9164ffffffffff1660a48501528382037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc0160c485015261095992614f98565b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0810182526109899082614bea565b6103b291615638565b346103d85760206003193601126103d8576109ab615595565b6103b273ffffffffffffffffffffffffffffffffffffffff60105416604051907fef706adf0000000000000000000000000000000000000000000000000000000060208301526004356024830152602482526103ad604483614bea565b60206003193601126103d85760043567ffffffffffffffff81116103d8576101a060031982360301126103d8576107796103b291610a44615595565b6103ad73ffffffffffffffffffffffffffffffffffffffff60135416916040519384917feefb986c000000000000000000000000000000000000000000000000000000006020840152602060248401526044830190600401615015565b346103d85760206003193601126103d857600435610abd615529565b624c4b408110156103d8576020817fbb7fa123c781240f4b78e7ab060f5cc8a2faa2b374559c0aea0c7bbf3d7c7b5092600e55604051908152a1005b346103d85760206003193601126103d8576004356bffffffffffffffffffffffff811681036103d85761001990610b2e615529565b6156d4565b346103d85760606003193601126103d8576103b2610b4f614a7f565b610b57614b5c565b610b5f615595565b64ffffffffff600f5460601c916bffffffffffffffffffffffff604051947fec4a7bbd0000000000000000000000000000000000000000000000000000000060208701526004356024870152166044850152166064830152606482526103ad608483614bea565b346103d85760406003193601126103d857602435600435610be5615529565b8015610c2257808210610bfa57601c55601d55005b7f73ab65c2000000000000000000000000000000000000000000000000000000005f5260045ffd5b7fda1eeb9f000000000000000000000000000000000000000000000000000000005f5260045ffd5b346103d85760406003193601126103d85760043567ffffffffffffffff81116103d857610c7b90369060040161493a565b610c83614a7f565b90610c8c615595565b73ffffffffffffffffffffffffffffffffffffffff6012541691604051937fdada9004000000000000000000000000000000000000000000000000000000006020860152826064860160406024880152526084850160848460051b87010193825f907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff4181360301935b838310610d66576103b28a8a6103ad828c6bffffffffffffffffffffffff8d166044830152037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101845283614bea565b9091929394967fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7c8a82030182528735868112156103d8576020610dfc60019360c0610dec8885960180358452610dc0868501878301614e8b565b6060810135606085015264ffffffffff610ddc60808301614b70565b16608085015260a0810190614f48565b9190928160a08201520191614f0a565b9901920193019190949392610d15565b346103d8575f6003193601126103d8576020601d54604051908152f35b346103d85760206003193601126103d85760043567ffffffffffffffff81116103d857610e5d6103b291369060040161493a565b610e65615595565b6103ad73ffffffffffffffffffffffffffffffffffffffff60105416916107796040519485927fd58d360c000000000000000000000000000000000000000000000000000000006020850152602060248501526044840191614d4e565b60606003193601126103d85760043567ffffffffffffffff81116103d857610eee90369060040161493a565b6024359167ffffffffffffffff83116103d857366023840112156103d857826004013567ffffffffffffffff81116103d8573660248260061b860101116103d85760443567ffffffffffffffff81116103d857610f4f90369060040161493a565b91610f58615595565b60246020610f9f600f5460601c96604051987fd1449f8a00000000000000000000000000000000000000000000000000000000848b01526060858b015260848a0191614d4e565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc888203016044890152838152019601905f5b81811061101857505050610779856103ad9386937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc856103b29a03016064860152614dd9565b9091966040808261102b6001948c614e8b565b019801929101610fd2565b346103d85760a06003193601126103d85760043564ffffffffff81168091036103d8576bffffffffffffffffffffffff9061106f614b34565b611077614b5c565b6effffffffff0000000000000000000061108f614b0c565b9269ffffffffff00000000007fffffffffffffffffffffffff0000000000ffffffffffffffffffffffffffffff6110c4614a49565b966110cd615529565b7fffffffffffffffffffffffffffffffffff00000000000000000000000000000073ffffffffff000000000000000000000000000000600d549860781b16971617169160281b16179160501b161717600d55166107d081116103d8577fffffffffffffffffffffffffffffffffffffffff000000000000000000000000600b541617600b555f80f35b346103d85773ffffffffffffffffffffffffffffffffffffffff61117936614cb7565b929091165f52602460205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f5260205260405f20905f52602052602060405f2054604051908152f35b346103d8575f6003193601126103d8576020601c54604051908152f35b346103d85760206003193601126103d8576004356111f6615529565b6103e881116103d8576020817f691d3fd9719e0e55da4b2e6511050f281cd825da1e96eec223845fc764f1ab1d92600355604051908152a1005b346103d85760206003193601126103d85760043567ffffffffffffffff81116103d8576112646103b291369060040161493a565b61126c615595565b6103ad600f5460601c916107796040519485927fc0740340000000000000000000000000000000000000000000000000000000006020850152602060248501526044840191614d4e565b60c06003193601126103d8576112ca614824565b6112d2614b5c565b606435906bffffffffffffffffffffffff82168092036103d8576112f4614b20565b60a4359367ffffffffffffffff85116103d85761077973ffffffffffffffffffffffffffffffffffffffff946103ad9364ffffffffff61133b6103b2993690600401614b82565b929093611346615595565b828a60105416996040519b8c997fb8f22d880000000000000000000000000000000000000000000000000000000060208c01521660248a015260243560448a015216606488015260848701521660a485015260c060c485015260e4840191614f0a565b346103d8575f6003193601126103d8576114086040516113ca604082614bea565b600581527f352e302e300000000000000000000000000000000000000000000000000000006020820152604051918291602083526020830190614d0b565b0390f35b346103d85760a06003193601126103d857608435606435604435602435600435611434615529565b8015610c2257818111610bfa576006556007558015610c2257828111610bfa578115610c2257828211610bfa57600855600955600a55005b346103d85760206003193601126103d85760043567ffffffffffffffff81116103d8576114a06103b291369060040161493a565b6114a8615595565b6103ad73ffffffffffffffffffffffffffffffffffffffff60105416916107796040519485927f9ef305d6000000000000000000000000000000000000000000000000000000006020850152602060248501526044840191614d4e565b346103d85760206003193601126103d857610019611521614824565b73ffffffffffffffffffffffffffffffffffffffff6015541673ffffffffffffffffffffffffffffffffffffffff604051927f981cadf5000000000000000000000000000000000000000000000000000000006020850152166024830152602482526103ad604483614bea565b60c06003193601126103d8576103b26115a5614847565b6115ad614b0c565b64ffffffffff6115bb614a49565b6bffffffffffffffffffffffff6115d0614b48565b916115d9615595565b8373ffffffffffffffffffffffffffffffffffffffff601054169573ffffffffffffffffffffffffffffffffffffffff604051987f8ec1c4c70000000000000000000000000000000000000000000000000000000060208b015260043560248b015216604489015260443560648901521660848701521660a48501521660c483015260c482526103ad60e483614bea565b346103d8575f6003193601126103d857602073ffffffffffffffffffffffffffffffffffffffff7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005416604051908152f35b346103d85760206003193601126103d8576116d5615255565b506116de615255565b506004355f525f60205260405f20805473ffffffffffffffffffffffffffffffffffffffff811691821561197f5760018101549260028201549160048101549360038201549160050154926040519261173684614bcd565b8184526020840197885260408401928660c81c64ffffffffff168452606085019060a01c81526080850173ffffffffffffffffffffffffffffffffffffffff8816815260a086018860081b7f0200000000000000000000000000000000000000000000000000000000000000167f020000000000000000000000000000000000000000000000000000000000000014815260c08701918a60a01c64ffffffffff16835260e08801938560a01c855261010089019573ffffffffffffffffffffffffffffffffffffffff1686526101208901968c60c81c60ff16151588526101408a01988d60d01c60ff1615158a526101608b019a73ffffffffffffffffffffffffffffffffffffffff8d168c5261018081019c60a01c61ffff168d526101a08101809e60a01c64ffffffffff1690526101c00173ffffffffffffffffffffffffffffffffffffffff819f1690526040519e8f9283525160208301525164ffffffffff169060400152516bffffffffffffffffffffffff1660608d01525173ffffffffffffffffffffffffffffffffffffffff1660808c015251151560a08b01525164ffffffffff1660c08a0152516bffffffffffffffffffffffff1660e08901525173ffffffffffffffffffffffffffffffffffffffff166101008801525115156101208701525115156101408601525173ffffffffffffffffffffffffffffffffffffffff166101608501525161ffff166101808401525164ffffffffff166101a08301525173ffffffffffffffffffffffffffffffffffffffff166101c08201526101e090f35b7f6b559eca000000000000000000000000000000000000000000000000000000005f5260045ffd5b346103d85760206003193601126103d8576004358015158091036103d8576119cd615529565b7fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff74ff00000000000000000000000000000000000000006005549260a01b169116176005555f80f35b60e06003193601126103d85760043567ffffffffffffffff81116103d857611a4290369060040161493a565b90611a4b614ace565b91611a5461486a565b9260643567ffffffffffffffff81116103d857611a7590369060040161493a565b91611a7e614aed565b91611a87614b48565b9060c43567ffffffffffffffff81116103d857611aa8903690600401614b82565b93909560155473ffffffffffffffffffffffffffffffffffffffff1699604051998a9960208b017f85ca7e3a00000000000000000000000000000000000000000000000000000000905260248b0160e090526101048b0190611b099261515c565b926fffffffffffffffffffffffffffffffff1660448a015273ffffffffffffffffffffffffffffffffffffffff1660648901528782037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc016084890152611b6f9261515c565b926fffffffffffffffffffffffffffffffff1660a486015264ffffffffff1660c48501528382037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc0160e4850152611bc692614f0a565b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081018252611bf69082614bea565b61001991615638565b346103d8575f6003193601126103d8576020600954604051908152f35b346103d85773ffffffffffffffffffffffffffffffffffffffff611c3f36614cb7565b929091165f52601e60205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f5260205260405f20905f52602052602060405f2054604051908152f35b346103d8575f6003193601126103d857602064ffffffffff600d5460501c16604051908152f35b346103d85760c06003193601126103d85760407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc3601126103d857611ced614b0c565b60843567ffffffffffffffff81116103d8576103b2916103ad611d1a64ffffffffff933690600401614b82565b92906bffffffffffffffffffffffff611dae611d34614a64565b92611d3d615595565b73ffffffffffffffffffffffffffffffffffffffff60125416966040519889967f7ab9b2320000000000000000000000000000000000000000000000000000000060208901526004356024890152611d9760448901614e5e565b16608487015260c060a487015260e4860191614f0a565b911660c4830152037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101845283614bea565b346103d85760406003193601126103d85760043567ffffffffffffffff81116103d857611e1290369060040161493a565b906024359167ffffffffffffffff83116103d8576103ad61077991611e3e6103b295369060040161493a565b9390611e48615595565b600f5460601c94611e8f6040519788957f71d0bcf4000000000000000000000000000000000000000000000000000000006020880152604060248801526064870191614d4e565b917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc858403016044860152614e18565b346103d8575f6003193601126103d857611ed7615529565b5f73ffffffffffffffffffffffffffffffffffffffff7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300547fffffffffffffffffffffffff000000000000000000000000000000000000000081167f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b60c06003193601126103d85760407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc3601126103d8576103b2611fbc614b0c565b611fc4614a49565b64ffffffffff611fd2614b48565b611fda615595565b6bffffffffffffffffffffffff73ffffffffffffffffffffffffffffffffffffffff601054169383604051967f70ba9ae7000000000000000000000000000000000000000000000000000000006020890152600435602489015261204060448901614e5e565b1660848701521660a48501521660c483015260c482526103ad60e483614bea565b346103d8575f6003193601126103d8576020600754604051908152f35b346103d8575f6003193601126103d85760206bffffffffffffffffffffffff600f5416604051908152f35b346103d8575f6003193601126103d85760206fffffffffffffffffffffffffffffffff60255416604051908152f35b346103d85760206003193601126103d8576004356fffffffffffffffffffffffffffffffff811681036103d85761001990612111615529565b615665565b6101a06003193601126103d85761212b614824565b612133614a9a565b9061213c614b0c565b90612145614b20565b61214d614c9b565b60c435938415158095036103d85760e4358015158091036103d857610104358015158091036103d85761012435918215158093036103d8576101443567ffffffffffffffff81116103d8576121a6903690600401614b82565b989095610164359773ffffffffffffffffffffffffffffffffffffffff89168099036103d857610184359761ffff89168099036103d8576121e5615595565b6040519a6101a08c018c811067ffffffffffffffff8211176123e15760405273ffffffffffffffffffffffffffffffffffffffff168b5260208b019b6024358d5260408c016bffffffffffffffffffffffff819f16905260608c019864ffffffffff16895260808c019264ffffffffff16835260a08c01931515845260c08c0194855260e08c019586526101008c019687526101208c01978852369061228a92614c65565b966101408b019788526101608b01998a526101808b0198895260135473ffffffffffffffffffffffffffffffffffffffff169c6040519c8d809d602082017feefb986c00000000000000000000000000000000000000000000000000000000905260248201602090525173ffffffffffffffffffffffffffffffffffffffff1690604401525160648d0152516bffffffffffffffffffffffff1660848c01525164ffffffffff1660a48b01525164ffffffffff1660c48a015251151560e48901525115156101048801525115156101248701525115156101448601525115156101648501525161018484016101a090526101e4840161238891614d0b565b915173ffffffffffffffffffffffffffffffffffffffff166101a48401525161ffff166101c4830152037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0810182526109899082614bea565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b346103d85760406003193601126103d857612427614824565b73ffffffffffffffffffffffffffffffffffffffff612444614847565b91165f52601f60205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f52602052602060405f2054604051908152f35b6124853661496b565b96919493929590979a9998612498615595565b60105473ffffffffffffffffffffffffffffffffffffffff169b6040519b8c9b60208d017f57664b9700000000000000000000000000000000000000000000000000000000905260248d0160c0905260e48d01906124f592614d8b565b908b82037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc0160448d015261252992614d4e565b908982037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc0160648b015261255d92614dd9565b908782037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc01608489015261259192614e18565b908582037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc0160a48701526125c592614dd9565b908382037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc0160c485015261095992614f98565b346103d8575f6003193601126103d8576020600654604051908152f35b60c06003193601126103d85760043567ffffffffffffffff81116103d85761264290369060040161493a565b9061264b614ace565b9161265461486a565b9260643567ffffffffffffffff81116103d85761267590369060040161493a565b9061267e614aed565b92612687614c9b565b9260155473ffffffffffffffffffffffffffffffffffffffff1697604051978897602089017f561ffcc30000000000000000000000000000000000000000000000000000000090526024890160c0905260e48901906126e59261515c565b926fffffffffffffffffffffffffffffffff16604488015273ffffffffffffffffffffffffffffffffffffffff1660648701528582037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc01608487015261274b9261515c565b916fffffffffffffffffffffffffffffffff1660a4840152151560c4830152037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081018252611bf69082614bea565b60206003193601126103d85760043567ffffffffffffffff81116103d8576127c690369060040161493a565b906127cf615595565b73ffffffffffffffffffffffffffffffffffffffff6013541691604051917f54b0fe99000000000000000000000000000000000000000000000000000000006020840152816044840160206024860152526064830160648360051b85010192825f907ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe6181360301935b838310612895576103b2888a6103ad828b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101845283614bea565b9091929394957fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9c8882030182528635868112156103d85760206128dd60019386839401615015565b9801920193019190949392612858565b346103d8575f6003193601126103d8576020600854604051908152f35b346103d8575f6003193601126103d85773ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001630036129815760206040517f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8152f35b7fe07c8dba000000000000000000000000000000000000000000000000000000005f5260045ffd5b346103d85760406003193601126103d8576129c2614824565b73ffffffffffffffffffffffffffffffffffffffff6129df614847565b91165f526020805273ffffffffffffffffffffffffffffffffffffffff60405f2091165f52602052602060405f2054604051908152f35b346103d85760406003193601126103d8576103b2612a32614b34565b612a3a615595565b600f5460601c64ffffffffff604051927f4fa0d4600000000000000000000000000000000000000000000000000000000060208501526004356024850152166044830152604482526103ad606483614bea565b60806003193601126103d85760407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc3601126103d8576103b2612ace614b0c565b612ad6615595565b600f5460601c64ffffffffff604051927f4f75081b0000000000000000000000000000000000000000000000000000000060208501526004356024850152612b2060448501614e5e565b166084830152608482526103ad60a483614bea565b60406003193601126103d857612b49614824565b60243567ffffffffffffffff81116103d857366023820112156103d857612b7a903690602481600401359101614c65565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016803014908115612de5575b5061298157612bc9615529565b73ffffffffffffffffffffffffffffffffffffffff8216916040517f52d1902d000000000000000000000000000000000000000000000000000000008152602081600481875afa5f9181612db1575b50612c4957837f4c9c8ce3000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc859203612d865750813b15612d5b57807fffffffffffffffffffffffff00000000000000000000000000000000000000007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5416177f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b5f80a2815115612d2a575f8083602061001995519101845af4612d24615609565b91615790565b505034612d3357005b7fb398979f000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f4c9c8ce3000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b7faa1d49a4000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b9091506020813d602011612ddd575b81612dcd60209383614bea565b810103126103d857519085612c18565b3d9150612dc0565b905073ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5416141583612bbc565b612e9e60e4612e353661496b565b9c90999a612e4b99929895969499979397615595565b73ffffffffffffffffffffffffffffffffffffffff601054169b6040519d8e7f4e8b56ae00000000000000000000000000000000000000000000000000000000602082015260c060248201520191614d8b565b937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc8c86030160448d0152808552602085019460208260051b82010195835f925b8484106130d4575050505050509082917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc8b612f2195030160648c0152614dd9565b937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc888603016084890152808552602085019460208260051b82010195835f925b848410613078575050505050509082917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc87612fa495030160a4880152614dd9565b937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc8486030160c4850152808552602085019460208260051b82010195835f925b848410613022576103b288886103ad828d037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101845283614bea565b909192939497602080613068837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe086600196030188526130628d88614eb7565b90614f98565b9a01940194019294939190612fe5565b9091929394976020806130c19b9e9b837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe086600196030188526130bb8d88614eb7565b90614e18565b9a019401940192949391909b989b612f62565b9091929394979c9f9c6020806131209b9e9b837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0866001960301885261311a8d88614eb7565b90614d4e565b9a019401940192949391909f9c9f9b989b612edf565b346103d8575f6003193601126103d857602064ffffffffff600d5416604051908152f35b346103d85760206003193601126103d8575f61012060405161317b81614bb0565b82815282602082015282604082015282606082015260606080820152606060a0820152606060c08201528260e08201528261010082015201526004355f52601860205260405f206040516131ce81614bb0565b81549073ffffffffffffffffffffffffffffffffffffffff82168152602081019164ffffffffff8160a01c168352604082019065ffffffffffff8160c81c16825260f81c93606083019460058110156134c657855260018101604051808260208294549384815201905f5260205f20925f5b81811061357d57505061325592500382614bea565b6080840190815260028201604051808260208294549384815201905f5260205f20925f5b81811061356457505061328e92500382614bea565b60a085019081526003830191604051808460208296549384815201905f5260205f20925f905b80600183011061352e576132da94549181811061350f575b106134f3575b500384614bea565b60c0860192835260048401549765ffffffffffff600560e089019673ffffffffffffffffffffffffffffffffffffffff8c1688526101008a019b60a01c8c52015496610120890197885264ffffffffff6040519a60208c5273ffffffffffffffffffffffffffffffffffffffff6101608d019b511660208d0152511660408b0152511660608901525160058110156134c6576080880152519461014060a08801528551809152602061018088019601905f5b81811061349a5750505051937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08682030160c0870152602080865192838152019501905f5b8181106134845750505051927fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08582030160e0860152602080855192838152019401905f5b81811061346057505050839473ffffffffffffffffffffffffffffffffffffffff6bffffffffffffffffffffffff9251166101008601525116610120840152516101408301520390f35b82516bffffffffffffffffffffffff16865260209586019590920191600101613416565b82518752602096870196909201916001016133d1565b825173ffffffffffffffffffffffffffffffffffffffff1688526020978801979092019160010161338c565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b60601c6bffffffffffffffffffffffff1681526020018b6132d2565b9260206001916bffffffffffffffffffffffff851681520193016132cc565b91600291935060406001916bffffffffffffffffffffffff8754818116835260601c1660208201520194019201869293916132b4565b8454835260019485019486945060209093019201613279565b845473ffffffffffffffffffffffffffffffffffffffff16835260019485019486945060209093019201613240565b346103d85760e06003193601126103d85773ffffffffffffffffffffffffffffffffffffffff6135da614824565b816135e3614847565b816135ec61486a565b816135f561488d565b816135fe6148b0565b93816136086148d3565b976136116148f6565b9a61361a615529565b6bffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffff000000000000000000000000600f549260601b16911617600f55167fffffffffffffffffffffffff00000000000000000000000000000000000000006010541617601055167fffffffffffffffffffffffff00000000000000000000000000000000000000006011541617601155167fffffffffffffffffffffffff00000000000000000000000000000000000000006012541617601255167fffffffffffffffffffffffff00000000000000000000000000000000000000006013541617601355167fffffffffffffffffffffffff00000000000000000000000000000000000000006014541617601455167fffffffffffffffffffffffff000000000000000000000000000000000000000060155416176015555f80f35b346103d85760206003193601126103d85773ffffffffffffffffffffffffffffffffffffffff613784614824565b165f52601b602052602060405f2054604051908152f35b346103d85760806003193601126103d85760043567ffffffffffffffff81116103d8576137cc90369060040161493a565b6137d461486a565b60643567ffffffffffffffff81116103d8576137f4903690600401614b82565b906137fd615595565b73ffffffffffffffffffffffffffffffffffffffff6014541692604051947f3574abaf0000000000000000000000000000000000000000000000000000000060208701528060a48701608060248901525260c486019060c48160051b8801019780925f907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8183360301905b8483106138f35750506103b289896103ad826107798f8d8d73ffffffffffffffffffffffffffffffffffffffff8e60243560448801521660648601527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc858403016084860152614f0a565b90919293949a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff3c8b82030182528b3590838212156103d8576020809187600194019073ffffffffffffffffffffffffffffffffffffffff61395383614919565b168152606073ffffffffffffffffffffffffffffffffffffffff6139b5826139ae61399361398389890189614eb7565b60808b8a01526080890191614d4e565b6139a06040890189614eb7565b9088830360408a0152614d4e565b9501614919565b169101529d01920193019190949392613888565b346103d8575f6003193601126103d857602064ffffffffff600d5460281c16604051908152f35b346103d85760206003193601126103d857613a09615595565b6103b2600f5460601c604051907f305a67a80000000000000000000000000000000000000000000000000000000060208301526004356024830152602482526103ad604483614bea565b346103d85760406003193601126103d8576103b2613a6f614a7f565b613a77615595565b600f5460601c6bffffffffffffffffffffffff604051927f23c798570000000000000000000000000000000000000000000000000000000060208501526004356024850152166044830152604482526103ad606483614bea565b346103d85760206003193601126103d857600435613aed615529565b80156103d857601a55005b346103d8575f6003193601126103d8576020601954604051908152f35b346103d8575f6003193601126103d857602064ffffffffff600d5460781c16604051908152f35b346103d85760c06003193601126103d85760407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbc3601126103d857613b7f614b20565b613b87614a64565b90613b90615595565b73ffffffffffffffffffffffffffffffffffffffff60125416604051917f19ea3758000000000000000000000000000000000000000000000000000000006020840152600435602484015260243560448401526044359373ffffffffffffffffffffffffffffffffffffffff85168095036103d85764ffffffffff6bffffffffffffffffffffffff926103b296606487015260643560848701521660a48501521660c483015260c482526103ad60e483614bea565b60a06003193601126103d85760407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc3601126103d8576103b2613c86614b0c565b613c8e614a49565b613c96615595565b6bffffffffffffffffffffffff73ffffffffffffffffffffffffffffffffffffffff601154169164ffffffffff604051947f192d1e4f0000000000000000000000000000000000000000000000000000000060208701526004356024870152613d0160448701614e5e565b1660848501521660a483015260a482526103ad60c483614bea565b346103d8576102006003193601126103d857613d36614824565b60a052613d41614847565b61020052613d4d61486a565b613d5561488d565b60e052613d606148b0565b61010052613d6c6148d3565b61012052613d786148f6565b6101405260e43561016081905273ffffffffffffffffffffffffffffffffffffffff811690036103d8576101043561018081905273ffffffffffffffffffffffffffffffffffffffff811690036103d857610124356101a081905273ffffffffffffffffffffffffffffffffffffffff811690036103d8576101443560c081905273ffffffffffffffffffffffffffffffffffffffff811690036103d857610164356101e08190526bffffffffffffffffffffffff811690036103d8576101843573ffffffffffffffffffffffffffffffffffffffff811681036103d8576101a435608081905273ffffffffffffffffffffffffffffffffffffffff811690036103d8576101c4356101c08190526fffffffffffffffffffffffffffffffff811690036103d8577ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00546102205267ffffffffffffffff61022051161580614572575b600167ffffffffffffffff6102205116149081614568575b15908161455f575b506145375773ffffffffffffffffffffffffffffffffffffffff809260017fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000006102205116177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005560ff6102205160401c16156144df575b613f79615739565b613f81615739565b613f8a336152c2565b613f92615739565b613f9a615739565b167fffffffffffffffffffffffff00000000000000000000000000000000000000006023541617602355167fffffffffffffffffffffffff0000000000000000000000000000000000000000600154161760015573ffffffffffffffffffffffffffffffffffffffff608051167fffffffffffffffffffffffff0000000000000000000000000000000000000000600254161760025573ffffffffffffffffffffffffffffffffffffffff60a051167fffffffffffffffffffffffff000000000000000000000000000000000000000060055416176005556101e435600c5573ffffffffffffffffffffffffffffffffffffffff60c051167fffffffffffffffffffffffff00000000000000000000000000000000000000006022541617602255600f546bffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000060e05160601b16911617600f5573ffffffffffffffffffffffffffffffffffffffff61010051167fffffffffffffffffffffffff0000000000000000000000000000000000000000601054161760105573ffffffffffffffffffffffffffffffffffffffff61012051167fffffffffffffffffffffffff0000000000000000000000000000000000000000601154161760115573ffffffffffffffffffffffffffffffffffffffff61014051167fffffffffffffffffffffffff0000000000000000000000000000000000000000601254161760125573ffffffffffffffffffffffffffffffffffffffff61016051167fffffffffffffffffffffffff0000000000000000000000000000000000000000601354161760135573ffffffffffffffffffffffffffffffffffffffff61018051167fffffffffffffffffffffffff0000000000000000000000000000000000000000601454161760145573ffffffffffffffffffffffffffffffffffffffff6101a051167fffffffffffffffffffffffff000000000000000000000000000000000000000060155416176015556142976101c051615665565b6142a36101e0516156d4565b73ffffffffffffffffffffffffffffffffffffffff61020051167fffffffffffffffffffffffff000000000000000000000000000000000000000060045416176004556102ee6003557f691d3fd9719e0e55da4b2e6511050f281cd825da1e96eec223845fc764f1ab1d60206040516102ee8152a1620f4240600e557fbb7fa123c781240f4b78e7ab060f5cc8a2faa2b374559c0aea0c7bbf3d7c7b506020604051620f42408152a1740100000000000000000000000000000000000000007fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff600554161760055562015180600655630107ac0060075561070860085561012c60095562093a80600a556f3c00000000b400000000000000000000653c00000002587fffffffffffffffffffffffff0000000000000000000000000000000000000000600d54161717600d5560647fffffffffffffffffffffffffffffffffffffffff000000000000000000000000600b541617600b556203d090600e5560016019556103e8601a5562015180601c55630107ac00601d5560ff6102205160401c161561444c57005b7fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054167ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00557fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2602060405160018152a1005b680100000000000000017fffffffffffffffffffffffffffffffffffffffffffffff0000000000000000006102205116177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0055613f71565b7ff92ee8a9000000000000000000000000000000000000000000000000000000005f5260045ffd5b90501583613efa565b303b159150613ef2565b5060ff6102205160401c1615613eda565b346103d85760406003193601126103d85761459c614824565b73ffffffffffffffffffffffffffffffffffffffff6145b9614847565b916145c2615529565b169081156103d85773ffffffffffffffffffffffffffffffffffffffff169081156103d8577fffffffffffffffffffffffff000000000000000000000000000000000000000060015416176001557fffffffffffffffffffffffff000000000000000000000000000000000000000060025416176002555f80f35b6146463661496b565b96919493929590979a9998614659615595565b60105473ffffffffffffffffffffffffffffffffffffffff169b6040519b8c9b60208d017fc0d2644c00000000000000000000000000000000000000000000000000000000905260248d0160c0905260e48d01906146b692614d4e565b908b82037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc0160448d01526146ea92614d8b565b908982037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc0160648b015261471e92614d4e565b908782037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc01608489015261475292614dd9565b908582037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc0160a487015261478692614e18565b908382037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc0160c485015261095992614dd9565b346103d85760206003193601126103d85773ffffffffffffffffffffffffffffffffffffffff6147e8614824565b6147f0615529565b1680156103d8577fffffffffffffffffffffffff000000000000000000000000000000000000000060225416176022555f80f35b6004359073ffffffffffffffffffffffffffffffffffffffff821682036103d857565b6024359073ffffffffffffffffffffffffffffffffffffffff821682036103d857565b6044359073ffffffffffffffffffffffffffffffffffffffff821682036103d857565b6064359073ffffffffffffffffffffffffffffffffffffffff821682036103d857565b6084359073ffffffffffffffffffffffffffffffffffffffff821682036103d857565b60a4359073ffffffffffffffffffffffffffffffffffffffff821682036103d857565b60c4359073ffffffffffffffffffffffffffffffffffffffff821682036103d857565b359073ffffffffffffffffffffffffffffffffffffffff821682036103d857565b9181601f840112156103d85782359167ffffffffffffffff83116103d8576020808501948460051b0101116103d857565b60c06003198201126103d85760043567ffffffffffffffff81116103d857816149969160040161493a565b9290929160243567ffffffffffffffff81116103d857816149b99160040161493a565b9290929160443567ffffffffffffffff81116103d857816149dc9160040161493a565b9290929160643567ffffffffffffffff81116103d857816149ff9160040161493a565b9290929160843567ffffffffffffffff81116103d85781614a229160040161493a565b9290929160a4359067ffffffffffffffff82116103d857614a459160040161493a565b9091565b608435906bffffffffffffffffffffffff821682036103d857565b60a435906bffffffffffffffffffffffff821682036103d857565b602435906bffffffffffffffffffffffff821682036103d857565b604435906bffffffffffffffffffffffff821682036103d857565b35906bffffffffffffffffffffffff821682036103d857565b602435906fffffffffffffffffffffffffffffffff821682036103d857565b608435906fffffffffffffffffffffffffffffffff821682036103d857565b6064359064ffffffffff821682036103d857565b6084359064ffffffffff821682036103d857565b6024359064ffffffffff821682036103d857565b60a4359064ffffffffff821682036103d857565b6044359064ffffffffff821682036103d857565b359064ffffffffff821682036103d857565b9181601f840112156103d85782359167ffffffffffffffff83116103d857602083818601950101116103d857565b610140810190811067ffffffffffffffff8211176123e157604052565b6101e0810190811067ffffffffffffffff8211176123e157604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff8211176123e157604052565b67ffffffffffffffff81116123e157601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b929192614c7182614c2b565b91614c7f6040519384614bea565b8294818452818301116103d8578281602093845f960137010152565b60a4359081151582036103d857565b359081151582036103d857565b60031960609101126103d85760043573ffffffffffffffffffffffffffffffffffffffff811681036103d8579060243573ffffffffffffffffffffffffffffffffffffffff811681036103d8579060443590565b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f602080948051918291828752018686015e5f8582860101520116010190565b90918281527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83116103d85760209260051b809284830137010190565b916020908281520191905f5b818110614da45750505090565b90919260208060019273ffffffffffffffffffffffffffffffffffffffff614dcb88614919565b168152019401929101614d97565b916020908281520191905f5b818110614df25750505090565b90919260208060019264ffffffffff614e0a88614b70565b168152019401929101614de5565b916020908281520191905f5b818110614e315750505090565b9091926020806001926bffffffffffffffffffffffff614e5088614ab5565b168152019401929101614e24565b60243573ffffffffffffffffffffffffffffffffffffffff81168091036103d85781526020604435910152565b6020809173ffffffffffffffffffffffffffffffffffffffff614ead82614919565b1684520135910152565b90357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1823603018112156103d857016020813591019167ffffffffffffffff82116103d8578160051b360383136103d857565b601f82602094937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe093818652868601375f8582860101520116010190565b90357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1823603018112156103d857016020813591019167ffffffffffffffff82116103d85781360383136103d857565b90602083828152019260208260051b82010193835f925b848410614fbf5750505050505090565b909192939495602080615005837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08660019603018852614fff8b88614f48565b90614f0a565b9801940194019294939190614faf565b9073ffffffffffffffffffffffffffffffffffffffff61503483614919565b168152602082013560208201526bffffffffffffffffffffffff61505a60408401614ab5565b16604082015264ffffffffff61507260608401614b70565b16606082015264ffffffffff61508a60808401614b70565b16608082015261509c60a08301614caa565b151560a08201526150af60c08301614caa565b151560c08201526150c260e08301614caa565b151560e08201526150d66101008301614caa565b15156101008201526150eb6101208301614caa565b151561012082015261018061511b615107610140850185614f48565b6101a06101408601526101a0850191614f0a565b9273ffffffffffffffffffffffffffffffffffffffff61513e6101608301614919565b1661016084015201359061ffff82168092036103d857610180015290565b90602083828152019060208160051b85010193835f915b8383106151835750505050505090565b9091929394957fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe082820301865286357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa1843603018112156103d8576020615247600193868394019073ffffffffffffffffffffffffffffffffffffffff61520983614919565b16815261523961522e61521e86850185614eb7565b6060888601526060850191614d4e565b926040810190614eb7565b916040818503910152614d4e565b980196019493019190615173565b6040519061526282614bcd565b5f6101c0838281528260208201528260408201528260608201528260808201528260a08201528260c08201528260e08201528261010082015282610120820152826101408201528261016082015282610180820152826101a08201520152565b73ffffffffffffffffffffffffffffffffffffffff1680156153835773ffffffffffffffffffffffffffffffffffffffff7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930054827fffffffffffffffffffffffff00000000000000000000000000000000000000008216177f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3565b7f1e4fbdf7000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b5f525f60205260405f207f020000000000000000000000000000000000000000000000000000000000000080600283015460081b16146153ee57505f90565b6003815460a01c91015460a01c6bffffffffffffffffffffffff600b541690604051927f66ad086d00000000000000000000000000000000000000000000000000000000845260048401526024830152604482015260208160648173e0cb467a1a46d29682332e0ba8099aee26dee6205af49081156154b5575f91615471575090565b90506020813d6020116154ad575b8161548c60209383614bea565b810103126103d857516bffffffffffffffffffffffff811681036103d85790565b3d915061547f565b6040513d5f823e3d90fd5b67ffffffffffffffff81116123e15760051b60200190565b91908110156154e85760051b0190565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b80518210156154e85760209160051b010190565b73ffffffffffffffffffffffffffffffffffffffff7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005416330361556957565b7f118cdaa7000000000000000000000000000000000000000000000000000000005f523360045260245ffd5b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005c6155e15760017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005d565b7f3ee5aeb5000000000000000000000000000000000000000000000000000000005f5260045ffd5b3d15615633573d9061561a82614c2b565b916156286040519384614bea565b82523d5f602084013e565b606090565b5f918291602082519201905af49061564e615609565b911561565657565b5080519081156103d857602001fd5b60406fffffffffffffffffffffffffffffffff7f7bd04e80b87f9d29d31456e209784930c75d2a834480768ca06d10d4483449709216807fffffffffffffffffffffffffffffffff000000000000000000000000000000006025541617602555815190600882526020820152a1565b60206bffffffffffffffffffffffff7f6d4357a1ed4a9686bb163d10abedf9d8787f955e3906001d40d62bb9aad8e9e89216807fffffffffffffffffffffffffffffffffffffffff000000000000000000000000600f541617600f55604051908152a1565b60ff7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460401c161561576857565b7fd7e6bcf8000000000000000000000000000000000000000000000000000000005f5260045ffd5b906157cd57508051156157a557805190602001fd5b7fd6bda275000000000000000000000000000000000000000000000000000000005f5260045ffd5b81511580615820575b6157de575090565b73ffffffffffffffffffffffffffffffffffffffff907f9996b315000000000000000000000000000000000000000000000000000000005f521660045260245ffd5b50803b156157d656fea2646970667358221220f130bf6982307e99d516777ad38922d57e0e1a90851a3178818b416126cba1e864736f6c634300081c0033f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00
Deployed Bytecode
0x610240604052600436101561001b575b3615610019575f80fd5b005b5f3560e01c80630c697fdf146147ba5780630ec4a1221461463d57806311c841201461458357806316ee930014613d1c578063192d1e4f14613c4557806319ea375814613b3c5780631db84f7c14613b1557806321ce9f9114613af8578063222ac42c14613ad157806323c7985714613a53578063305a67a8146139f05780633092a388146139c95780633574abaf1461379b5780633ef748f61461375657806342f90ed9146135ac5780634579268a1461315a57806349ae64b0146131365780634e8b56ae14612e275780634f1ef28614612b355780634f75081b14612a8d5780634fa0d46014612a1657806352a8bb4d146129a957806352d1902d1461290a57806354134876146128ed57806354b0fe991461279a578063561ffcc31461261657806356715761146125f957806357664b971461247c578063585b3e4d1461240e5780635e66bb8714612116578063687d471f146120d85780636a10c93e146120a95780636a1b7ecc1461207e5780636db5c8fd1461206157806370ba9ae714611f7b578063715018a614611ebf57806371d0bcf414611de15780637ab9b23214611caa5780637cdc8e2c14611c83578063847339ea14611c1c578063858122fd14611bff57806385ca7e3a14611a165780638642683f146119a75780638c746d8b146116bc5780638da5cb5b1461166a5780638ec1c4c71461158e578063981cadf5146115055780639ef305d61461146c578063a4e44fdd1461140c578063ad3cb1cc146113a9578063b8f22d88146112b6578063c074034014611230578063c96e9f4b146111da578063c99e0ffc146111bd578063cc2c754e14611156578063ce98a60714611036578063d1449f8a14610ec2578063d58d360c14610e29578063da1a200e14610e0c578063dada900414610c4a578063dd99146614610bc6578063ec4a7bbd14610b33578063ec7b2b5e14610af9578063ee7e7ba814610aa1578063eefb986c14610a08578063ef706adf14610992578063f2332635146107ce578063f2fde38b146107a5578063f743303514610691578063f92171e81461065d578063f968d006146103dc5763fc60698b0361000f57346103d85760206003193601126103d857610350615595565b6103b273ffffffffffffffffffffffffffffffffffffffff60135416604051907ffc60698b0000000000000000000000000000000000000000000000000000000060208301526004356024830152602482526103ad604483614bea565b615638565b505f7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005d005b5f80fd5b346103d85760606003193601126103d85760043567ffffffffffffffff81116103d85761040d90369060040161493a565b60243567ffffffffffffffff81116103d85761042d90369060040161493a565b9261043661486a565b90610440846154c0565b9461044e6040519687614bea565b84865261045a856154c0565b947fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe060208801960136873773ffffffffffffffffffffffffffffffffffffffff5f9416935b8181106104ec578688604051918291602083019060208452518091526040830191905f5b8181106104d1575050500390f35b825115158452859450602093840193909201916001016104c3565b6104f78183866154d8565b3573ffffffffffffffffffffffffffffffffffffffff811681036103d8576105208285896154d8565b3590865f52601e60205260405f2073ffffffffffffffffffffffffffffffffffffffff82165f5260205260405f20825f5260205260405f205480610628575b50865f526020805273ffffffffffffffffffffffffffffffffffffffff60405f2091165f5260205260405f20548061059c575b505060010161049f565b5f9996959892979194939952601860205260405f20945f98600287019485549a5b8b81101561061457865f528060205f20015488146105de575b6001016105bd565b64ffffffffff895460a01c164210156105d6575095509550959892509560018092985061060b828b615515565b525b9089610592565b50955095509598925095600191975061060d565b5f52601860205264ffffffffff60405f205460a01c16421061064b575b8a61055f565b6001610657848c615515565b52610645565b346103d85760206003193601126103d857602061067b6004356153af565b6bffffffffffffffffffffffff60405191168152f35b60a06003193601126103d8576106a5614824565b6106ad614b34565b6106b5614a9a565b906106be614b0c565b6084359367ffffffffffffffff85116103d85761077973ffffffffffffffffffffffffffffffffffffffff946bffffffffffffffffffffffff64ffffffffff6103ad956107126103b29a3690600401614b82565b93909461071d615595565b838b601054169a6040519c8d9a7ff74330350000000000000000000000000000000000000000000000000000000060208d01521660248b015216604489015216606487015216608485015260a060a485015260c4840191614f0a565b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101845283614bea565b346103d85760206003193601126103d8576100196107c1614824565b6107c9615529565b6152c2565b60c06003193601126103d8576107e2614824565b60243567ffffffffffffffff81116103d85761080290369060040161493a565b909161080c614b5c565b60643567ffffffffffffffff81116103d85761082c90369060040161493a565b91610835614b20565b9160a43567ffffffffffffffff81116103d85761085690369060040161493a565b929094610861615595565b60105473ffffffffffffffffffffffffffffffffffffffff169860405198899860208a017ff233263500000000000000000000000000000000000000000000000000000000905273ffffffffffffffffffffffffffffffffffffffff1660248a01526044890160c0905260e48901906108d992614d4e565b9164ffffffffff1660648801528682037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc01608488015261091992614e18565b9164ffffffffff1660a48501528382037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc0160c485015261095992614f98565b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0810182526109899082614bea565b6103b291615638565b346103d85760206003193601126103d8576109ab615595565b6103b273ffffffffffffffffffffffffffffffffffffffff60105416604051907fef706adf0000000000000000000000000000000000000000000000000000000060208301526004356024830152602482526103ad604483614bea565b60206003193601126103d85760043567ffffffffffffffff81116103d8576101a060031982360301126103d8576107796103b291610a44615595565b6103ad73ffffffffffffffffffffffffffffffffffffffff60135416916040519384917feefb986c000000000000000000000000000000000000000000000000000000006020840152602060248401526044830190600401615015565b346103d85760206003193601126103d857600435610abd615529565b624c4b408110156103d8576020817fbb7fa123c781240f4b78e7ab060f5cc8a2faa2b374559c0aea0c7bbf3d7c7b5092600e55604051908152a1005b346103d85760206003193601126103d8576004356bffffffffffffffffffffffff811681036103d85761001990610b2e615529565b6156d4565b346103d85760606003193601126103d8576103b2610b4f614a7f565b610b57614b5c565b610b5f615595565b64ffffffffff600f5460601c916bffffffffffffffffffffffff604051947fec4a7bbd0000000000000000000000000000000000000000000000000000000060208701526004356024870152166044850152166064830152606482526103ad608483614bea565b346103d85760406003193601126103d857602435600435610be5615529565b8015610c2257808210610bfa57601c55601d55005b7f73ab65c2000000000000000000000000000000000000000000000000000000005f5260045ffd5b7fda1eeb9f000000000000000000000000000000000000000000000000000000005f5260045ffd5b346103d85760406003193601126103d85760043567ffffffffffffffff81116103d857610c7b90369060040161493a565b610c83614a7f565b90610c8c615595565b73ffffffffffffffffffffffffffffffffffffffff6012541691604051937fdada9004000000000000000000000000000000000000000000000000000000006020860152826064860160406024880152526084850160848460051b87010193825f907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff4181360301935b838310610d66576103b28a8a6103ad828c6bffffffffffffffffffffffff8d166044830152037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101845283614bea565b9091929394967fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7c8a82030182528735868112156103d8576020610dfc60019360c0610dec8885960180358452610dc0868501878301614e8b565b6060810135606085015264ffffffffff610ddc60808301614b70565b16608085015260a0810190614f48565b9190928160a08201520191614f0a565b9901920193019190949392610d15565b346103d8575f6003193601126103d8576020601d54604051908152f35b346103d85760206003193601126103d85760043567ffffffffffffffff81116103d857610e5d6103b291369060040161493a565b610e65615595565b6103ad73ffffffffffffffffffffffffffffffffffffffff60105416916107796040519485927fd58d360c000000000000000000000000000000000000000000000000000000006020850152602060248501526044840191614d4e565b60606003193601126103d85760043567ffffffffffffffff81116103d857610eee90369060040161493a565b6024359167ffffffffffffffff83116103d857366023840112156103d857826004013567ffffffffffffffff81116103d8573660248260061b860101116103d85760443567ffffffffffffffff81116103d857610f4f90369060040161493a565b91610f58615595565b60246020610f9f600f5460601c96604051987fd1449f8a00000000000000000000000000000000000000000000000000000000848b01526060858b015260848a0191614d4e565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc888203016044890152838152019601905f5b81811061101857505050610779856103ad9386937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc856103b29a03016064860152614dd9565b9091966040808261102b6001948c614e8b565b019801929101610fd2565b346103d85760a06003193601126103d85760043564ffffffffff81168091036103d8576bffffffffffffffffffffffff9061106f614b34565b611077614b5c565b6effffffffff0000000000000000000061108f614b0c565b9269ffffffffff00000000007fffffffffffffffffffffffff0000000000ffffffffffffffffffffffffffffff6110c4614a49565b966110cd615529565b7fffffffffffffffffffffffffffffffffff00000000000000000000000000000073ffffffffff000000000000000000000000000000600d549860781b16971617169160281b16179160501b161717600d55166107d081116103d8577fffffffffffffffffffffffffffffffffffffffff000000000000000000000000600b541617600b555f80f35b346103d85773ffffffffffffffffffffffffffffffffffffffff61117936614cb7565b929091165f52602460205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f5260205260405f20905f52602052602060405f2054604051908152f35b346103d8575f6003193601126103d8576020601c54604051908152f35b346103d85760206003193601126103d8576004356111f6615529565b6103e881116103d8576020817f691d3fd9719e0e55da4b2e6511050f281cd825da1e96eec223845fc764f1ab1d92600355604051908152a1005b346103d85760206003193601126103d85760043567ffffffffffffffff81116103d8576112646103b291369060040161493a565b61126c615595565b6103ad600f5460601c916107796040519485927fc0740340000000000000000000000000000000000000000000000000000000006020850152602060248501526044840191614d4e565b60c06003193601126103d8576112ca614824565b6112d2614b5c565b606435906bffffffffffffffffffffffff82168092036103d8576112f4614b20565b60a4359367ffffffffffffffff85116103d85761077973ffffffffffffffffffffffffffffffffffffffff946103ad9364ffffffffff61133b6103b2993690600401614b82565b929093611346615595565b828a60105416996040519b8c997fb8f22d880000000000000000000000000000000000000000000000000000000060208c01521660248a015260243560448a015216606488015260848701521660a485015260c060c485015260e4840191614f0a565b346103d8575f6003193601126103d8576114086040516113ca604082614bea565b600581527f352e302e300000000000000000000000000000000000000000000000000000006020820152604051918291602083526020830190614d0b565b0390f35b346103d85760a06003193601126103d857608435606435604435602435600435611434615529565b8015610c2257818111610bfa576006556007558015610c2257828111610bfa578115610c2257828211610bfa57600855600955600a55005b346103d85760206003193601126103d85760043567ffffffffffffffff81116103d8576114a06103b291369060040161493a565b6114a8615595565b6103ad73ffffffffffffffffffffffffffffffffffffffff60105416916107796040519485927f9ef305d6000000000000000000000000000000000000000000000000000000006020850152602060248501526044840191614d4e565b346103d85760206003193601126103d857610019611521614824565b73ffffffffffffffffffffffffffffffffffffffff6015541673ffffffffffffffffffffffffffffffffffffffff604051927f981cadf5000000000000000000000000000000000000000000000000000000006020850152166024830152602482526103ad604483614bea565b60c06003193601126103d8576103b26115a5614847565b6115ad614b0c565b64ffffffffff6115bb614a49565b6bffffffffffffffffffffffff6115d0614b48565b916115d9615595565b8373ffffffffffffffffffffffffffffffffffffffff601054169573ffffffffffffffffffffffffffffffffffffffff604051987f8ec1c4c70000000000000000000000000000000000000000000000000000000060208b015260043560248b015216604489015260443560648901521660848701521660a48501521660c483015260c482526103ad60e483614bea565b346103d8575f6003193601126103d857602073ffffffffffffffffffffffffffffffffffffffff7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005416604051908152f35b346103d85760206003193601126103d8576116d5615255565b506116de615255565b506004355f525f60205260405f20805473ffffffffffffffffffffffffffffffffffffffff811691821561197f5760018101549260028201549160048101549360038201549160050154926040519261173684614bcd565b8184526020840197885260408401928660c81c64ffffffffff168452606085019060a01c81526080850173ffffffffffffffffffffffffffffffffffffffff8816815260a086018860081b7f0200000000000000000000000000000000000000000000000000000000000000167f020000000000000000000000000000000000000000000000000000000000000014815260c08701918a60a01c64ffffffffff16835260e08801938560a01c855261010089019573ffffffffffffffffffffffffffffffffffffffff1686526101208901968c60c81c60ff16151588526101408a01988d60d01c60ff1615158a526101608b019a73ffffffffffffffffffffffffffffffffffffffff8d168c5261018081019c60a01c61ffff168d526101a08101809e60a01c64ffffffffff1690526101c00173ffffffffffffffffffffffffffffffffffffffff819f1690526040519e8f9283525160208301525164ffffffffff169060400152516bffffffffffffffffffffffff1660608d01525173ffffffffffffffffffffffffffffffffffffffff1660808c015251151560a08b01525164ffffffffff1660c08a0152516bffffffffffffffffffffffff1660e08901525173ffffffffffffffffffffffffffffffffffffffff166101008801525115156101208701525115156101408601525173ffffffffffffffffffffffffffffffffffffffff166101608501525161ffff166101808401525164ffffffffff166101a08301525173ffffffffffffffffffffffffffffffffffffffff166101c08201526101e090f35b7f6b559eca000000000000000000000000000000000000000000000000000000005f5260045ffd5b346103d85760206003193601126103d8576004358015158091036103d8576119cd615529565b7fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff74ff00000000000000000000000000000000000000006005549260a01b169116176005555f80f35b60e06003193601126103d85760043567ffffffffffffffff81116103d857611a4290369060040161493a565b90611a4b614ace565b91611a5461486a565b9260643567ffffffffffffffff81116103d857611a7590369060040161493a565b91611a7e614aed565b91611a87614b48565b9060c43567ffffffffffffffff81116103d857611aa8903690600401614b82565b93909560155473ffffffffffffffffffffffffffffffffffffffff1699604051998a9960208b017f85ca7e3a00000000000000000000000000000000000000000000000000000000905260248b0160e090526101048b0190611b099261515c565b926fffffffffffffffffffffffffffffffff1660448a015273ffffffffffffffffffffffffffffffffffffffff1660648901528782037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc016084890152611b6f9261515c565b926fffffffffffffffffffffffffffffffff1660a486015264ffffffffff1660c48501528382037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc0160e4850152611bc692614f0a565b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081018252611bf69082614bea565b61001991615638565b346103d8575f6003193601126103d8576020600954604051908152f35b346103d85773ffffffffffffffffffffffffffffffffffffffff611c3f36614cb7565b929091165f52601e60205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f5260205260405f20905f52602052602060405f2054604051908152f35b346103d8575f6003193601126103d857602064ffffffffff600d5460501c16604051908152f35b346103d85760c06003193601126103d85760407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc3601126103d857611ced614b0c565b60843567ffffffffffffffff81116103d8576103b2916103ad611d1a64ffffffffff933690600401614b82565b92906bffffffffffffffffffffffff611dae611d34614a64565b92611d3d615595565b73ffffffffffffffffffffffffffffffffffffffff60125416966040519889967f7ab9b2320000000000000000000000000000000000000000000000000000000060208901526004356024890152611d9760448901614e5e565b16608487015260c060a487015260e4860191614f0a565b911660c4830152037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101845283614bea565b346103d85760406003193601126103d85760043567ffffffffffffffff81116103d857611e1290369060040161493a565b906024359167ffffffffffffffff83116103d8576103ad61077991611e3e6103b295369060040161493a565b9390611e48615595565b600f5460601c94611e8f6040519788957f71d0bcf4000000000000000000000000000000000000000000000000000000006020880152604060248801526064870191614d4e565b917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc858403016044860152614e18565b346103d8575f6003193601126103d857611ed7615529565b5f73ffffffffffffffffffffffffffffffffffffffff7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300547fffffffffffffffffffffffff000000000000000000000000000000000000000081167f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b60c06003193601126103d85760407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc3601126103d8576103b2611fbc614b0c565b611fc4614a49565b64ffffffffff611fd2614b48565b611fda615595565b6bffffffffffffffffffffffff73ffffffffffffffffffffffffffffffffffffffff601054169383604051967f70ba9ae7000000000000000000000000000000000000000000000000000000006020890152600435602489015261204060448901614e5e565b1660848701521660a48501521660c483015260c482526103ad60e483614bea565b346103d8575f6003193601126103d8576020600754604051908152f35b346103d8575f6003193601126103d85760206bffffffffffffffffffffffff600f5416604051908152f35b346103d8575f6003193601126103d85760206fffffffffffffffffffffffffffffffff60255416604051908152f35b346103d85760206003193601126103d8576004356fffffffffffffffffffffffffffffffff811681036103d85761001990612111615529565b615665565b6101a06003193601126103d85761212b614824565b612133614a9a565b9061213c614b0c565b90612145614b20565b61214d614c9b565b60c435938415158095036103d85760e4358015158091036103d857610104358015158091036103d85761012435918215158093036103d8576101443567ffffffffffffffff81116103d8576121a6903690600401614b82565b989095610164359773ffffffffffffffffffffffffffffffffffffffff89168099036103d857610184359761ffff89168099036103d8576121e5615595565b6040519a6101a08c018c811067ffffffffffffffff8211176123e15760405273ffffffffffffffffffffffffffffffffffffffff168b5260208b019b6024358d5260408c016bffffffffffffffffffffffff819f16905260608c019864ffffffffff16895260808c019264ffffffffff16835260a08c01931515845260c08c0194855260e08c019586526101008c019687526101208c01978852369061228a92614c65565b966101408b019788526101608b01998a526101808b0198895260135473ffffffffffffffffffffffffffffffffffffffff169c6040519c8d809d602082017feefb986c00000000000000000000000000000000000000000000000000000000905260248201602090525173ffffffffffffffffffffffffffffffffffffffff1690604401525160648d0152516bffffffffffffffffffffffff1660848c01525164ffffffffff1660a48b01525164ffffffffff1660c48a015251151560e48901525115156101048801525115156101248701525115156101448601525115156101648501525161018484016101a090526101e4840161238891614d0b565b915173ffffffffffffffffffffffffffffffffffffffff166101a48401525161ffff166101c4830152037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0810182526109899082614bea565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b346103d85760406003193601126103d857612427614824565b73ffffffffffffffffffffffffffffffffffffffff612444614847565b91165f52601f60205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f52602052602060405f2054604051908152f35b6124853661496b565b96919493929590979a9998612498615595565b60105473ffffffffffffffffffffffffffffffffffffffff169b6040519b8c9b60208d017f57664b9700000000000000000000000000000000000000000000000000000000905260248d0160c0905260e48d01906124f592614d8b565b908b82037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc0160448d015261252992614d4e565b908982037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc0160648b015261255d92614dd9565b908782037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc01608489015261259192614e18565b908582037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc0160a48701526125c592614dd9565b908382037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc0160c485015261095992614f98565b346103d8575f6003193601126103d8576020600654604051908152f35b60c06003193601126103d85760043567ffffffffffffffff81116103d85761264290369060040161493a565b9061264b614ace565b9161265461486a565b9260643567ffffffffffffffff81116103d85761267590369060040161493a565b9061267e614aed565b92612687614c9b565b9260155473ffffffffffffffffffffffffffffffffffffffff1697604051978897602089017f561ffcc30000000000000000000000000000000000000000000000000000000090526024890160c0905260e48901906126e59261515c565b926fffffffffffffffffffffffffffffffff16604488015273ffffffffffffffffffffffffffffffffffffffff1660648701528582037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc01608487015261274b9261515c565b916fffffffffffffffffffffffffffffffff1660a4840152151560c4830152037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081018252611bf69082614bea565b60206003193601126103d85760043567ffffffffffffffff81116103d8576127c690369060040161493a565b906127cf615595565b73ffffffffffffffffffffffffffffffffffffffff6013541691604051917f54b0fe99000000000000000000000000000000000000000000000000000000006020840152816044840160206024860152526064830160648360051b85010192825f907ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe6181360301935b838310612895576103b2888a6103ad828b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101845283614bea565b9091929394957fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9c8882030182528635868112156103d85760206128dd60019386839401615015565b9801920193019190949392612858565b346103d8575f6003193601126103d8576020600854604051908152f35b346103d8575f6003193601126103d85773ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000b8535db7f7652da3e2b9bec877f385a6cf9dfe261630036129815760206040517f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8152f35b7fe07c8dba000000000000000000000000000000000000000000000000000000005f5260045ffd5b346103d85760406003193601126103d8576129c2614824565b73ffffffffffffffffffffffffffffffffffffffff6129df614847565b91165f526020805273ffffffffffffffffffffffffffffffffffffffff60405f2091165f52602052602060405f2054604051908152f35b346103d85760406003193601126103d8576103b2612a32614b34565b612a3a615595565b600f5460601c64ffffffffff604051927f4fa0d4600000000000000000000000000000000000000000000000000000000060208501526004356024850152166044830152604482526103ad606483614bea565b60806003193601126103d85760407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc3601126103d8576103b2612ace614b0c565b612ad6615595565b600f5460601c64ffffffffff604051927f4f75081b0000000000000000000000000000000000000000000000000000000060208501526004356024850152612b2060448501614e5e565b166084830152608482526103ad60a483614bea565b60406003193601126103d857612b49614824565b60243567ffffffffffffffff81116103d857366023820112156103d857612b7a903690602481600401359101614c65565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000b8535db7f7652da3e2b9bec877f385a6cf9dfe2616803014908115612de5575b5061298157612bc9615529565b73ffffffffffffffffffffffffffffffffffffffff8216916040517f52d1902d000000000000000000000000000000000000000000000000000000008152602081600481875afa5f9181612db1575b50612c4957837f4c9c8ce3000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc859203612d865750813b15612d5b57807fffffffffffffffffffffffff00000000000000000000000000000000000000007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5416177f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b5f80a2815115612d2a575f8083602061001995519101845af4612d24615609565b91615790565b505034612d3357005b7fb398979f000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f4c9c8ce3000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b7faa1d49a4000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b9091506020813d602011612ddd575b81612dcd60209383614bea565b810103126103d857519085612c18565b3d9150612dc0565b905073ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5416141583612bbc565b612e9e60e4612e353661496b565b9c90999a612e4b99929895969499979397615595565b73ffffffffffffffffffffffffffffffffffffffff601054169b6040519d8e7f4e8b56ae00000000000000000000000000000000000000000000000000000000602082015260c060248201520191614d8b565b937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc8c86030160448d0152808552602085019460208260051b82010195835f925b8484106130d4575050505050509082917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc8b612f2195030160648c0152614dd9565b937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc888603016084890152808552602085019460208260051b82010195835f925b848410613078575050505050509082917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc87612fa495030160a4880152614dd9565b937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc8486030160c4850152808552602085019460208260051b82010195835f925b848410613022576103b288886103ad828d037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101845283614bea565b909192939497602080613068837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe086600196030188526130628d88614eb7565b90614f98565b9a01940194019294939190612fe5565b9091929394976020806130c19b9e9b837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe086600196030188526130bb8d88614eb7565b90614e18565b9a019401940192949391909b989b612f62565b9091929394979c9f9c6020806131209b9e9b837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0866001960301885261311a8d88614eb7565b90614d4e565b9a019401940192949391909f9c9f9b989b612edf565b346103d8575f6003193601126103d857602064ffffffffff600d5416604051908152f35b346103d85760206003193601126103d8575f61012060405161317b81614bb0565b82815282602082015282604082015282606082015260606080820152606060a0820152606060c08201528260e08201528261010082015201526004355f52601860205260405f206040516131ce81614bb0565b81549073ffffffffffffffffffffffffffffffffffffffff82168152602081019164ffffffffff8160a01c168352604082019065ffffffffffff8160c81c16825260f81c93606083019460058110156134c657855260018101604051808260208294549384815201905f5260205f20925f5b81811061357d57505061325592500382614bea565b6080840190815260028201604051808260208294549384815201905f5260205f20925f5b81811061356457505061328e92500382614bea565b60a085019081526003830191604051808460208296549384815201905f5260205f20925f905b80600183011061352e576132da94549181811061350f575b106134f3575b500384614bea565b60c0860192835260048401549765ffffffffffff600560e089019673ffffffffffffffffffffffffffffffffffffffff8c1688526101008a019b60a01c8c52015496610120890197885264ffffffffff6040519a60208c5273ffffffffffffffffffffffffffffffffffffffff6101608d019b511660208d0152511660408b0152511660608901525160058110156134c6576080880152519461014060a08801528551809152602061018088019601905f5b81811061349a5750505051937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08682030160c0870152602080865192838152019501905f5b8181106134845750505051927fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08582030160e0860152602080855192838152019401905f5b81811061346057505050839473ffffffffffffffffffffffffffffffffffffffff6bffffffffffffffffffffffff9251166101008601525116610120840152516101408301520390f35b82516bffffffffffffffffffffffff16865260209586019590920191600101613416565b82518752602096870196909201916001016133d1565b825173ffffffffffffffffffffffffffffffffffffffff1688526020978801979092019160010161338c565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b60601c6bffffffffffffffffffffffff1681526020018b6132d2565b9260206001916bffffffffffffffffffffffff851681520193016132cc565b91600291935060406001916bffffffffffffffffffffffff8754818116835260601c1660208201520194019201869293916132b4565b8454835260019485019486945060209093019201613279565b845473ffffffffffffffffffffffffffffffffffffffff16835260019485019486945060209093019201613240565b346103d85760e06003193601126103d85773ffffffffffffffffffffffffffffffffffffffff6135da614824565b816135e3614847565b816135ec61486a565b816135f561488d565b816135fe6148b0565b93816136086148d3565b976136116148f6565b9a61361a615529565b6bffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffff000000000000000000000000600f549260601b16911617600f55167fffffffffffffffffffffffff00000000000000000000000000000000000000006010541617601055167fffffffffffffffffffffffff00000000000000000000000000000000000000006011541617601155167fffffffffffffffffffffffff00000000000000000000000000000000000000006012541617601255167fffffffffffffffffffffffff00000000000000000000000000000000000000006013541617601355167fffffffffffffffffffffffff00000000000000000000000000000000000000006014541617601455167fffffffffffffffffffffffff000000000000000000000000000000000000000060155416176015555f80f35b346103d85760206003193601126103d85773ffffffffffffffffffffffffffffffffffffffff613784614824565b165f52601b602052602060405f2054604051908152f35b346103d85760806003193601126103d85760043567ffffffffffffffff81116103d8576137cc90369060040161493a565b6137d461486a565b60643567ffffffffffffffff81116103d8576137f4903690600401614b82565b906137fd615595565b73ffffffffffffffffffffffffffffffffffffffff6014541692604051947f3574abaf0000000000000000000000000000000000000000000000000000000060208701528060a48701608060248901525260c486019060c48160051b8801019780925f907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8183360301905b8483106138f35750506103b289896103ad826107798f8d8d73ffffffffffffffffffffffffffffffffffffffff8e60243560448801521660648601527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc858403016084860152614f0a565b90919293949a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff3c8b82030182528b3590838212156103d8576020809187600194019073ffffffffffffffffffffffffffffffffffffffff61395383614919565b168152606073ffffffffffffffffffffffffffffffffffffffff6139b5826139ae61399361398389890189614eb7565b60808b8a01526080890191614d4e565b6139a06040890189614eb7565b9088830360408a0152614d4e565b9501614919565b169101529d01920193019190949392613888565b346103d8575f6003193601126103d857602064ffffffffff600d5460281c16604051908152f35b346103d85760206003193601126103d857613a09615595565b6103b2600f5460601c604051907f305a67a80000000000000000000000000000000000000000000000000000000060208301526004356024830152602482526103ad604483614bea565b346103d85760406003193601126103d8576103b2613a6f614a7f565b613a77615595565b600f5460601c6bffffffffffffffffffffffff604051927f23c798570000000000000000000000000000000000000000000000000000000060208501526004356024850152166044830152604482526103ad606483614bea565b346103d85760206003193601126103d857600435613aed615529565b80156103d857601a55005b346103d8575f6003193601126103d8576020601954604051908152f35b346103d8575f6003193601126103d857602064ffffffffff600d5460781c16604051908152f35b346103d85760c06003193601126103d85760407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbc3601126103d857613b7f614b20565b613b87614a64565b90613b90615595565b73ffffffffffffffffffffffffffffffffffffffff60125416604051917f19ea3758000000000000000000000000000000000000000000000000000000006020840152600435602484015260243560448401526044359373ffffffffffffffffffffffffffffffffffffffff85168095036103d85764ffffffffff6bffffffffffffffffffffffff926103b296606487015260643560848701521660a48501521660c483015260c482526103ad60e483614bea565b60a06003193601126103d85760407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc3601126103d8576103b2613c86614b0c565b613c8e614a49565b613c96615595565b6bffffffffffffffffffffffff73ffffffffffffffffffffffffffffffffffffffff601154169164ffffffffff604051947f192d1e4f0000000000000000000000000000000000000000000000000000000060208701526004356024870152613d0160448701614e5e565b1660848501521660a483015260a482526103ad60c483614bea565b346103d8576102006003193601126103d857613d36614824565b60a052613d41614847565b61020052613d4d61486a565b613d5561488d565b60e052613d606148b0565b61010052613d6c6148d3565b61012052613d786148f6565b6101405260e43561016081905273ffffffffffffffffffffffffffffffffffffffff811690036103d8576101043561018081905273ffffffffffffffffffffffffffffffffffffffff811690036103d857610124356101a081905273ffffffffffffffffffffffffffffffffffffffff811690036103d8576101443560c081905273ffffffffffffffffffffffffffffffffffffffff811690036103d857610164356101e08190526bffffffffffffffffffffffff811690036103d8576101843573ffffffffffffffffffffffffffffffffffffffff811681036103d8576101a435608081905273ffffffffffffffffffffffffffffffffffffffff811690036103d8576101c4356101c08190526fffffffffffffffffffffffffffffffff811690036103d8577ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00546102205267ffffffffffffffff61022051161580614572575b600167ffffffffffffffff6102205116149081614568575b15908161455f575b506145375773ffffffffffffffffffffffffffffffffffffffff809260017fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000006102205116177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005560ff6102205160401c16156144df575b613f79615739565b613f81615739565b613f8a336152c2565b613f92615739565b613f9a615739565b167fffffffffffffffffffffffff00000000000000000000000000000000000000006023541617602355167fffffffffffffffffffffffff0000000000000000000000000000000000000000600154161760015573ffffffffffffffffffffffffffffffffffffffff608051167fffffffffffffffffffffffff0000000000000000000000000000000000000000600254161760025573ffffffffffffffffffffffffffffffffffffffff60a051167fffffffffffffffffffffffff000000000000000000000000000000000000000060055416176005556101e435600c5573ffffffffffffffffffffffffffffffffffffffff60c051167fffffffffffffffffffffffff00000000000000000000000000000000000000006022541617602255600f546bffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000060e05160601b16911617600f5573ffffffffffffffffffffffffffffffffffffffff61010051167fffffffffffffffffffffffff0000000000000000000000000000000000000000601054161760105573ffffffffffffffffffffffffffffffffffffffff61012051167fffffffffffffffffffffffff0000000000000000000000000000000000000000601154161760115573ffffffffffffffffffffffffffffffffffffffff61014051167fffffffffffffffffffffffff0000000000000000000000000000000000000000601254161760125573ffffffffffffffffffffffffffffffffffffffff61016051167fffffffffffffffffffffffff0000000000000000000000000000000000000000601354161760135573ffffffffffffffffffffffffffffffffffffffff61018051167fffffffffffffffffffffffff0000000000000000000000000000000000000000601454161760145573ffffffffffffffffffffffffffffffffffffffff6101a051167fffffffffffffffffffffffff000000000000000000000000000000000000000060155416176015556142976101c051615665565b6142a36101e0516156d4565b73ffffffffffffffffffffffffffffffffffffffff61020051167fffffffffffffffffffffffff000000000000000000000000000000000000000060045416176004556102ee6003557f691d3fd9719e0e55da4b2e6511050f281cd825da1e96eec223845fc764f1ab1d60206040516102ee8152a1620f4240600e557fbb7fa123c781240f4b78e7ab060f5cc8a2faa2b374559c0aea0c7bbf3d7c7b506020604051620f42408152a1740100000000000000000000000000000000000000007fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff600554161760055562015180600655630107ac0060075561070860085561012c60095562093a80600a556f3c00000000b400000000000000000000653c00000002587fffffffffffffffffffffffff0000000000000000000000000000000000000000600d54161717600d5560647fffffffffffffffffffffffffffffffffffffffff000000000000000000000000600b541617600b556203d090600e5560016019556103e8601a5562015180601c55630107ac00601d5560ff6102205160401c161561444c57005b7fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054167ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00557fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2602060405160018152a1005b680100000000000000017fffffffffffffffffffffffffffffffffffffffffffffff0000000000000000006102205116177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0055613f71565b7ff92ee8a9000000000000000000000000000000000000000000000000000000005f5260045ffd5b90501583613efa565b303b159150613ef2565b5060ff6102205160401c1615613eda565b346103d85760406003193601126103d85761459c614824565b73ffffffffffffffffffffffffffffffffffffffff6145b9614847565b916145c2615529565b169081156103d85773ffffffffffffffffffffffffffffffffffffffff169081156103d8577fffffffffffffffffffffffff000000000000000000000000000000000000000060015416176001557fffffffffffffffffffffffff000000000000000000000000000000000000000060025416176002555f80f35b6146463661496b565b96919493929590979a9998614659615595565b60105473ffffffffffffffffffffffffffffffffffffffff169b6040519b8c9b60208d017fc0d2644c00000000000000000000000000000000000000000000000000000000905260248d0160c0905260e48d01906146b692614d4e565b908b82037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc0160448d01526146ea92614d8b565b908982037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc0160648b015261471e92614d4e565b908782037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc01608489015261475292614dd9565b908582037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc0160a487015261478692614e18565b908382037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc0160c485015261095992614dd9565b346103d85760206003193601126103d85773ffffffffffffffffffffffffffffffffffffffff6147e8614824565b6147f0615529565b1680156103d8577fffffffffffffffffffffffff000000000000000000000000000000000000000060225416176022555f80f35b6004359073ffffffffffffffffffffffffffffffffffffffff821682036103d857565b6024359073ffffffffffffffffffffffffffffffffffffffff821682036103d857565b6044359073ffffffffffffffffffffffffffffffffffffffff821682036103d857565b6064359073ffffffffffffffffffffffffffffffffffffffff821682036103d857565b6084359073ffffffffffffffffffffffffffffffffffffffff821682036103d857565b60a4359073ffffffffffffffffffffffffffffffffffffffff821682036103d857565b60c4359073ffffffffffffffffffffffffffffffffffffffff821682036103d857565b359073ffffffffffffffffffffffffffffffffffffffff821682036103d857565b9181601f840112156103d85782359167ffffffffffffffff83116103d8576020808501948460051b0101116103d857565b60c06003198201126103d85760043567ffffffffffffffff81116103d857816149969160040161493a565b9290929160243567ffffffffffffffff81116103d857816149b99160040161493a565b9290929160443567ffffffffffffffff81116103d857816149dc9160040161493a565b9290929160643567ffffffffffffffff81116103d857816149ff9160040161493a565b9290929160843567ffffffffffffffff81116103d85781614a229160040161493a565b9290929160a4359067ffffffffffffffff82116103d857614a459160040161493a565b9091565b608435906bffffffffffffffffffffffff821682036103d857565b60a435906bffffffffffffffffffffffff821682036103d857565b602435906bffffffffffffffffffffffff821682036103d857565b604435906bffffffffffffffffffffffff821682036103d857565b35906bffffffffffffffffffffffff821682036103d857565b602435906fffffffffffffffffffffffffffffffff821682036103d857565b608435906fffffffffffffffffffffffffffffffff821682036103d857565b6064359064ffffffffff821682036103d857565b6084359064ffffffffff821682036103d857565b6024359064ffffffffff821682036103d857565b60a4359064ffffffffff821682036103d857565b6044359064ffffffffff821682036103d857565b359064ffffffffff821682036103d857565b9181601f840112156103d85782359167ffffffffffffffff83116103d857602083818601950101116103d857565b610140810190811067ffffffffffffffff8211176123e157604052565b6101e0810190811067ffffffffffffffff8211176123e157604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff8211176123e157604052565b67ffffffffffffffff81116123e157601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b929192614c7182614c2b565b91614c7f6040519384614bea565b8294818452818301116103d8578281602093845f960137010152565b60a4359081151582036103d857565b359081151582036103d857565b60031960609101126103d85760043573ffffffffffffffffffffffffffffffffffffffff811681036103d8579060243573ffffffffffffffffffffffffffffffffffffffff811681036103d8579060443590565b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f602080948051918291828752018686015e5f8582860101520116010190565b90918281527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83116103d85760209260051b809284830137010190565b916020908281520191905f5b818110614da45750505090565b90919260208060019273ffffffffffffffffffffffffffffffffffffffff614dcb88614919565b168152019401929101614d97565b916020908281520191905f5b818110614df25750505090565b90919260208060019264ffffffffff614e0a88614b70565b168152019401929101614de5565b916020908281520191905f5b818110614e315750505090565b9091926020806001926bffffffffffffffffffffffff614e5088614ab5565b168152019401929101614e24565b60243573ffffffffffffffffffffffffffffffffffffffff81168091036103d85781526020604435910152565b6020809173ffffffffffffffffffffffffffffffffffffffff614ead82614919565b1684520135910152565b90357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1823603018112156103d857016020813591019167ffffffffffffffff82116103d8578160051b360383136103d857565b601f82602094937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe093818652868601375f8582860101520116010190565b90357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1823603018112156103d857016020813591019167ffffffffffffffff82116103d85781360383136103d857565b90602083828152019260208260051b82010193835f925b848410614fbf5750505050505090565b909192939495602080615005837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08660019603018852614fff8b88614f48565b90614f0a565b9801940194019294939190614faf565b9073ffffffffffffffffffffffffffffffffffffffff61503483614919565b168152602082013560208201526bffffffffffffffffffffffff61505a60408401614ab5565b16604082015264ffffffffff61507260608401614b70565b16606082015264ffffffffff61508a60808401614b70565b16608082015261509c60a08301614caa565b151560a08201526150af60c08301614caa565b151560c08201526150c260e08301614caa565b151560e08201526150d66101008301614caa565b15156101008201526150eb6101208301614caa565b151561012082015261018061511b615107610140850185614f48565b6101a06101408601526101a0850191614f0a565b9273ffffffffffffffffffffffffffffffffffffffff61513e6101608301614919565b1661016084015201359061ffff82168092036103d857610180015290565b90602083828152019060208160051b85010193835f915b8383106151835750505050505090565b9091929394957fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe082820301865286357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa1843603018112156103d8576020615247600193868394019073ffffffffffffffffffffffffffffffffffffffff61520983614919565b16815261523961522e61521e86850185614eb7565b6060888601526060850191614d4e565b926040810190614eb7565b916040818503910152614d4e565b980196019493019190615173565b6040519061526282614bcd565b5f6101c0838281528260208201528260408201528260608201528260808201528260a08201528260c08201528260e08201528261010082015282610120820152826101408201528261016082015282610180820152826101a08201520152565b73ffffffffffffffffffffffffffffffffffffffff1680156153835773ffffffffffffffffffffffffffffffffffffffff7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930054827fffffffffffffffffffffffff00000000000000000000000000000000000000008216177f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3565b7f1e4fbdf7000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b5f525f60205260405f207f020000000000000000000000000000000000000000000000000000000000000080600283015460081b16146153ee57505f90565b6003815460a01c91015460a01c6bffffffffffffffffffffffff600b541690604051927f66ad086d00000000000000000000000000000000000000000000000000000000845260048401526024830152604482015260208160648173e0cb467a1a46d29682332e0ba8099aee26dee6205af49081156154b5575f91615471575090565b90506020813d6020116154ad575b8161548c60209383614bea565b810103126103d857516bffffffffffffffffffffffff811681036103d85790565b3d915061547f565b6040513d5f823e3d90fd5b67ffffffffffffffff81116123e15760051b60200190565b91908110156154e85760051b0190565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b80518210156154e85760209160051b010190565b73ffffffffffffffffffffffffffffffffffffffff7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005416330361556957565b7f118cdaa7000000000000000000000000000000000000000000000000000000005f523360045260245ffd5b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005c6155e15760017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005d565b7f3ee5aeb5000000000000000000000000000000000000000000000000000000005f5260045ffd5b3d15615633573d9061561a82614c2b565b916156286040519384614bea565b82523d5f602084013e565b606090565b5f918291602082519201905af49061564e615609565b911561565657565b5080519081156103d857602001fd5b60406fffffffffffffffffffffffffffffffff7f7bd04e80b87f9d29d31456e209784930c75d2a834480768ca06d10d4483449709216807fffffffffffffffffffffffffffffffff000000000000000000000000000000006025541617602555815190600882526020820152a1565b60206bffffffffffffffffffffffff7f6d4357a1ed4a9686bb163d10abedf9d8787f955e3906001d40d62bb9aad8e9e89216807fffffffffffffffffffffffffffffffffffffffff000000000000000000000000600f541617600f55604051908152a1565b60ff7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460401c161561576857565b7fd7e6bcf8000000000000000000000000000000000000000000000000000000005f5260045ffd5b906157cd57508051156157a557805190602001fd5b7fd6bda275000000000000000000000000000000000000000000000000000000005f5260045ffd5b81511580615820575b6157de575090565b73ffffffffffffffffffffffffffffffffffffffff907f9996b315000000000000000000000000000000000000000000000000000000005f521660045260245ffd5b50803b156157d656fea2646970667358221220f130bf6982307e99d516777ad38922d57e0e1a90851a3178818b416126cba1e864736f6c634300081c0033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.