Feature Tip: Add private address tag to any address under My Name Tag !
Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
TokenTracker
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Become Implement... | 20679051 | 114 days ago | IN | 0 ETH | 0.00027235 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
NftIndex
Compiler Version
v0.8.26+commit.8a97fa7a
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.26; import "contracts/token/ERC20/extensions/ERC20Permit.sol"; import "contracts/token/ERC20/utils/SafeERC20.sol"; import "contracts/src/v0.8/vrf/dev/libraries/VRFV2PlusClient.sol"; import "contracts/utils/structs/EnumerableSet.sol"; import "contracts/access/AccessControl.sol"; import "contracts/proxies/Upgradeable2Step.sol"; import "contracts/token/ERC721/IERC721.sol"; import "contracts/token/ERC721/IERC721Receiver.sol"; import "contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "contracts/libraries/NftIndexHelpers.sol"; import "contracts/protocol/NftIndexState.sol"; import "contracts/vrfUtils/VrfV2PlusConsumer.sol"; import "contracts/interfaces/INftIndex.sol"; import "contracts/staking/liqStaking/IsNftIndex.sol"; /** * @title Fungify Index Token - ERC20 * @notice All functions related to minting and burning of the Fungify NFT Index Token * @dev $NFT Index Token refered to as LIQ internally to avoid confusion with actual Non Fungible Tokens */ contract NftIndex is INftIndex, Upgradeable2Step, AccessControl, IERC721Receiver, ERC20Permit, VrfV2PlusConsumer, NftIndexState { using SafeERC20 for IERC20; using EnumerableSet for EnumerableSet.Bytes32Set; // Constants uint256 constant RATE = 1e18; uint256 constant MAX_UINT_TO_RATE = type(uint256).max / RATE; bytes32 public constant INTERNAL_ROLE = keccak256("INTERNAL_ROLE"); bytes32 public constant DEPOSITOR_ROLE = keccak256("DEPOSITOR_ROLE"); bytes32 public constant REDEEMER_ROLE = keccak256("REDEEMER_ROLE"); // Contract References address public immutable veFUNG; address public immutable liqStaking; /** * @notice The constructor initializing immutable variables * @param _veFUNG the address of the Fung staking contract * @param _liqStaking the address of the Liq staking contract * @param _vrfCoordinator the chainlink vrf coordinator address * @param _keyHash the keyhash for chainlinks vrf's gas lane * @param _callbackGasLimit the gas limit for chainlink vrf's callback * @param _requestConfirmations the amount of confirmations the vrf should perform * @param _subscriptionId the subscription id for vrf */ constructor(address _veFUNG, address _liqStaking, address _vrfCoordinator, bytes32 _keyHash, uint32 _callbackGasLimit, uint16 _requestConfirmations, uint256 _subscriptionId) ERC20Permit(name()) ERC20(name(), symbol()) { veFUNG = _veFUNG; liqStaking = _liqStaking; s_vrfCoordinator = IVRFCoordinatorV2Plus(_vrfCoordinator); keyHash = _keyHash; callbackGasLimit = _callbackGasLimit; requestConfirmations = _requestConfirmations; s_subscriptionId = _subscriptionId; } /** * @notice The initializer for storage variables * @param _oracle the address for the PriceOracle * @param nftsNeeded an array of how many nfts of a collection we need to have a vault incentive * @param incentives the corresponding array of vault incentives for each of the first array */ function initialize(PriceOracle _oracle, int[] calldata nftsNeeded, uint[] calldata incentives) public onlyOwner { if (_initialized == true) { revert AlreadyInitialized(); } _grantRole(INTERNAL_ROLE, msg.sender); depositWhitelist = true; redeemWhitelist = false; oracle = _oracle; // Sets the vault incentives, arrays should be same length setNftIncentives(nftsNeeded, incentives); initialLiqPerUsd = 1e17; // 1 LIQ = 10 USD redemptionBuffer = 102e16; // 102% minLINKBalance = 1e18; // 1 LINK depositFeeRate = 5e15; // 0.5% redemptionFeeRate = 5e15; // 0.5% veFungSpreadRate = 2e17; // 20% _initialized = true; } /** * @notice The name of the Fungify Index Token * @return the name */ function name() public view override returns (string memory) { return "Fungify NFT Index"; } /** * @notice The symbol for the Fungify Index Token * @return the symbol */ function symbol() public view override returns (string memory) { return "NFT"; } /** * @notice Adds an asset as a supported type to the Index * @param assetAddress The asset to be supported * @param assetType the type of asset (ERC721 or ERC20) * @param listedType type it should be listed as. (influences incentives and depositing) */ function addAsset(address assetAddress, SharedObjs.AssetType assetType, SharedObjs.ListedType listedType) external onlyRole(INTERNAL_ROLE) { if (assetAddress == address(0) || (assetType != SharedObjs.AssetType.ERC721 && assetType != SharedObjs.AssetType.ERC20)) { revert InvalidAsset(); } if (listedType == SharedObjs.ListedType.UNLISTED) { revert InvalidListedType(); } SharedObjs.IndexAsset storage asset = indexAssets[assetAddress]; if (asset.assetType != SharedObjs.AssetType.Undefined) { revert AssetExists(); } asset.assetType = assetType; asset.listedType = listedType; listedAssets.push(assetAddress); emit AddAsset(msg.sender, assetAddress, assetType, listedType); } /** * @notice Changes the type of listing an asset is classified as * @param assetAddress The asset to be changed * @param listedType type it should be listed as. (influences incentives and depositing) */ function changeAssetListing(address assetAddress, SharedObjs.ListedType listedType) external onlyRole(INTERNAL_ROLE) { SharedObjs.IndexAsset storage asset = indexAssets[assetAddress]; if (assetAddress == address(0) || asset.assetType == SharedObjs.AssetType.Undefined) { revert InvalidAsset(); } if (listedType == SharedObjs.ListedType.UNLISTED) { revert InvalidListedType(); } SharedObjs.ListedType _oldListedType = asset.listedType; asset.listedType = listedType; emit ChangeAssetListing(msg.sender, assetAddress, _oldListedType, listedType); } /** * @notice The asset to be removed from the listedAssets * @param assetAddress The asset to be removed * Requirements: * - None of the assets may be contained in the vault (Doing so would affect LIQ Price) */ function removeAsset(address assetAddress) external onlyRole(INTERNAL_ROLE) { SharedObjs.IndexAsset storage asset = indexAssets[assetAddress]; if (assetAddress == address(0) || asset.assetType == SharedObjs.AssetType.Undefined) { revert InvalidAsset(); } if (asset.size != 0 || asset.amount != 0) { revert NonEmptyAsset(); } assert(asset.totalVaultLiq == 0); asset.assetType = SharedObjs.AssetType.Undefined; asset.listedType = SharedObjs.ListedType.UNLISTED; // Finds asset's index in listedAssets uint256 assetIndex; uint256 listedAssetsLength = listedAssets.length; for (uint256 i; i < listedAssetsLength;) { if (assetAddress == listedAssets[i]) { assetIndex = i; } unchecked{ ++i; } } if (assetIndex == 0 && listedAssets[assetIndex] != assetAddress) { revert AssetNotFound(); } // Swap and pop address lastAsset = listedAssets[listedAssetsLength - 1]; listedAssets[assetIndex] = lastAsset; listedAssets.pop(); emit RemoveAsset(msg.sender, assetAddress); } // // Market Cap / Target Weight Functions // /** * @notice Gets the MarketCap of a given NftContract based on its totalSupply and chainlink floor price. * @param nftContract the contract to get the MarketCap for * @return usd summed floorVal of that contract. */ function nftContractMarketCap(address nftContract) public view returns(uint256) { // Get latestFloor from chainlink uint256 latestFloor = oracle.getAssetPrice(nftContract); // Calculate nftContractMarketCap by multiplying floor price by totalSupply of nfts in that contract return latestFloor * getERC721TokenSupply(nftContract); } /** * @notice Sums the market caps for all nft contracts that are listed as standard. * @return totalValue the summed total floor market cap of all standard listed contracts. */ function standardAssetMarketCap() public view returns (uint256 totalValue) { uint256 listedAssetsLength = listedAssets.length; // Running sum iterating through every nftContract which are listed as standard for (uint256 i; i < listedAssetsLength;) { // Only standard assets are used in this calculation if (indexAssets[listedAssets[i]].listedType == SharedObjs.ListedType.STANDARD) { uint256 vaultAssetValue = nftContractMarketCap(listedAssets[i]); totalValue += vaultAssetValue; } unchecked { ++i; } } } /** * @notice Returns the portion of the vault we'd expect a certain nftContract to be for an accurate index distribution. * @param nftContract the contract to get the target weight for * @return The target weight as a rate */ function nftContractTargetWeight(address nftContract, uint256 totalMarketCap) public view returns (uint256) { if (totalMarketCap == 0) { return 0; } else { return nftContractMarketCap(nftContract) * RATE / totalMarketCap; } } /** * @notice Gets the value in the vault of all assets listed as standard type * @return totalValue of standard assets in the vault in USD */ function totalStandardVaultValue() public view returns(uint256) { uint256 totalValue; uint256 listedAssetsLength = listedAssets.length; // Running sum iterating through every nftContract which are listed as standard for (uint256 i; i < listedAssetsLength;) { SharedObjs.IndexAsset memory asset = indexAssets[listedAssets[i]]; // Only standard assets are used in this calculation if (asset.listedType == SharedObjs.ListedType.STANDARD) { uint256 vaultAssetValue = assetWorkingVaultValue(listedAssets[i], asset); totalValue += vaultAssetValue; } unchecked { ++i; } } return totalValue; } /** * @notice Returns the summed Usd value to be of a specified nftContract in the vault. * @param nftContract the asset to be summed * @return vaultValue the summed Usd value of all assets of that collection in the vault */ function assetWorkingVaultValue(address nftContract, SharedObjs.IndexAsset memory asset) internal view returns(uint256 vaultValue) { // Uses chainlink and feed adapter to get the latest Usd floor price of the given collection uint256 latestFloorUsd = oracle.getAssetPrice(nftContract); // Multiplies that price by the vault count to get the sum. vaultValue = latestFloorUsd * asset.workingSize; } /** * @notice Calculates the number of nfts of the given nftContract needed to reach our desired target weight. * @param nftContract to get the number of nfts needed for * @return The number needed to reach our target weight, can be negative if overweight */ function _nftAssetsNeeded( address nftContract, uint256 floorPrice, uint256 totalMarketCap, SharedObjs.IndexAsset memory asset ) internal view returns (int) { /* Gets values needed for the calculation */ if (floorPrice == 0) { return 0; } uint256 targetWeight = nftContractTargetWeight(nftContract, totalMarketCap); if (targetWeight == RATE) { return 0; } // Multiplies that price by the vault count to get the sum. uint256 currentValue = floorPrice * asset.workingSize; // Naive target value, only considering current totalVaultFloorValue uint256 totalVaultFloorValue = totalStandardVaultValue(); uint256 targetValue = totalVaultFloorValue * targetWeight / RATE; /** * Step 1: * ASCII Art for the original equation: * * (assetVaultCount + nftsNeeded) * floorPrice * targetWeight = ------------------------------------------------------------ * totalVaultFloorValue + (nftsNeeded * floorPrice) * * * Step 2: * Solving for nftsNeeded. * * ASCII Art of intermediate equation: * * (floorPrice * assetVaultCount) - (totalVaultFloorValue * targetWeight) * nftsNeeded = -------------------------------------------------------------------------------------- * (floorPrice * targetWeight) - floorPrice * * Step 3: * Substitute currentValue = floorPrice * assetVaultCount * Substutute targetValue = totalVaultFloorValue * targetWeight * * ASCII Art for the implemented equation: * * currentValue - targetValue * nftsNeeded = ---------------------------------------- * (floorPrice * targetWeight) - floorPrice */ return (int(currentValue) - int(targetValue)) / ((int(floorPrice * targetWeight / RATE)) - int(floorPrice)); } /** * @notice Calculates the incentive rate for a given nftContract. * @dev Based on nftsNeeded from targetWeight based on MarketCaps * @param nftsNeeded number of nfts needed to return the incentive for * @return The incentive rate, over 100% is incentivized, under is decentivized. */ function nftsNeededToIncentiveRate(int256 nftsNeeded) public view returns (uint256) { if (nftsNeeded < lowestNftsNeeded) { return nftIncentives[lowestNftsNeeded]; } else if (nftsNeeded > highestNftsNeeded) { return nftIncentives[highestNftsNeeded]; } else { return nftIncentives[nftsNeeded]; } } /** * @notice Fetches the bytes 32 key for a particular nft * @param contractAddress the contract address of that nft * @param tokenId the tokenId for that particular nft * @return The key associated with the nft */ function _getNftKey(address contractAddress, uint256 tokenId) internal pure returns (bytes32) { return keccak256(abi.encodePacked(contractAddress, tokenId)); } /** * @notice Deposits an asset and mints the appropriate amount of NFT Index Token * @param assets an array of assets to be deposited */ function deposit(SharedObjs.Nft [] calldata assets, uint256 minimalAmount) external checkDepositWhitelist() { if(assets.length == 0) return; uint256 __totalMarketCap = standardAssetMarketCap(); uint256 __totalVaultValue = totalVaultValue(); uint256 totalLiqToMint; uint256 totalSellerMintCut; // Loops through all assets and deposits all respective nftIds for(uint256 i; i < assets.length;) { IERC721 nftContract = IERC721(assets[i].nftContract); uint256 tokenId = assets[i].tokenId; bytes32 key = _getNftKey(address(nftContract), tokenId); SharedObjs.IndexAsset storage asset = indexAssets[address(nftContract)]; if (asset.assetType != SharedObjs.AssetType.ERC721 || asset.listedType == SharedObjs.ListedType.REMOVED || asset.listedType == SharedObjs.ListedType.UNLISTED) { revert InvalidAsset(); } // Gets the Liq value of the deposited Nfts uint256 callPrice = oracle.getAssetPrice(address(nftContract)); uint256 assetLiqPrice = _usdToLiq(callPrice, __totalVaultValue); asset.totalVaultLiq += assetLiqPrice; // Transfers in the nfts and verifies balances { uint256 balanceBefore = nftContract.balanceOf(address(this)); assert(!EnumerableSet.contains(vault, key)); // Vault must not contain this key/asset if(EnumerableSet.add(vault, key)) { // Note: asset.size is incremented below, alongside LIQ mint, to avoid inaccurate prices during the batch call if(nfts[key].nftContract == address(0)){ nfts[key] = SharedObjs.Nft(address(nftContract), tokenId); } } nftContract.safeTransferFrom(msg.sender, address(this), tokenId); // Calculate the amount that was *actually* transferred if (nftContract.balanceOf(address(this)) - balanceBefore != 1) { revert BalanceMismatch(); } } uint256 incentiveRate = RATE; if (asset.listedType == SharedObjs.ListedType.STANDARD) { incentiveRate = nftsNeededToIncentiveRate( _nftAssetsNeeded(address(nftContract), callPrice, __totalMarketCap, asset) ); } ++asset.workingSize; // Calculates the fee distrbution of each nft being transferred (uint256 stakersCut, uint256 sellerMintCut, uint256 sellerPoolCut, uint256 protocolCut) = calculateDepositFeeDistribution(assetLiqPrice, incentiveRate, incentivesPool); totalLiqToMint += protocolCut + stakersCut + sellerMintCut; stakerAllocatedFees += stakersCut; totalSellerMintCut += sellerMintCut + sellerPoolCut; // Updates Incentives Pool if(protocolCut != 0) { incentivesPool += protocolCut; } if (sellerPoolCut != 0) { if (incentivesPool >= sellerPoolCut) { incentivesPool -= sellerPoolCut; } else { incentivesPool = 0; } } emit DepositNFT(msg.sender, msg.sender, key, address(nftContract), tokenId, callPrice, stakersCut, sellerMintCut, sellerPoolCut, protocolCut); unchecked { ++i; } } // Handles all variables related to LIQ Price for(uint256 i; i < assets.length;) { ++indexAssets[assets[i].nftContract].size; // Increments collection size which affects totalVaultValue and hence LIQ price unchecked { ++i; } } if(totalSellerMintCut < minimalAmount){ revert LessThanMinimalAmount(); } _mint(address(this), totalLiqToMint); _transfer(address(this), msg.sender, totalSellerMintCut); } /** * @notice Transfers the staker fees that have already been allocated */ function extractAndDistributeFees() external onlyRole(INTERNAL_ROLE) { // Calculate the staker fee distribution uint256 totalVeFungCut = stakerAllocatedFees * veFungSpreadRate / RATE; uint256 totalLiqStakingCut = stakerAllocatedFees - totalVeFungCut; if(veFUNG != address(0) && totalVeFungCut > 0) { stakerAllocatedFees -= totalVeFungCut; _transfer(address(this), veFUNG, totalVeFungCut); } if(liqStaking != address(0) && totalLiqStakingCut > 0) { stakerAllocatedFees -= totalLiqStakingCut; _approve(address(this), liqStaking, totalLiqStakingCut); IsNftIndex(liqStaking).addRewards(totalLiqStakingCut); } assert(this.balanceOf(address(this)) >= incentivesPool); if(totalLiqStakingCut > 0 || totalVeFungCut > 0) emit ExtractAndDistribute(totalLiqStakingCut, totalVeFungCut); } /** * @notice Calculates what funds go where when an asset is deposited * @param floorVal of the asset in LIQ * @param vaultIncentiveRate the incentive rate to be applied onto the deposit * @param _incentivesPool the incentive pool value * @return stakersCut the amount of LIQ to be transferred to stakers * @return sellerMintCut the amount the depositer/seller is minted for their nft * @return sellerPoolCut the amount they are transferred from the incentivePool * @return protocolCut the amount the protocol's incentivePool receives */ function calculateDepositFeeDistribution(uint256 floorVal, uint256 vaultIncentiveRate, uint256 _incentivesPool) public view returns ( uint256 stakersCut, uint256 sellerMintCut, uint256 sellerPoolCut, uint256 protocolCut ) { /* Calculate stakersCut to distributes it to veFung and xLiq holders */ stakersCut = floorVal * depositFeeRate / RATE; // Calculate sellerCut after spread uint256 sellerCut = floorVal - stakersCut; // Calculate potential seller cut after incentiveRate is applied uint256 incentivizedSellerCut = sellerCut * vaultIncentiveRate / RATE; // If over target weight: disincentivize. mint incentivizedSellerCut to seller & store remainder in sellerIncentivesPool if (incentivizedSellerCut < sellerCut) { sellerMintCut = incentivizedSellerCut; // Mints leftover to protocol to not affect Liq Price protocolCut = sellerCut - incentivizedSellerCut; // If under target weight: incentivize. seller gets more as an incentive } else { assert(incentivizedSellerCut >= sellerCut); uint256 incentive = incentivizedSellerCut - sellerCut; sellerMintCut = sellerCut; // If incentivesPool has enough: mint incentivizedSellerCut & adjust incentivesPool if (_incentivesPool >= incentive) { // Transfers the incentive from sellingMarket's pool sellerPoolCut = incentive; // If incentivesPool doesn't have enough: mint what's available & zero-out incentivesPool } else { sellerPoolCut = _incentivesPool; } } } /** * @notice Burns $NFT/LIQ token in exchange for a random NFT from the vault * @param nftCount of nfts to be redeemed * @return requestId associated with the chainlink vrf call */ function redeem(uint256 nftCount) external checkRedeemWhitelist() returns(uint256 requestId) { if (nftCount == 0) { revert InvalidRedemption(); } // Empty vault check to prevent VRF wasting. if (EnumerableSet.length(vault) == 0) { revert EmptyVault(); } // Fetches the price of a redemption uint256 basePrice = baseRedeemPrice(); uint256 redeemFee = basePrice * redemptionFeeRate / RATE; uint256 bufferedPrice = basePrice * redemptionBuffer / RATE; uint256 callPrice = bufferedPrice + redeemFee; // Transfers the callPrice and tracks the balance _transfer(msg.sender, address(this), callPrice * nftCount); redemptionBalance[msg.sender] += callPrice * nftCount; // Check for VRF subscription has sufficient link. (uint256 balance, , , ,) = s_vrfCoordinator.getSubscription(s_subscriptionId); if (balance < minLINKBalance) { revert InsufficientLINKBalance(); } // Requests a random word from VRF requestId = s_vrfCoordinator.requestRandomWords( VRFV2PlusClient.RandomWordsRequest( keyHash, s_subscriptionId, requestConfirmations, callbackGasLimit, uint32(1), //We need only 1 true random VRFV2PlusClient._argsToBytes( VRFV2PlusClient.ExtraArgsV1(false) // False - paying LINK ) ) ); randomnessRequests[requestId] = SharedObjs.RandomnessRequest({ recipient: msg.sender, redeemer: msg.sender, callPrice: callPrice, nftCount: nftCount, vaultSize: EnumerableSet.length(vault) }); emit RedemptionRequested(msg.sender, requestId, callPrice, nftCount); } /** * @notice Performs the actual redeeming after random numbers have been retrieved from the VRF. * @dev This function is internal because it will be called by rawFulfillRandomWords() (an inherited external function) * @dev If multiple redemptions other indexes are obtained from the single VRF * @param requestId The randomnessRequest id to give information for this redemption call. * @param randomWords Contains the random number from VRF */ function fulfillRandomWords(uint256 requestId, uint256[] memory randomWords) internal override { // Get request to access redeemer and callPrice at redemption time. SharedObjs.RandomnessRequest memory request = randomnessRequests[requestId]; // Saves on accessing struct multiple times. address recipient = request.recipient; address redeemer = request.redeemer; uint256 callPrice = request.callPrice; uint256 nftCount = request.nftCount; uint256 callBalance = callPrice * nftCount; // Checks the user has stil has sufficient LIQ balance since VRF call, this should only occur if refundRedeemer() is called during a pending redeem if (redemptionBalance[redeemer] < callBalance) { revert InsufficientRedemptionBalance(); } // Reduce nftCount if it's bigger than total vault size uint256 actualVaultSize = EnumerableSet.length(vault); uint256 vaultSize = (request.vaultSize > actualVaultSize) ? actualVaultSize : request.vaultSize; nftCount = (nftCount > vaultSize) ? vaultSize : nftCount; // Vars used in event output bool redeemed; SharedObjs.Nft memory nft; uint256 stickerPrice; uint256 stakerFees; for (uint256 i; i < nftCount;) { // Selects a random floor Nft based on random words uint256 randomIndex = uint256(keccak256(abi.encodePacked(randomWords[0], i, callPrice))); (nft, stickerPrice) = selectNft(randomIndex, vaultSize); stakerFees = stickerPrice * redemptionFeeRate / RATE; // If nft's price is higher than balance left for redemptions then skip that nft. if (stickerPrice + stakerFees > callBalance) { redeemed = false; } else { redeemNft(nft, redeemer, recipient, stickerPrice); callBalance -= stickerPrice + stakerFees; vaultSize--; redeemed = true; } emit WithdrawNFT(redeemer, recipient, _getNftKey(nft.nftContract, nft.tokenId), nft.nftContract, nft.tokenId, stickerPrice, oracle.getAssetPrice(nft.nftContract), (stickerPrice * redemptionFeeRate / RATE), redeemed); unchecked { ++i; } } // Returns the caller any unused leftover LIQ assert(redemptionBalance[redeemer] >= callBalance); _refundRedeemer(redeemer, callBalance); } /** * @notice Gets the highest of the average sticker price of listed nft collections. Buffer added * @dev Used for the call amount for redemptions (before spread) * @return basePrice The highest of the collection average redemption prices */ function baseRedeemPrice() public view returns(uint256 basePrice) { address nftContract; uint256 averageFloor; uint256 listedAssetsLength = listedAssets.length; for (uint256 i; i < listedAssetsLength;) { nftContract = listedAssets[i]; // Avoids division by zero when collection not in vault averageFloor = getBaseRedemptionPrice(nftContract); // Tracks maximum if (averageFloor > basePrice) { basePrice = averageFloor; } unchecked { ++i; } } } /** * @notice Selects an unreserved vault Nft based on the randomNumber and chosen NftSet. * @param randomNum the value used to get a random index. * @param vaultSize the total number of deposited nfts * @return nft that was selected. * @return stickerPrice of that selected Nft. */ function selectNft(uint256 randomNum, uint256 vaultSize) internal view returns(SharedObjs.Nft memory nft, uint256 stickerPrice) { uint256 randomScaledNum = randomNum % MAX_UINT_TO_RATE; uint256 randomRate = randomScaledNum * RATE / MAX_UINT_TO_RATE; uint256 randomIdx = randomRate * vaultSize / RATE; nft = nfts[EnumerableSet.at(vault, randomIdx)]; assert(nft.nftContract != address(0)); stickerPrice = getBaseRedemptionPrice(nft.nftContract); assert(stickerPrice != 0); } /** * @notice Gets the sticker price for the redemption of a listed Nft * @param nftContract to check the price for * @return the redemption price of that nft in Liq * Requirements: * - There must be one nft of that collection in the vault to have a nonzero redemption price */ function getBaseRedemptionPrice(address nftContract) public view returns(uint256) { SharedObjs.IndexAsset storage asset = indexAssets[nftContract]; uint256 numNfts = asset.size; // Avoids division by zero when collection not in vault return (numNfts != 0) ? asset.totalVaultLiq / numNfts : 0; } /** * @notice Actually does the sending of the Nft and distributes the spread. * @param nft The nft to be sent * @param redeemer The address to send the nft too * @param stickerPrice Used to calculate if there is leftover that should be refunded. */ function redeemNft(SharedObjs.Nft memory nft, address redeemer, address recipient, uint256 stickerPrice) internal { // Updates totalVaultLiq of the asset SharedObjs.IndexAsset storage asset = indexAssets[nft.nftContract]; asset.totalVaultLiq = asset.totalVaultLiq - stickerPrice; // Allocates fees to stakers uint256 stakerFees = stickerPrice * redemptionFeeRate / RATE; stakerAllocatedFees += stakerFees; // Burns the price of the NFT _burn(address(this), stickerPrice); // Updates users redemptionBalance redemptionBalance[redeemer] -= stickerPrice + stakerFees; // Sends Nft to redeemer bytes32 key = _getNftKey(nft.nftContract, nft.tokenId); if (EnumerableSet.remove(vault, key)) { asset.size--; asset.workingSize--; } IERC721(nft.nftContract).transferFrom(address(this), recipient, nft.tokenId); } /** * @notice This function refunds a users redemptionBalance in the event of a vrf fulfillment failure. * @dev Only should allow refunds to prevent bad actors manipulating redemptions * @param redeemer the user to refund * Requirements: * - Ensure the user doesn't have a pending redemption during this call or they will revert their redemption */ function refundRedeemer(address redeemer) external onlyRole(INTERNAL_ROLE) { uint256 _refundBalance = redemptionBalance[redeemer]; _refundRedeemer(redeemer, _refundBalance); } /** * @notice This function refunds a users redemptionBalance by a specified amount * @param redeemer the user to refund * @param amount the amount to refund * Requirements: * - The user must have that enough redemptionBalance allocated to them. */ function _refundRedeemer(address redeemer, uint256 amount) internal { uint256 _refundBalance = redemptionBalance[redeemer]; if (redemptionBalance[redeemer] < amount) { revert InsufficientRedemptionBalance(); } redemptionBalance[redeemer] -= amount; _transfer(address(this), redeemer, amount); emit RefundRedeemer(redeemer, amount); assert(balanceOf(address(this)) >= incentivesPool + stakerAllocatedFees); } /** * @notice This function claims a users redemptionBalance for stakers. * @dev Extra caution on pending redemptions when using this one. * @dev This should only be used too disincentives bad actors from attempting to manipulate random redemptions. * @param redeemer the user to refund * Requirements: * - Ensure the user doesn't have a pending redemption during this call or they will revert ther redemption and lose their LIQ! */ function sinkRedeemer(address redeemer) external onlyRole(INTERNAL_ROLE) { stakerAllocatedFees += redemptionBalance[redeemer]; redemptionBalance[redeemer] = 0; } /** * @notice Converts a usdAmount to a Liq amount based on the Liq price * @param usdAmount to be converted * @return Liq amount equivalent to the provided usdAmount */ function _usdToLiq(uint256 usdAmount, uint256 totalUsdValue) internal view returns(uint256) { uint256 liqSupply = totalSupply(); // Zero Check if (liqSupply == 0) { return usdAmount * initialLiqPerUsd / RATE; } /* * The liq per usd is derived from the LIQTotalSupply / totalVaultUsdValue * Then LiqAmount = usdAmount * LiqSupply / TotalVaultUsdValue */ return usdAmount * liqSupply / totalUsdValue; } /** * @notice Converts an Liq amount to a USD amount based on the Liq price * @param liqAmount to be converted * @return USD amount equivalent to the provided liqAmount */ function _liqToUsd(uint256 liqAmount, uint256 totalUsdValue) internal view returns(uint256) { uint256 liqSupply = totalSupply(); // Zero Check if (liqSupply == 0) { return liqAmount * RATE / initialLiqPerUsd; } /* * The usd per liq is derived from the totalUnreservedVaultUsdValue / LIQTotalSupply * Then UsdAmount = liqAmount * TotalVaultUsdValue / LiqSupply */ return liqAmount * totalUsdValue / liqSupply; } /** * @notice Gets the value of all listed assets no matter what type of listed. * @return totalValue of the vault in USD */ function totalVaultValue() public view returns(uint256 totalValue) { // Running sum iterating through every nftContract which have ever entered the system. uint256 listedAssetsLength = listedAssets.length; for (uint256 i; i < listedAssetsLength;) { uint256 vaultAssetValue = assetVaultValue(listedAssets[i]); totalValue += vaultAssetValue; unchecked { ++i; } } } /** * @notice Returns the summed Usd value of a specified nftContract in the vault. * @param nftContract the asset to be summed * @return vaultValue the summed Usd value of all assets of that collection in the vault */ function assetVaultValue(address nftContract) public view returns(uint256 vaultValue) { // Uses chainlink and feed adapter to get the latest Usd floor price of the given collection uint256 latestFloorUsd = oracle.getAssetPrice(nftContract); // Multiplies that price by the vault count to get the sum. vaultValue = latestFloorUsd * indexAssets[nftContract].size; } /** * @notice Gets the IndexAsset of a particular asset * @param assetAddress to be fetched * @return the indexAsset data for it */ function getIndexAssetDetails(address assetAddress) public view returns (SharedObjs.IndexAsset memory) { return indexAssets[assetAddress]; } /** * @notice Gets the size of the listedAssets array * @return the length of the array */ function listedAssetsSize() public view returns(uint) { return listedAssets.length; } /** * @notice Requires operator to be this contract */ function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external override returns (bytes4) { if (operator != address(this)) { revert Unauthorized(); } return IERC721Receiver.onERC721Received.selector; } /** * @notice Sets a new price oracle * @dev Admin function to set a new price oracle * @param newOracle address to be set */ function setPriceOracle(PriceOracle newOracle) external onlyRole(INTERNAL_ROLE) { // Track the old oracle PriceOracle oldOracle = oracle; // Set oracle to newOracle oracle = newOracle; // Emit NewPriceOracle(oldOracle, newOracle) emit NewPriceOracle(oldOracle, newOracle); } /** * @notice Fills the mapping for number of nfts needed of a collection to a vault incentive rate * @dev NftsNeeded will truncate (so for 2 <= nonTruncatedNftsNeeded < 3, use nftsNeeded = 2) * @dev Applied vault incentive rates are used as total values. (for a 7% penalty use incentive = 93%, for a 6% bonus use incentive = 106%) * @param nftsNeeded the values of how many nfts needed will have assigned vault incentive rates * @param incentives the vault incentive rates pertaining to those nfts needed amounts. * Requirements: * - Arrays must be of equal length * - Both nftsNeeded and incentives must sequentially increase in value * - 0 nftsNeeded must have 100% vault incentive */ function setNftIncentives(int[] calldata nftsNeeded, uint256 [] calldata incentives) public onlyRole(INTERNAL_ROLE) { if (nftsNeeded.length != incentives.length) { revert ArrayLengthMismatch(); } // Declare previous vars int256 previousNftsNeeded; uint256 previousIncentive; uint256 nftsNeededLength = nftsNeeded.length; for (uint256 i; i < nftsNeededLength;) { // Get currentNftsNeeded int256 currentNftsNeeded = nftsNeeded[i]; uint256 currentIncentive = incentives[i]; // Validate incentive if (currentIncentive == 0) { revert IncentiveIsZero(); } // If first key if (i == 0) { lowestNftsNeeded = currentNftsNeeded; } else { // Validate keys and values if (currentNftsNeeded != previousNftsNeeded + 1) { revert NftsNeededNotIncreasing(); } if (currentIncentive < previousIncentive) { revert IncentiveNotIncreasing(); } } // If last key if (i == nftsNeededLength - 1) { highestNftsNeeded = currentNftsNeeded; } if (currentNftsNeeded == 0 && currentIncentive != RATE) { revert ZeroNftsNeededMustHaveOneHundredPctIncentive(); } // Update storage nftIncentives[nftsNeeded[i]] = currentIncentive; // Update previous vars previousNftsNeeded = currentNftsNeeded; previousIncentive = currentIncentive; unchecked { ++i; } } } /** * @notice Sets the initial Liq Price, used only for empty vaults. * @dev 18 decimal so 1e18 is 1:1 * @param newInitialPrice the new price of Liq */ function setInitialLiqPerUsd(uint256 newInitialPrice) external onlyRole(INTERNAL_ROLE) { initialLiqPerUsd = newInitialPrice; } /** * @notice Sets the redemptionBuffer, added on top of base redeem price to avoid failed redemptions * @dev 18 decimal rate including self so 2% buffer should be passed as 102% = 102e16 * @param newRedemptionBuffer the new buffer * Requirements: * - The buffer cant be over 100% so value passed in cant be over 200% */ function setRedemptionBuffer(uint256 newRedemptionBuffer) external onlyRole(INTERNAL_ROLE) { if (newRedemptionBuffer > (RATE + RATE)) { revert InvalidValue(); } redemptionBuffer = newRedemptionBuffer; } /** * @notice Sets the minLINKBalance, how much LINK the VRF subscription should contain to allow for a redemption * @dev 18 decimal value so 1 LINk is 1e18 * @param newMinLINKBalance the new minimum */ function setMinLINKBalance(uint256 newMinLINKBalance) external onlyRole(INTERNAL_ROLE) { minLINKBalance = newMinLINKBalance; } /** * @notice Sets the depositFeeRate the fee taken for stakers for a deposit * @dev 18 decimal rate so 50% = 5e17 * @param newDepositFeeRate the new fee * Requirements: * - The fee cant be over 100% */ function setDepositFeeRate(uint256 newDepositFeeRate) external onlyRole(INTERNAL_ROLE) { if (newDepositFeeRate > RATE) { revert InvalidValue(); } depositFeeRate = newDepositFeeRate; } /** * @notice Sets the redemptionFeeRate the fee taken for stakers for a redemption * @dev 18 decimal rate so 50% = 5e17 * @param newRedemptionFeeRate the new fee * Requirements: * - The fee cant be over 100% */ function setRedemptionFeeRate(uint256 newRedemptionFeeRate) external onlyRole(INTERNAL_ROLE) { if (newRedemptionFeeRate > RATE) { revert InvalidValue(); } redemptionFeeRate = newRedemptionFeeRate; } /** * @notice Sets the veFungSpreadRate, the dsitribution of fees going to veFung stakers, rest going to LIQ stakers * @dev 18 decimal rate so 50% = 5e17 * @param newVeFungSpreadRate the new fee * Requirements: * - The spread cant be over 100% */ function setVeFungSpreadRate(uint256 newVeFungSpreadRate) external onlyRole(INTERNAL_ROLE) { if (newVeFungSpreadRate > RATE) { revert InvalidValue(); } veFungSpreadRate = newVeFungSpreadRate; } /** * @notice Sets the deposit whitelist to be on or off * @param status true or false for the whitelist */ function setDepositWhitelist(bool status) external onlyRole(INTERNAL_ROLE) { depositWhitelist = status; } /** * @notice Sets the deposit whitelist to be on or off * @param status true or false for the whitelist */ function setRedeemWhitelist(bool status) external onlyRole(INTERNAL_ROLE) { redeemWhitelist = status; } /** * @notice Calculates the number of nfts of the given nftContract needed to reach our desired target weight. * @param nftContract to get the number of nfts needed for * @return The number needed to reach our target weight, can be negative if overweight */ function nftAssetsNeeded(address nftContract) external view returns (int) { return _nftAssetsNeeded(nftContract, oracle.getAssetPrice(nftContract), standardAssetMarketCap(), indexAssets[nftContract]); } /** * @notice Converts an Liq amount to a USD amount based on the Liq price * @param liqAmount to be converted * @return USD amount equivalent to the provided liqAmount */ function liqToUsd(uint256 liqAmount) public view returns(uint256) { return _liqToUsd(liqAmount, totalVaultValue()); } /** * @notice Converts a usdAmount to a Liq amount based on the Liq price * @param usdAmount to be converted * @return Liq amount equivalent to the provided usdAmount */ function usdToLiq(uint256 usdAmount) public view returns(uint256) { return _usdToLiq(usdAmount, totalVaultValue()); } /** * @notice Deposits an asset and mints the appropriate amount of NFT Index Token * @param assets an array of assets to be deposited * @return output LIQ amount */ function calculateDepositOutputAmount(SharedObjs.Nft [] calldata assets) external view returns (uint256) { uint256 __totalMarketCap = standardAssetMarketCap(); uint256 __totalVaultValue = totalVaultValue(); uint256 len = assets.length; uint256 totalSellerMintCut; uint256 [] memory assetsCounters = new uint256[](len); // Loops through all assets and deposits all respective nftIds for (uint256 i; i < len;) { address nftContract = assets[i].nftContract; SharedObjs.IndexAsset memory asset = indexAssets[nftContract]; asset.workingSize += assetsCounters[i]; // Gets the Liq value of the deposited Nfts uint256 callPrice = oracle.getAssetPrice(nftContract); uint256 assetLiqPrice = _usdToLiq(callPrice, __totalVaultValue); // Get nftsNeeded for the specified contract. uint256 incentiveRate = nftsNeededToIncentiveRate( _nftAssetsNeeded(nftContract, callPrice, __totalMarketCap, asset) ); for (uint256 j = i; j < len;) { if (nftContract == assets[j].nftContract) ++assetsCounters[j]; unchecked { ++j; } } // Calculates the fee distrbution of each nft being transferred (uint256 stakersCut, uint256 sellerMintCut, uint256 sellerPoolCut, uint256 protocolCut) = calculateDepositFeeDistribution(assetLiqPrice, incentiveRate, incentivesPool); totalSellerMintCut += sellerMintCut + sellerPoolCut; unchecked { ++i; } } return totalSellerMintCut; } /** * @notice takes originalToken if it's wrapped and returns totalSupply * @param nftContract address * @return unwrapped token totalSupply */ function getERC721TokenSupply(address nftContract) internal view returns (uint256){ address original = originalTokens[nftContract]; return IERC721Enumerable(original == address(0) ? nftContract : original).totalSupply(); } /** * @notice set originalToken if it's wrapped * @param nftContract address * @param original address */ function setOriginalTokens(address nftContract, address original) external onlyRole(INTERNAL_ROLE) { originalTokens[nftContract] = original; } /** * @notice Checks if deposit whitelist is on and if msg.sender is whitelisted if it is */ modifier checkDepositWhitelist() { if (depositWhitelist) { _checkRole(DEPOSITOR_ROLE); } _; } /** * @notice Checks if redeem whitelist is on and if msg.sender is whitelisted if it is */ modifier checkRedeemWhitelist() { if (redeemWhitelist) { _checkRole(REDEEMER_ROLE); } _; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC20Permit.sol) pragma solidity ^0.8.20; import {IERC20Permit} from "contracts/token/ERC20/extensions/IERC20Permit.sol"; import {ERC20} from "contracts/token/ERC20/ERC20.sol"; import {ECDSA} from "contracts/utils/cryptography/ECDSA.sol"; import {EIP712} from "contracts/utils/cryptography/EIP712.sol"; import {Nonces} from "contracts/utils/Nonces.sol"; /** * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712, Nonces { bytes32 private constant PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); /** * @dev Permit deadline has expired. */ error ERC2612ExpiredSignature(uint256 deadline); /** * @dev Mismatched signature. */ error ERC2612InvalidSigner(address signer, address owner); /** * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`. * * It's a good idea to use the same `name` that is defined as the ERC20 token name. */ constructor(string memory name) EIP712(name, "1") {} /** * @inheritdoc IERC20Permit */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual { if (block.timestamp > deadline) { revert ERC2612ExpiredSignature(deadline); } bytes32 structHash = keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline)); bytes32 hash = _hashTypedDataV4(structHash); address signer = ECDSA.recover(hash, v, r, s); if (signer != owner) { revert ERC2612InvalidSigner(signer, owner); } _approve(owner, spender, value); } /** * @inheritdoc IERC20Permit */ function nonces(address owner) public view virtual override(IERC20Permit, Nonces) returns (uint256) { return super.nonces(owner); } /** * @inheritdoc IERC20Permit */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view virtual returns (bytes32) { return _domainSeparatorV4(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * CAUTION: See Security Considerations above. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "contracts/token/ERC20/IERC20.sol"; import {IERC20Metadata} from "contracts/token/ERC20/extensions/IERC20Metadata.sol"; import {Context} from "contracts/utils/Context.sol"; import {IERC20Errors} from "contracts/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 ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. */ 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}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `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: * ``` * 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.0.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the 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.0.0) (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.20; import {IERC20} from "contracts/token/ERC20/IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 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.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.0.0) (interfaces/draft-IERC6093.sol) pragma solidity ^0.8.20; /** * @dev Standard ERC20 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 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 ERC721 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens. */ interface IERC721Errors { /** * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-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 ERC1155 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 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) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.20; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS } /** * @dev The signature derives the `address(0)`. */ error ECDSAInvalidSignature(); /** * @dev The signature has an invalid length. */ error ECDSAInvalidSignatureLength(uint256 length); /** * @dev The signature has an S value that is in the upper half order. */ error ECDSAInvalidSignatureS(bytes32 s); /** * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not * return address(0) without also returning an error description. Errors are documented using an enum (error type) * and a bytes32 providing additional information about the error. * * If no error is returned, then the address can be used for verification purposes. * * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) { if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else { return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length)); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature); _throwError(error, errorArg); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] */ function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) { unchecked { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); // We do not check for an overflow here since the shift operation results in 0 or 1. uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. */ function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs); _throwError(error, errorArg); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError, bytes32) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS, s); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature, bytes32(0)); } return (signer, RecoverError.NoError, bytes32(0)); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s); _throwError(error, errorArg); return recovered; } /** * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided. */ function _throwError(RecoverError error, bytes32 errorArg) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert ECDSAInvalidSignature(); } else if (error == RecoverError.InvalidSignatureLength) { revert ECDSAInvalidSignatureLength(uint256(errorArg)); } else if (error == RecoverError.InvalidSignatureS) { revert ECDSAInvalidSignatureS(errorArg); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol) pragma solidity ^0.8.20; import {MessageHashUtils} from "contracts/utils/cryptography/MessageHashUtils.sol"; import {ShortStrings, ShortString} from "contracts/utils/ShortStrings.sol"; import {IERC5267} from "contracts/interfaces/IERC5267.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose * encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract * does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to * produce the hash of their typed data using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the * separator from the immutable values, which is cheaper than accessing a cached version in cold storage. * * @custom:oz-upgrades-unsafe-allow state-variable-immutable */ abstract contract EIP712 is IERC5267 { using ShortStrings for *; bytes32 private constant TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to // invalidate the cached domain separator if the chain id changes. bytes32 private immutable _cachedDomainSeparator; uint256 private immutable _cachedChainId; address private immutable _cachedThis; bytes32 private immutable _hashedName; bytes32 private immutable _hashedVersion; ShortString private immutable _name; ShortString private immutable _version; string private _nameFallback; string private _versionFallback; /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { _name = name.toShortStringWithFallback(_nameFallback); _version = version.toShortStringWithFallback(_versionFallback); _hashedName = keccak256(bytes(name)); _hashedVersion = keccak256(bytes(version)); _cachedChainId = block.chainid; _cachedDomainSeparator = _buildDomainSeparator(); _cachedThis = address(this); } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { if (address(this) == _cachedThis && block.chainid == _cachedChainId) { return _cachedDomainSeparator; } else { return _buildDomainSeparator(); } } function _buildDomainSeparator() private view returns (bytes32) { return keccak256(abi.encode(TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash); } /** * @dev See {IERC-5267}. */ function eip712Domain() public view virtual returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ) { return ( hex"0f", // 01111 _EIP712Name(), _EIP712Version(), block.chainid, address(this), bytes32(0), new uint256[](0) ); } /** * @dev The name parameter for the EIP712 domain. * * NOTE: By default this function reads _name which is an immutable value. * It only reads from storage if necessary (in case the value is too large to fit in a ShortString). */ // solhint-disable-next-line func-name-mixedcase function _EIP712Name() internal view returns (string memory) { return _name.toStringWithFallback(_nameFallback); } /** * @dev The version parameter for the EIP712 domain. * * NOTE: By default this function reads _version which is an immutable value. * It only reads from storage if necessary (in case the value is too large to fit in a ShortString). */ // solhint-disable-next-line func-name-mixedcase function _EIP712Version() internal view returns (string memory) { return _version.toStringWithFallback(_versionFallback); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol) pragma solidity ^0.8.20; import {Strings} from "contracts/utils/Strings.sol"; /** * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing. * * The library provides methods for generating a hash of a message that conforms to the * https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712] * specifications. */ library MessageHashUtils { /** * @dev Returns the keccak256 digest of an EIP-191 signed data with version * `0x45` (`personal_sign` messages). * * The digest is calculated by prefixing a bytes32 `messageHash` with * `"\x19Ethereum Signed Message:\n32"` and hashing the result. It corresponds with the * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method. * * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with * keccak256, although any bytes32 value can be safely used because the final digest will * be re-hashed. * * See {ECDSA-recover}. */ function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) { /// @solidity memory-safe-assembly assembly { mstore(0x00, "\x19Ethereum Signed Message:\n32") // 32 is the bytes-length of messageHash mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20) } } /** * @dev Returns the keccak256 digest of an EIP-191 signed data with version * `0x45` (`personal_sign` messages). * * The digest is calculated by prefixing an arbitrary `message` with * `"\x19Ethereum Signed Message:\n" + len(message)` and hashing the result. It corresponds with the * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method. * * See {ECDSA-recover}. */ function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) { return keccak256(bytes.concat("\x19Ethereum Signed Message:\n", bytes(Strings.toString(message.length)), message)); } /** * @dev Returns the keccak256 digest of an EIP-191 signed data with version * `0x00` (data with intended validator). * * The digest is calculated by prefixing an arbitrary `data` with `"\x19\x00"` and the intended * `validator` address. Then hashing the result. * * See {ECDSA-recover}. */ function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) { return keccak256(abi.encodePacked(hex"19_00", validator, data)); } /** * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`). * * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with * `\x19\x01` and hashing the result. It corresponds to the hash signed by the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712. * * See {ECDSA-recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(ptr, hex"19_01") mstore(add(ptr, 0x02), domainSeparator) mstore(add(ptr, 0x22), structHash) digest := keccak256(ptr, 0x42) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol) pragma solidity ^0.8.20; import {Math} from "contracts/utils/math/Math.sol"; import {SignedMath} from "contracts/utils/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; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { 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 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.0.0) (utils/math/Math.sol) pragma solidity ^0.8.20; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Muldiv operation overflow. */ error MathOverflowedMulDiv(); 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 overflow flag. */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { 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 division by zero flag. */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return 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. return a / b; } // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * @dev 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^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { 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^256. Also prevents denominator == 0. if (denominator <= prod1) { revert MathOverflowedMulDiv(); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // 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 { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / 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^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. 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^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // 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^256. Since the preconditions guarantee that the outcome is // less than 2^256, 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; } } /** * @notice 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) { uint256 result = mulDiv(x, y, denominator); if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice 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 + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0); } } /** * @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; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 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 + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0); } } /** * @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 + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0); } } /** * @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; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 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 + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0); } } /** * @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.0.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.20; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return 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 { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/ShortStrings.sol) pragma solidity ^0.8.20; import {StorageSlot} from "contracts/utils/StorageSlot.sol"; // | string | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | // | length | 0x BB | type ShortString is bytes32; /** * @dev This library provides functions to convert short memory strings * into a `ShortString` type that can be used as an immutable variable. * * Strings of arbitrary length can be optimized using this library if * they are short enough (up to 31 bytes) by packing them with their * length (1 byte) in a single EVM word (32 bytes). Additionally, a * fallback mechanism can be used for every other case. * * Usage example: * * ```solidity * contract Named { * using ShortStrings for *; * * ShortString private immutable _name; * string private _nameFallback; * * constructor(string memory contractName) { * _name = contractName.toShortStringWithFallback(_nameFallback); * } * * function name() external view returns (string memory) { * return _name.toStringWithFallback(_nameFallback); * } * } * ``` */ library ShortStrings { // Used as an identifier for strings longer than 31 bytes. bytes32 private constant FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF; error StringTooLong(string str); error InvalidShortString(); /** * @dev Encode a string of at most 31 chars into a `ShortString`. * * This will trigger a `StringTooLong` error is the input string is too long. */ function toShortString(string memory str) internal pure returns (ShortString) { bytes memory bstr = bytes(str); if (bstr.length > 31) { revert StringTooLong(str); } return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length)); } /** * @dev Decode a `ShortString` back to a "normal" string. */ function toString(ShortString sstr) internal pure returns (string memory) { uint256 len = byteLength(sstr); // using `new string(len)` would work locally but is not memory safe. string memory str = new string(32); /// @solidity memory-safe-assembly assembly { mstore(str, len) mstore(add(str, 0x20), sstr) } return str; } /** * @dev Return the length of a `ShortString`. */ function byteLength(ShortString sstr) internal pure returns (uint256) { uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF; if (result > 31) { revert InvalidShortString(); } return result; } /** * @dev Encode a string into a `ShortString`, or write it to storage if it is too long. */ function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) { if (bytes(value).length < 32) { return toShortString(value); } else { StorageSlot.getStringSlot(store).value = value; return ShortString.wrap(FALLBACK_SENTINEL); } } /** * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}. */ function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) { if (ShortString.unwrap(value) != FALLBACK_SENTINEL) { return toString(value); } else { return store; } } /** * @dev Return the length of a string that was encoded to `ShortString` or written to storage using * {setWithFallback}. * * WARNING: This will return the "byte length" of the string. This may not reflect the actual length in terms of * actual characters as the UTF-8 encoding of a single character can span over multiple bytes. */ function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) { if (ShortString.unwrap(value) != FALLBACK_SENTINEL) { return byteLength(value); } else { return bytes(store).length; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.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 ERC1967 implementation slot: * ```solidity * contract ERC1967 { * 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; * } * } * ``` */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 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) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` with member `value` located at `slot`. */ function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { 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) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } /** * @dev Returns an `BytesSlot` with member `value` located at `slot`. */ function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { 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) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol) pragma solidity ^0.8.20; interface IERC5267 { /** * @dev MAY be emitted to signal that the domain could have changed. */ event EIP712DomainChanged(); /** * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712 * signature. */ function eip712Domain() external view returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Nonces.sol) pragma solidity ^0.8.20; /** * @dev Provides tracking nonces for addresses. Nonces will only increment. */ abstract contract Nonces { /** * @dev The nonce used for an `account` is not the expected current nonce. */ error InvalidAccountNonce(address account, uint256 currentNonce); mapping(address account => uint256) private _nonces; /** * @dev Returns the next unused nonce for an address. */ function nonces(address owner) public view virtual returns (uint256) { return _nonces[owner]; } /** * @dev Consumes a nonce. * * Returns the current value and increments nonce. */ function _useNonce(address owner) internal virtual returns (uint256) { // For each account, the nonce has an initial value of 0, can only be incremented by one, and cannot be // decremented or reset. This guarantees that the nonce never overflows. unchecked { // It is important to do x++ and not ++x here. return _nonces[owner]++; } } /** * @dev Same as {_useNonce} but checking that `nonce` is the next valid for `owner`. */ function _useCheckedNonce(address owner, uint256 nonce) internal virtual { uint256 current = _useNonce(owner); if (nonce != current) { revert InvalidAccountNonce(owner, current); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "contracts/token/ERC20/IERC20.sol"; import {IERC20Permit} from "contracts/token/ERC20/extensions/IERC20Permit.sol"; import {Address} from "contracts/utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; /** * @dev An operation with an ERC20 token failed. */ error SafeERC20FailedOperation(address token); /** * @dev Indicates a failed `decreaseAllowance` request. */ error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease); /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value))); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value))); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); forceApprove(token, spender, oldAllowance + value); } /** * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no * value, non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal { unchecked { uint256 currentAllowance = token.allowance(address(this), spender); if (currentAllowance < requestedDecrease) { revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease); } forceApprove(token, spender, currentAllowance - requestedDecrease); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value)); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0))); _callOptionalReturn(token, approvalCall); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data); if (returndata.length != 0 && !abi.decode(returndata, (bool))) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol) pragma solidity ^0.8.20; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error AddressInsufficientBalance(address account); /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedInnerCall(); /** * @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 AddressInsufficientBalance(address(this)); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert FailedInnerCall(); } } /** * @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 * {FailedInnerCall} 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 AddressInsufficientBalance(address(this)); } (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 {FailedInnerCall}) 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 {FailedInnerCall} 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 {FailedInnerCall}. */ 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 /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert FailedInnerCall(); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; // End consumer library. library VRFV2PlusClient { // extraArgs will evolve to support new features bytes4 public constant EXTRA_ARGS_V1_TAG = bytes4(keccak256("VRF ExtraArgsV1")); struct ExtraArgsV1 { bool nativePayment; } struct RandomWordsRequest { bytes32 keyHash; uint256 subId; uint16 requestConfirmations; uint32 callbackGasLimit; uint32 numWords; bytes extraArgs; } function _argsToBytes(ExtraArgsV1 memory extraArgs) internal pure returns (bytes memory bts) { return abi.encodeWithSelector(EXTRA_ARGS_V1_TAG, extraArgs); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js. pragma solidity ^0.8.20; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ```solidity * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableSet. * ==== */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position is the index of the value in the `values` array plus 1. // Position 0 is used to mean a value is not in the set. mapping(bytes32 value => uint256) _positions; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._positions[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We cache the value's position to prevent multiple reads from the same storage slot uint256 position = set._positions[value]; if (position != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 valueIndex = position - 1; uint256 lastIndex = set._values.length - 1; if (valueIndex != lastIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the lastValue to the index where the value to delete is set._values[valueIndex] = lastValue; // Update the tracked position of the lastValue (that was just moved) set._positions[lastValue] = position; } // Delete the slot where the moved value was stored set._values.pop(); // Delete the tracked position for the deleted slot delete set._positions[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._positions[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values in the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol) pragma solidity ^0.8.20; import {IAccessControl} from "contracts/access/IAccessControl.sol"; import {Context} from "contracts/utils/Context.sol"; import {ERC165} from "contracts/utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ```solidity * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ```solidity * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} * to enforce additional security measures for this role. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address account => bool) hasRole; bytes32 adminRole; } mapping(bytes32 role => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with an {AccessControlUnauthorizedAccount} error including the required role. */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual returns (bool) { return _roles[role].hasRole[account]; } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()` * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier. */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account` * is missing `role`. */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert AccessControlUnauthorizedAccount(account, role); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `callerConfirmation`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address callerConfirmation) public virtual { if (callerConfirmation != _msgSender()) { revert AccessControlBadConfirmation(); } _revokeRole(role, callerConfirmation); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual returns (bool) { if (!hasRole(role, account)) { _roles[role].hasRole[account] = true; emit RoleGranted(role, account, _msgSender()); return true; } else { return false; } } /** * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual returns (bool) { if (hasRole(role, account)) { _roles[role].hasRole[account] = false; emit RoleRevoked(role, account, _msgSender()); return true; } else { return false; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol) pragma solidity ^0.8.20; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev The `account` is missing a role. */ error AccessControlUnauthorizedAccount(address account, bytes32 neededRole); /** * @dev The caller of a function is not the expected one. * * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}. */ error AccessControlBadConfirmation(); /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `callerConfirmation`. */ function renounceRole(bytes32 role, address callerConfirmation) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "contracts/utils/introspection/IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 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.0.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * 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[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.26; import "contracts/access/Ownable2Step.sol"; event ReplaceImplementationStarted(address indexed previousImplementation, address indexed newImplementation); event ReplaceImplementation(address indexed previousImplementation, address indexed newImplementation); error Unauthorized(); contract Upgradeable2Step is Ownable2Step { address public pendingImplementation; address public implementation; constructor() Ownable(msg.sender) {} // called on an inheriting proxy contract function replaceImplementation(address impl_) public onlyOwner { pendingImplementation = impl_; emit ReplaceImplementationStarted(implementation, impl_); } // called from an inheriting implementation contract function acceptImplementation() public { if (msg.sender != pendingImplementation) { revert OwnableUnauthorizedAccount(msg.sender); } emit ReplaceImplementation(implementation, msg.sender); delete pendingImplementation; implementation = msg.sender; } // called on an inheriting implementation contract function becomeImplementation(Upgradeable2Step proxy) public { if (msg.sender != proxy.owner()) { revert Unauthorized(); } proxy.acceptImplementation(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable2Step.sol) pragma solidity ^0.8.20; import {Ownable} from "contracts/access/Ownable.sol"; /** * @dev Contract module which provides access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is specified at deployment time in the constructor for `Ownable`. This * can later be changed with {transferOwnership} and {acceptOwnership}. * * This module is used through inheritance. It will make available all functions * from parent (Ownable). */ abstract contract Ownable2Step is Ownable { address private _pendingOwner; event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner); /** * @dev Returns the address of the pending owner. */ function pendingOwner() public view virtual returns (address) { return _pendingOwner; } /** * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual override onlyOwner { _pendingOwner = newOwner; emit OwnershipTransferStarted(owner(), newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner. * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual override { delete _pendingOwner; super._transferOwnership(newOwner); } /** * @dev The new owner accepts the ownership transfer. */ function acceptOwnership() public virtual { address sender = _msgSender(); if (pendingOwner() != sender) { revert OwnableUnauthorizedAccount(sender); } _transferOwnership(sender); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {Context} from "contracts/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.0.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.20; import {IERC165} from "contracts/utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 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 ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must 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 ERC721 * 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.0.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.20; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 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.0.0) (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.20; import {ERC721} from "contracts/token/ERC721/ERC721.sol"; import {IERC721Enumerable} from "contracts/token/ERC721/extensions/IERC721Enumerable.sol"; import {IERC165} from "contracts/utils/introspection/ERC165.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds enumerability * of all the token ids in the contract as well as all token ids owned by each account. * * CAUTION: `ERC721` extensions that implement custom `balanceOf` logic, such as `ERC721Consecutive`, * interfere with enumerability and should not be used together with `ERC721Enumerable`. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { mapping(address owner => mapping(uint256 index => uint256)) private _ownedTokens; mapping(uint256 tokenId => uint256) private _ownedTokensIndex; uint256[] private _allTokens; mapping(uint256 tokenId => uint256) private _allTokensIndex; /** * @dev An `owner`'s token query was out of bounds for `index`. * * NOTE: The owner being `address(0)` indicates a global out of bounds index. */ error ERC721OutOfBoundsIndex(address owner, uint256 index); /** * @dev Batch mint is not allowed. */ error ERC721EnumerableForbiddenBatchMint(); /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256) { if (index >= balanceOf(owner)) { revert ERC721OutOfBoundsIndex(owner, index); } return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual returns (uint256) { if (index >= totalSupply()) { revert ERC721OutOfBoundsIndex(address(0), index); } return _allTokens[index]; } /** * @dev See {ERC721-_update}. */ function _update(address to, uint256 tokenId, address auth) internal virtual override returns (address) { address previousOwner = super._update(to, tokenId, auth); if (previousOwner == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (previousOwner != to) { _removeTokenFromOwnerEnumeration(previousOwner, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (previousOwner != to) { _addTokenToOwnerEnumeration(to, tokenId); } return previousOwner; } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = balanceOf(to) - 1; _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = balanceOf(from); uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } /** * See {ERC721-_increaseBalance}. We need that to account tokens that were minted in batch */ function _increaseBalance(address account, uint128 amount) internal virtual override { if (amount > 0) { revert ERC721EnumerableForbiddenBatchMint(); } super._increaseBalance(account, amount); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.20; import {IERC721} from "contracts/token/ERC721/IERC721.sol"; import {IERC721Receiver} from "contracts/token/ERC721/IERC721Receiver.sol"; import {IERC721Metadata} from "contracts/token/ERC721/extensions/IERC721Metadata.sol"; import {Context} from "contracts/utils/Context.sol"; import {Strings} from "contracts/utils/Strings.sol"; import {IERC165, ERC165} from "contracts/utils/introspection/ERC165.sol"; import {IERC721Errors} from "contracts/interfaces/draft-IERC6093.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] 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); _checkOnERC721Received(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 ERC721 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 the provided `owner` for the given token or for all its assets * the `spender` for the specific `tokenId`. * * 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); _checkOnERC721Received(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 ERC721 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); _checkOnERC721Received(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; } /** * @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target address. This will revert if the * recipient doesn't accept the token transfer. The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param data bytes optional data to send along with the call */ function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory data) private { if (to.code.length > 0) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) { if (retval != IERC721Receiver.onERC721Received.selector) { revert ERC721InvalidReceiver(to); } } catch (bytes memory reason) { if (reason.length == 0) { revert ERC721InvalidReceiver(to); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.20; import {IERC721} from "contracts/token/ERC721/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.0.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.20; import {IERC721} from "contracts/token/ERC721/IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.26; library NftIndexHelpers { function mpush( uint256[] memory array, uint256 item ) public pure returns(uint256[] memory newArray) { unchecked { newArray = new uint256[](array.length + 1); assembly { mstore(array, mload(newArray)) newArray := array } newArray[newArray.length - 1] = item; } } // Pass the smaller array as array1 for better gas efficiency function mjoin( uint256[] memory array1, uint256[] memory array2 ) public pure returns(uint256[] memory newArray) { unchecked { uint256 len = array2.length; newArray = new uint256[](len + array1.length); assembly { mstore(array2, mload(newArray)) newArray := array2 } for (uint256 i = 0; i < array1.length; i++) { newArray[len + i] = array1[i]; } return newArray; } } // only use for smallish arrays function mpop( uint256[] memory array, uint256 item ) public pure returns(uint256[] memory) { unchecked { uint256 len = array.length; for (uint256 i = 0; i < len; i++) { if (array[i] == item) { len--; array[i] = array[len]; assembly { mstore(array, len) } return array; } } return array; } } }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.26; import "contracts/token/ERC20/IERC20.sol"; import {EnumerableSet} from "contracts/utils/structs/EnumerableSet.sol"; import "contracts/protocol/SharedObjs.sol"; import "contracts/oracle/PriceOracle.sol"; contract NftIndexState { bool internal _initialized; // Vault address[] public listedAssets; mapping(address => SharedObjs.IndexAsset) public indexAssets; mapping(bytes32 => SharedObjs.Nft) public nfts; EnumerableSet.Bytes32Set internal vault; // NFT Index Price PriceOracle public oracle; uint256 public initialLiqPerUsd; // Vault Incentives mapping(int256 => uint) public nftIncentives; int256 public lowestNftsNeeded; int256 public highestNftsNeeded; uint256 public incentivesPool; // The pool of value used to incentivize a representive vault // Redemption mapping(uint256 => SharedObjs.RandomnessRequest) public randomnessRequests; // Stores the redemption callPrice at vrf request and number of nfts to redeem. mapping(address => uint256) public redemptionBalance; // Tracks how much a user has sent for redemptions that have not yet been redeemed. uint256 public redemptionBuffer; uint256 public minLINKBalance; // Fees uint256 public depositFeeRate; uint256 public redemptionFeeRate; uint256 public veFungSpreadRate; uint256 public stakerAllocatedFees; mapping(address => address) public originalTokens; // Whitelists bool public depositWhitelist; bool public redeemWhitelist; // Gaps uint256[49] __gaps; }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.26; contract SharedObjs { enum AssetType { Undefined, ERC721, ERC20 } enum ListedType { UNLISTED, STANDARD, UNINCENTIVIZED, REMOVED } struct IndexAsset { AssetType assetType; ListedType listedType; uint256 workingSize; // Needed for batch deposit vault incentives uint256 totalVaultLiq; uint256 size; // Number of NFTs contained uint256 amount; // For ERC20s } struct Nft { address nftContract; uint256 tokenId; } // Redemptions struct RandomnessRequest { address recipient; address redeemer; uint256 callPrice; uint256 nftCount; uint256 vaultSize; } }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.26; abstract contract PriceOracle { /// @notice Indicator that this is a PriceOracle contract (for inspection) bool public constant isPriceOracle = true; function getAssetPrice(address asset) virtual external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.26; import "contracts/src/v0.8/vrf/dev/interfaces/IVRFCoordinatorV2Plus.sol"; import "contracts/access/Ownable.sol"; import "contracts/src/v0.8/vrf/dev/VRFConsumerBaseV2Plus.sol"; error OnlyCoordinatorCanFulfill(address have, address want); /** * @notice Receiver for random numbers from Chainlink VRF 2.5 */ abstract contract VrfV2PlusConsumer { IVRFCoordinatorV2Plus public immutable s_vrfCoordinator; bytes32 public immutable keyHash; uint32 public immutable callbackGasLimit; uint16 public immutable requestConfirmations; uint256 public immutable s_subscriptionId; uint256[49] __gaps2; /** * @notice Overriden by redemptions to do the callback logic * @param randId The request Id * @param randomWords the random values obtained */ function fulfillRandomWords( uint256 randId, uint256[] memory randomWords ) internal virtual; /** * @notice The callback entry point for VRF. * @param requestId the requestId of the VRF call * @param randomWords The random values obtained */ function rawFulfillRandomWords(uint256 requestId, uint256[] memory randomWords) external { if (msg.sender != address(s_vrfCoordinator)) { revert OnlyCoordinatorCanFulfill(msg.sender, address(s_vrfCoordinator)); } fulfillRandomWords(requestId, randomWords); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {VRFV2PlusClient} from "contracts/src/v0.8/vrf/dev/libraries/VRFV2PlusClient.sol"; import {IVRFSubscriptionV2Plus} from "contracts/src/v0.8/vrf/dev/interfaces/IVRFSubscriptionV2Plus.sol"; // Interface that enables consumers of VRFCoordinatorV2Plus to be future-proof for upgrades // This interface is supported by subsequent versions of VRFCoordinatorV2Plus interface IVRFCoordinatorV2Plus is IVRFSubscriptionV2Plus { /** * @notice Request a set of random words. * @param req - a struct containing following fields for randomness request: * keyHash - Corresponds to a particular oracle job which uses * that key for generating the VRF proof. Different keyHash's have different gas price * ceilings, so you can select a specific one to bound your maximum per request cost. * subId - The ID of the VRF subscription. Must be funded * with the minimum subscription balance required for the selected keyHash. * requestConfirmations - How many blocks you'd like the * oracle to wait before responding to the request. See SECURITY CONSIDERATIONS * for why you may want to request more. The acceptable range is * [minimumRequestBlockConfirmations, 200]. * callbackGasLimit - How much gas you'd like to receive in your * fulfillRandomWords callback. Note that gasleft() inside fulfillRandomWords * may be slightly less than this amount because of gas used calling the function * (argument decoding etc.), so you may need to request slightly more than you expect * to have inside fulfillRandomWords. The acceptable range is * [0, maxGasLimit] * numWords - The number of uint256 random values you'd like to receive * in your fulfillRandomWords callback. Note these numbers are expanded in a * secure way by the VRFCoordinator from a single random value supplied by the oracle. * extraArgs - abi-encoded extra args * @return requestId - A unique identifier of the request. Can be used to match * a request to a response in fulfillRandomWords. */ function requestRandomWords(VRFV2PlusClient.RandomWordsRequest calldata req) external returns (uint256 requestId); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @notice The IVRFSubscriptionV2Plus interface defines the subscription /// @notice related methods implemented by the V2Plus coordinator. interface IVRFSubscriptionV2Plus { /** * @notice Add a consumer to a VRF subscription. * @param subId - ID of the subscription * @param consumer - New consumer which can use the subscription */ function addConsumer(uint256 subId, address consumer) external; /** * @notice Remove a consumer from a VRF subscription. * @param subId - ID of the subscription * @param consumer - Consumer to remove from the subscription */ function removeConsumer(uint256 subId, address consumer) external; /** * @notice Cancel a subscription * @param subId - ID of the subscription * @param to - Where to send the remaining LINK to */ function cancelSubscription(uint256 subId, address to) external; /** * @notice Accept subscription owner transfer. * @param subId - ID of the subscription * @dev will revert if original owner of subId has * not requested that msg.sender become the new owner. */ function acceptSubscriptionOwnerTransfer(uint256 subId) external; /** * @notice Request subscription owner transfer. * @param subId - ID of the subscription * @param newOwner - proposed new owner of the subscription */ function requestSubscriptionOwnerTransfer(uint256 subId, address newOwner) external; /** * @notice Create a VRF subscription. * @return subId - A unique subscription id. * @dev You can manage the consumer set dynamically with addConsumer/removeConsumer. * @dev Note to fund the subscription with LINK, use transferAndCall. For example * @dev LINKTOKEN.transferAndCall( * @dev address(COORDINATOR), * @dev amount, * @dev abi.encode(subId)); * @dev Note to fund the subscription with Native, use fundSubscriptionWithNative. Be sure * @dev to send Native with the call, for example: * @dev COORDINATOR.fundSubscriptionWithNative{value: amount}(subId); */ function createSubscription() external returns (uint256 subId); /** * @notice Get a VRF subscription. * @param subId - ID of the subscription * @return balance - LINK balance of the subscription in juels. * @return nativeBalance - native balance of the subscription in wei. * @return reqCount - Requests count of subscription. * @return owner - owner of the subscription. * @return consumers - list of consumer address which are able to use this subscription. */ function getSubscription( uint256 subId ) external view returns (uint96 balance, uint96 nativeBalance, uint64 reqCount, address owner, address[] memory consumers); /* * @notice Check to see if there exists a request commitment consumers * for all consumers and keyhashes for a given sub. * @param subId - ID of the subscription * @return true if there exists at least one unfulfilled request for the subscription, false * otherwise. */ function pendingRequestExists(uint256 subId) external view returns (bool); /** * @notice Paginate through all active VRF subscriptions. * @param startIndex index of the subscription to start from * @param maxCount maximum number of subscriptions to return, 0 to return all * @dev the order of IDs in the list is **not guaranteed**, therefore, if making successive calls, one * @dev should consider keeping the blockheight constant to ensure a holistic picture of the contract state */ function getActiveSubscriptionIds(uint256 startIndex, uint256 maxCount) external view returns (uint256[] memory); /** * @notice Fund a subscription with native. * @param subId - ID of the subscription * @notice This method expects msg.value to be greater than or equal to 0. */ function fundSubscriptionWithNative(uint256 subId) external payable; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import {IVRFCoordinatorV2Plus} from "contracts/src/v0.8/vrf/dev/interfaces/IVRFCoordinatorV2Plus.sol"; import {IVRFMigratableConsumerV2Plus} from "contracts/src/v0.8/vrf/dev/interfaces/IVRFMigratableConsumerV2Plus.sol"; import {ConfirmedOwner} from "contracts/src/v0.8/shared/access/ConfirmedOwner.sol"; /** **************************************************************************** * @notice Interface for contracts using VRF randomness * ***************************************************************************** * @dev PURPOSE * * @dev Reggie the Random Oracle (not his real job) wants to provide randomness * @dev to Vera the verifier in such a way that Vera can be sure he's not * @dev making his output up to suit himself. Reggie provides Vera a public key * @dev to which he knows the secret key. Each time Vera provides a seed to * @dev Reggie, he gives back a value which is computed completely * @dev deterministically from the seed and the secret key. * * @dev Reggie provides a proof by which Vera can verify that the output was * @dev correctly computed once Reggie tells it to her, but without that proof, * @dev the output is indistinguishable to her from a uniform random sample * @dev from the output space. * * @dev The purpose of this contract is to make it easy for unrelated contracts * @dev to talk to Vera the verifier about the work Reggie is doing, to provide * @dev simple access to a verifiable source of randomness. It ensures 2 things: * @dev 1. The fulfillment came from the VRFCoordinatorV2Plus. * @dev 2. The consumer contract implements fulfillRandomWords. * ***************************************************************************** * @dev USAGE * * @dev Calling contracts must inherit from VRFConsumerBaseV2Plus, and can * @dev initialize VRFConsumerBaseV2Plus's attributes in their constructor as * @dev shown: * * @dev contract VRFConsumerV2Plus is VRFConsumerBaseV2Plus { * @dev constructor(<other arguments>, address _vrfCoordinator, address _subOwner) * @dev VRFConsumerBaseV2Plus(_vrfCoordinator, _subOwner) public { * @dev <initialization with other arguments goes here> * @dev } * @dev } * * @dev The oracle will have given you an ID for the VRF keypair they have * @dev committed to (let's call it keyHash). Create a subscription, fund it * @dev and your consumer contract as a consumer of it (see VRFCoordinatorInterface * @dev subscription management functions). * @dev Call requestRandomWords(keyHash, subId, minimumRequestConfirmations, * @dev callbackGasLimit, numWords, extraArgs), * @dev see (IVRFCoordinatorV2Plus for a description of the arguments). * * @dev Once the VRFCoordinatorV2Plus has received and validated the oracle's response * @dev to your request, it will call your contract's fulfillRandomWords method. * * @dev The randomness argument to fulfillRandomWords is a set of random words * @dev generated from your requestId and the blockHash of the request. * * @dev If your contract could have concurrent requests open, you can use the * @dev requestId returned from requestRandomWords to track which response is associated * @dev with which randomness request. * @dev See "SECURITY CONSIDERATIONS" for principles to keep in mind, * @dev if your contract could have multiple requests in flight simultaneously. * * @dev Colliding `requestId`s are cryptographically impossible as long as seeds * @dev differ. * * ***************************************************************************** * @dev SECURITY CONSIDERATIONS * * @dev A method with the ability to call your fulfillRandomness method directly * @dev could spoof a VRF response with any random value, so it's critical that * @dev it cannot be directly called by anything other than this base contract * @dev (specifically, by the VRFConsumerBaseV2Plus.rawFulfillRandomness method). * * @dev For your users to trust that your contract's random behavior is free * @dev from malicious interference, it's best if you can write it so that all * @dev behaviors implied by a VRF response are executed *during* your * @dev fulfillRandomness method. If your contract must store the response (or * @dev anything derived from it) and use it later, you must ensure that any * @dev user-significant behavior which depends on that stored value cannot be * @dev manipulated by a subsequent VRF request. * * @dev Similarly, both miners and the VRF oracle itself have some influence * @dev over the order in which VRF responses appear on the blockchain, so if * @dev your contract could have multiple VRF requests in flight simultaneously, * @dev you must ensure that the order in which the VRF responses arrive cannot * @dev be used to manipulate your contract's user-significant behavior. * * @dev Since the block hash of the block which contains the requestRandomness * @dev call is mixed into the input to the VRF *last*, a sufficiently powerful * @dev miner could, in principle, fork the blockchain to evict the block * @dev containing the request, forcing the request to be included in a * @dev different block with a different hash, and therefore a different input * @dev to the VRF. However, such an attack would incur a substantial economic * @dev cost. This cost scales with the number of blocks the VRF oracle waits * @dev until it calls responds to a request. It is for this reason that * @dev that you can signal to an oracle you'd like them to wait longer before * @dev responding to the request (however this is not enforced in the contract * @dev and so remains effective only in the case of unmodified oracle software). */ abstract contract VRFConsumerBaseV2Plus is IVRFMigratableConsumerV2Plus, ConfirmedOwner { error OnlyCoordinatorCanFulfill(address have, address want); error OnlyOwnerOrCoordinator(address have, address owner, address coordinator); error ZeroAddress(); // s_vrfCoordinator should be used by consumers to make requests to vrfCoordinator // so that coordinator reference is updated after migration IVRFCoordinatorV2Plus public s_vrfCoordinator; /** * @param _vrfCoordinator address of VRFCoordinator contract */ constructor(address _vrfCoordinator) ConfirmedOwner(msg.sender) { if (_vrfCoordinator == address(0)) { revert ZeroAddress(); } s_vrfCoordinator = IVRFCoordinatorV2Plus(_vrfCoordinator); } /** * @notice fulfillRandomness handles the VRF response. Your contract must * @notice implement it. See "SECURITY CONSIDERATIONS" above for important * @notice principles to keep in mind when implementing your fulfillRandomness * @notice method. * * @dev VRFConsumerBaseV2Plus expects its subcontracts to have a method with this * @dev signature, and will call it once it has verified the proof * @dev associated with the randomness. (It is triggered via a call to * @dev rawFulfillRandomness, below.) * * @param requestId The Id initially returned by requestRandomness * @param randomWords the VRF output expanded to the requested number of words */ // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore function fulfillRandomWords(uint256 requestId, uint256[] memory randomWords) internal virtual; // rawFulfillRandomness is called by VRFCoordinator when it receives a valid VRF // proof. rawFulfillRandomness then calls fulfillRandomness, after validating // the origin of the call function rawFulfillRandomWords(uint256 requestId, uint256[] memory randomWords) external { if (msg.sender != address(s_vrfCoordinator)) { revert OnlyCoordinatorCanFulfill(msg.sender, address(s_vrfCoordinator)); } fulfillRandomWords(requestId, randomWords); } /** * @inheritdoc IVRFMigratableConsumerV2Plus */ function setCoordinator(address _vrfCoordinator) external override onlyOwnerOrCoordinator { if (_vrfCoordinator == address(0)) { revert ZeroAddress(); } s_vrfCoordinator = IVRFCoordinatorV2Plus(_vrfCoordinator); emit CoordinatorSet(_vrfCoordinator); } modifier onlyOwnerOrCoordinator() { if (msg.sender != owner() && msg.sender != address(s_vrfCoordinator)) { revert OnlyOwnerOrCoordinator(msg.sender, owner(), address(s_vrfCoordinator)); } _; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @notice The IVRFMigratableConsumerV2Plus interface defines the /// @notice method required to be implemented by all V2Plus consumers. /// @dev This interface is designed to be used in VRFConsumerBaseV2Plus. interface IVRFMigratableConsumerV2Plus { event CoordinatorSet(address vrfCoordinator); /// @notice Sets the VRF Coordinator address /// @notice This method should only be callable by the coordinator or contract owner function setCoordinator(address vrfCoordinator) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {ConfirmedOwnerWithProposal} from "contracts/src/v0.8/shared/access/ConfirmedOwnerWithProposal.sol"; /// @title The ConfirmedOwner contract /// @notice A contract with helpers for basic contract ownership. contract ConfirmedOwner is ConfirmedOwnerWithProposal { constructor(address newOwner) ConfirmedOwnerWithProposal(newOwner, address(0)) {} }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {IOwnable} from "contracts/src/v0.8/shared/interfaces/IOwnable.sol"; /// @title The ConfirmedOwner contract /// @notice A contract with helpers for basic contract ownership. contract ConfirmedOwnerWithProposal is IOwnable { address private s_owner; address private s_pendingOwner; event OwnershipTransferRequested(address indexed from, address indexed to); event OwnershipTransferred(address indexed from, address indexed to); constructor(address newOwner, address pendingOwner) { // solhint-disable-next-line gas-custom-errors require(newOwner != address(0), "Cannot set owner to zero"); s_owner = newOwner; if (pendingOwner != address(0)) { _transferOwnership(pendingOwner); } } /// @notice Allows an owner to begin transferring ownership to a new address. function transferOwnership(address to) public override onlyOwner { _transferOwnership(to); } /// @notice Allows an ownership transfer to be completed by the recipient. function acceptOwnership() external override { // solhint-disable-next-line gas-custom-errors require(msg.sender == s_pendingOwner, "Must be proposed owner"); address oldOwner = s_owner; s_owner = msg.sender; s_pendingOwner = address(0); emit OwnershipTransferred(oldOwner, msg.sender); } /// @notice Get the current owner function owner() public view override returns (address) { return s_owner; } /// @notice validate, transfer ownership, and emit relevant events function _transferOwnership(address to) private { // solhint-disable-next-line gas-custom-errors require(to != msg.sender, "Cannot transfer to self"); s_pendingOwner = to; emit OwnershipTransferRequested(s_owner, to); } /// @notice validate access function _validateOwnership() internal view { // solhint-disable-next-line gas-custom-errors require(msg.sender == s_owner, "Only callable by owner"); } /// @notice Reverts if called by anyone other than the contract owner. modifier onlyOwner() { _validateOwnership(); _; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IOwnable { function owner() external returns (address); function transferOwnership(address recipient) external; function acceptOwnership() external; }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.26; import {PriceOracle} from "contracts/oracle/PriceOracle.sol"; import {SharedObjs} from "contracts/protocol/SharedObjs.sol"; interface INftIndex { // Events event DepositNFT(address indexed depositer, address indexed recipient, bytes32 key, address indexed collection, uint256 tokenId, uint256 price, uint256 stakersCut, uint256 sellerMintCut, uint256 sellerPoolCut, uint256 protocolCut); event NewPriceOracle(PriceOracle oldPriceOracle, PriceOracle newPriceOracle); event RedemptionRequested(address indexed redeemer, uint256 requestId, uint256 highestFloor, uint256 nftCount); event AddAsset(address user, address assetAddress, SharedObjs.AssetType assetType, SharedObjs.ListedType listedType); event RemoveAsset(address user, address assetAddress); event ChangeAssetListing(address user, address assetAddress, SharedObjs.ListedType oldListedType, SharedObjs.ListedType newListedType); event WithdrawNFT(address indexed redeemer, address indexed recipient, bytes32 key, address indexed nftContract, uint256 tokenId, uint256 stickerPrice, uint256 currentPrice, uint256 fee, bool redeemed); event RefundRedeemer(address indexed redeemer, uint256 amount); event ExtractAndDistribute(uint256 toStaking, uint256 toVesting); // Errors error AlreadyInitialized(); error InvalidDeposit(); error InvalidValue(); error NoEthSent(); error InvalidAsset(); error InvalidListedType(); error NonEmptyAsset(); error AssetNotFound(); error ArrayMismatch(); error ExpiredPermit(); error UninitializedDomainSeparator(); error InvalidPermitSignature(); error TokenIsReceiver(); error AssetExists(); error InvalidRedemption(); error BalanceMismatch(); error EmptyVault(); error InsufficientBalance(); error InsufficientLINKBalance(); error InsufficientRedemptionBalance(); error ArrayLengthMismatch(); error IncentiveIsZero(); error NftsNeededNotIncreasing(); error IncentiveNotIncreasing(); error ZeroNftsNeededMustHaveOneHundredPctIncentive(); error LessThanMinimalAmount(); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.26; import "contracts/token/ERC20/IERC20.sol"; interface IsNftIndex is IERC20 { // Errors error ExpiredPermit(); error UninitializedDomainSeparator(); error InvalidPermitSignature(); error AlreadyInitialized(); // Events event LiqStake(address indexed user, uint256 liqAmount, uint256 xLiqAmount); event LiqUnstake(address indexed user, uint256 liqAmount, uint256 xLiqAmount); event RewardAdded(uint256 rewardAmount); // Functions function tokenPrice() external view returns (uint256); function xLiqToLiq(uint256 xLiqAmount) external view returns(uint256 liqAmount); function liqToXLiq(uint256 liqAmount) external view returns(uint256 xLiqAmount); function stake(uint256 liqAmount) external; function unstake(uint256 liqAmount) external; function addRewards(uint256 rewardsAmount) external; }
{ "evmVersion": "shanghai", "optimizer": { "enabled": true, "runs": 200 }, "libraries": { "NftIndex.sol": {} }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_veFUNG","type":"address"},{"internalType":"address","name":"_liqStaking","type":"address"},{"internalType":"address","name":"_vrfCoordinator","type":"address"},{"internalType":"bytes32","name":"_keyHash","type":"bytes32"},{"internalType":"uint32","name":"_callbackGasLimit","type":"uint32"},{"internalType":"uint16","name":"_requestConfirmations","type":"uint16"},{"internalType":"uint256","name":"_subscriptionId","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[],"name":"AlreadyInitialized","type":"error"},{"inputs":[],"name":"ArrayLengthMismatch","type":"error"},{"inputs":[],"name":"ArrayMismatch","type":"error"},{"inputs":[],"name":"AssetExists","type":"error"},{"inputs":[],"name":"AssetNotFound","type":"error"},{"inputs":[],"name":"BalanceMismatch","type":"error"},{"inputs":[],"name":"ECDSAInvalidSignature","type":"error"},{"inputs":[{"internalType":"uint256","name":"length","type":"uint256"}],"name":"ECDSAInvalidSignatureLength","type":"error"},{"inputs":[{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"ECDSAInvalidSignatureS","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"allowance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientAllowance","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC20InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC20InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC20InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"}],"name":"ERC20InvalidSpender","type":"error"},{"inputs":[{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"ERC2612ExpiredSignature","type":"error"},{"inputs":[{"internalType":"address","name":"signer","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"ERC2612InvalidSigner","type":"error"},{"inputs":[],"name":"EmptyVault","type":"error"},{"inputs":[],"name":"ExpiredPermit","type":"error"},{"inputs":[],"name":"IncentiveIsZero","type":"error"},{"inputs":[],"name":"IncentiveNotIncreasing","type":"error"},{"inputs":[],"name":"InsufficientBalance","type":"error"},{"inputs":[],"name":"InsufficientLINKBalance","type":"error"},{"inputs":[],"name":"InsufficientRedemptionBalance","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"currentNonce","type":"uint256"}],"name":"InvalidAccountNonce","type":"error"},{"inputs":[],"name":"InvalidAsset","type":"error"},{"inputs":[],"name":"InvalidDeposit","type":"error"},{"inputs":[],"name":"InvalidListedType","type":"error"},{"inputs":[],"name":"InvalidPermitSignature","type":"error"},{"inputs":[],"name":"InvalidRedemption","type":"error"},{"inputs":[],"name":"InvalidShortString","type":"error"},{"inputs":[],"name":"InvalidValue","type":"error"},{"inputs":[],"name":"LessThanMinimalAmount","type":"error"},{"inputs":[],"name":"NftsNeededNotIncreasing","type":"error"},{"inputs":[],"name":"NoEthSent","type":"error"},{"inputs":[],"name":"NonEmptyAsset","type":"error"},{"inputs":[{"internalType":"address","name":"have","type":"address"},{"internalType":"address","name":"want","type":"address"}],"name":"OnlyCoordinatorCanFulfill","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":[{"internalType":"string","name":"str","type":"string"}],"name":"StringTooLong","type":"error"},{"inputs":[],"name":"TokenIsReceiver","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"inputs":[],"name":"UninitializedDomainSeparator","type":"error"},{"inputs":[],"name":"ZeroNftsNeededMustHaveOneHundredPctIncentive","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"assetAddress","type":"address"},{"indexed":false,"internalType":"enum SharedObjs.AssetType","name":"assetType","type":"uint8"},{"indexed":false,"internalType":"enum SharedObjs.ListedType","name":"listedType","type":"uint8"}],"name":"AddAsset","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"assetAddress","type":"address"},{"indexed":false,"internalType":"enum SharedObjs.ListedType","name":"oldListedType","type":"uint8"},{"indexed":false,"internalType":"enum SharedObjs.ListedType","name":"newListedType","type":"uint8"}],"name":"ChangeAssetListing","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"depositer","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"bytes32","name":"key","type":"bytes32"},{"indexed":true,"internalType":"address","name":"collection","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"stakersCut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"sellerMintCut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"sellerPoolCut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"protocolCut","type":"uint256"}],"name":"DepositNFT","type":"event"},{"anonymous":false,"inputs":[],"name":"EIP712DomainChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"toStaking","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"toVesting","type":"uint256"}],"name":"ExtractAndDistribute","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract PriceOracle","name":"oldPriceOracle","type":"address"},{"indexed":false,"internalType":"contract PriceOracle","name":"newPriceOracle","type":"address"}],"name":"NewPriceOracle","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"redeemer","type":"address"},{"indexed":false,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"highestFloor","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nftCount","type":"uint256"}],"name":"RedemptionRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"redeemer","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RefundRedeemer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"assetAddress","type":"address"}],"name":"RemoveAsset","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousImplementation","type":"address"},{"indexed":true,"internalType":"address","name":"newImplementation","type":"address"}],"name":"ReplaceImplementation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousImplementation","type":"address"},{"indexed":true,"internalType":"address","name":"newImplementation","type":"address"}],"name":"ReplaceImplementationStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"redeemer","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"bytes32","name":"key","type":"bytes32"},{"indexed":true,"internalType":"address","name":"nftContract","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"stickerPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"currentPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"},{"indexed":false,"internalType":"bool","name":"redeemed","type":"bool"}],"name":"WithdrawNFT","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEPOSITOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"INTERNAL_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"REDEEMER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptImplementation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"assetAddress","type":"address"},{"internalType":"enum SharedObjs.AssetType","name":"assetType","type":"uint8"},{"internalType":"enum SharedObjs.ListedType","name":"listedType","type":"uint8"}],"name":"addAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"nftContract","type":"address"}],"name":"assetVaultValue","outputs":[{"internalType":"uint256","name":"vaultValue","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseRedeemPrice","outputs":[{"internalType":"uint256","name":"basePrice","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract Upgradeable2Step","name":"proxy","type":"address"}],"name":"becomeImplementation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"floorVal","type":"uint256"},{"internalType":"uint256","name":"vaultIncentiveRate","type":"uint256"},{"internalType":"uint256","name":"_incentivesPool","type":"uint256"}],"name":"calculateDepositFeeDistribution","outputs":[{"internalType":"uint256","name":"stakersCut","type":"uint256"},{"internalType":"uint256","name":"sellerMintCut","type":"uint256"},{"internalType":"uint256","name":"sellerPoolCut","type":"uint256"},{"internalType":"uint256","name":"protocolCut","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"nftContract","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"internalType":"struct SharedObjs.Nft[]","name":"assets","type":"tuple[]"}],"name":"calculateDepositOutputAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"callbackGasLimit","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"assetAddress","type":"address"},{"internalType":"enum SharedObjs.ListedType","name":"listedType","type":"uint8"}],"name":"changeAssetListing","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"nftContract","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"internalType":"struct SharedObjs.Nft[]","name":"assets","type":"tuple[]"},{"internalType":"uint256","name":"minimalAmount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"depositFeeRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"depositWhitelist","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"extractAndDistributeFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"nftContract","type":"address"}],"name":"getBaseRedemptionPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"assetAddress","type":"address"}],"name":"getIndexAssetDetails","outputs":[{"components":[{"internalType":"enum SharedObjs.AssetType","name":"assetType","type":"uint8"},{"internalType":"enum SharedObjs.ListedType","name":"listedType","type":"uint8"},{"internalType":"uint256","name":"workingSize","type":"uint256"},{"internalType":"uint256","name":"totalVaultLiq","type":"uint256"},{"internalType":"uint256","name":"size","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct SharedObjs.IndexAsset","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"highestNftsNeeded","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"implementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"incentivesPool","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"indexAssets","outputs":[{"internalType":"enum SharedObjs.AssetType","name":"assetType","type":"uint8"},{"internalType":"enum SharedObjs.ListedType","name":"listedType","type":"uint8"},{"internalType":"uint256","name":"workingSize","type":"uint256"},{"internalType":"uint256","name":"totalVaultLiq","type":"uint256"},{"internalType":"uint256","name":"size","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initialLiqPerUsd","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract PriceOracle","name":"_oracle","type":"address"},{"internalType":"int256[]","name":"nftsNeeded","type":"int256[]"},{"internalType":"uint256[]","name":"incentives","type":"uint256[]"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"keyHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"liqStaking","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"liqAmount","type":"uint256"}],"name":"liqToUsd","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"listedAssets","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"listedAssetsSize","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lowestNftsNeeded","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minLINKBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"nftContract","type":"address"}],"name":"nftAssetsNeeded","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"nftContract","type":"address"}],"name":"nftContractMarketCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"nftContract","type":"address"},{"internalType":"uint256","name":"totalMarketCap","type":"uint256"}],"name":"nftContractTargetWeight","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"int256","name":"","type":"int256"}],"name":"nftIncentives","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"nfts","outputs":[{"internalType":"address","name":"nftContract","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"int256","name":"nftsNeeded","type":"int256"}],"name":"nftsNeededToIncentiveRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"oracle","outputs":[{"internalType":"contract PriceOracle","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"originalTokens","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingImplementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"randomnessRequests","outputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"redeemer","type":"address"},{"internalType":"uint256","name":"callPrice","type":"uint256"},{"internalType":"uint256","name":"nftCount","type":"uint256"},{"internalType":"uint256","name":"vaultSize","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"},{"internalType":"uint256[]","name":"randomWords","type":"uint256[]"}],"name":"rawFulfillRandomWords","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"nftCount","type":"uint256"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"requestId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"redeemWhitelist","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"redemptionBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"redemptionBuffer","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"redemptionFeeRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"redeemer","type":"address"}],"name":"refundRedeemer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"assetAddress","type":"address"}],"name":"removeAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"impl_","type":"address"}],"name":"replaceImplementation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"requestConfirmations","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"s_subscriptionId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"s_vrfCoordinator","outputs":[{"internalType":"contract IVRFCoordinatorV2Plus","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"newDepositFeeRate","type":"uint256"}],"name":"setDepositFeeRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"status","type":"bool"}],"name":"setDepositWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newInitialPrice","type":"uint256"}],"name":"setInitialLiqPerUsd","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newMinLINKBalance","type":"uint256"}],"name":"setMinLINKBalance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"int256[]","name":"nftsNeeded","type":"int256[]"},{"internalType":"uint256[]","name":"incentives","type":"uint256[]"}],"name":"setNftIncentives","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"nftContract","type":"address"},{"internalType":"address","name":"original","type":"address"}],"name":"setOriginalTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract PriceOracle","name":"newOracle","type":"address"}],"name":"setPriceOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"status","type":"bool"}],"name":"setRedeemWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newRedemptionBuffer","type":"uint256"}],"name":"setRedemptionBuffer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newRedemptionFeeRate","type":"uint256"}],"name":"setRedemptionFeeRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newVeFungSpreadRate","type":"uint256"}],"name":"setVeFungSpreadRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"redeemer","type":"address"}],"name":"sinkRedeemer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakerAllocatedFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"standardAssetMarketCap","outputs":[{"internalType":"uint256","name":"totalValue","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalStandardVaultValue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalVaultValue","outputs":[{"internalType":"uint256","name":"totalValue","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"usdAmount","type":"uint256"}],"name":"usdToLiq","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"veFUNG","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"veFungSpreadRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
610240604052348015610010575f80fd5b50604051615d3b380380615d3b83398101604081905261002f916102ed565b60408051808201909152601181527008ceadcced2ccf2409c8ca84092dcc8caf607b1b60208201526040805180820190915260018152603160f81b6020820152819061009f60408051808201909152601181527008ceadcced2ccf2409c8ca84092dcc8caf607b1b602082015290565b60408051808201909152600381526213919560ea1b602082015233806100df57604051631e4fbdf760e01b81525f60048201526024015b60405180910390fd5b6100e8816101f8565b5060086100f58382610411565b5060096101028282610411565b506101129150839050600a610214565b6101205261012181600b610214565b61014052815160208084019190912060e052815190820120610100524660a0526101ad60e05161010051604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201529081019290925260608201524660808201523060a08201525f9060c00160405160208183030381529060405280519060200120905090565b60805250503060c052506001600160a01b03968716610200529486166102205292909416610160526101805263ffffffff9092166101a05261ffff9091166101c0526101e052610539565b600180546001600160a01b031916905561021181610246565b50565b5f60208351101561022f5761022883610295565b9050610240565b8161023a8482610411565b5060ff90505b92915050565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b5f80829050601f815111156102bf578260405163305a27a960e01b81526004016100d691906104cb565b80516102ca82610516565b179392505050565b80516001600160a01b03811681146102e8575f80fd5b919050565b5f805f805f805f60e0888a031215610303575f80fd5b61030c886102d2565b965061031a602089016102d2565b9550610328604089016102d2565b945060608801519350608088015163ffffffff81168114610347575f80fd5b60a089015190935061ffff8116811461035e575f80fd5b60c09890980151969995985093969295919492935090919050565b634e487b7160e01b5f52604160045260245ffd5b600181811c908216806103a157607f821691505b6020821081036103bf57634e487b7160e01b5f52602260045260245ffd5b50919050565b601f82111561040c57805f5260205f20601f840160051c810160208510156103ea5750805b601f840160051c820191505b81811015610409575f81556001016103f6565b50505b505050565b81516001600160401b0381111561042a5761042a610379565b61043e81610438845461038d565b846103c5565b6020601f821160018114610470575f83156104595750848201515b5f19600385901b1c1916600184901b178455610409565b5f84815260208120601f198516915b8281101561049f578785015182556020948501946001909201910161047f565b50848210156104bc57868401515f19600387901b60f8161c191681555b50505050600190811b01905550565b602081525f82518060208401525f5b818110156104f757602081860181015160408684010152016104da565b505f604082850101526040601f19601f83011684010191505092915050565b805160208083015191908110156103bf575f1960209190910360031b1b16919050565b60805160a05160c05160e05161010051610120516101405161016051610180516101a0516101c0516101e05161020051610220516157096106325f395f818161086d015281816111f80152818161124f015261128a01525f81816106630152818161117a01526111d101525f8181610a67015281816129570152612a8b01525f8181610c060152612ab101525f818161072e0152612adb01525f818161095e0152612a6501525f8181610aff015281816113b6015281816113f80152818161297f0152612a2b01525f613df201525f613dc501525f613cbe01525f613c9601525f613bf101525f613c1b01525f613c4501526157095ff3fe608060405234801561000f575f80fd5b5060043610610553575f3560e01c80637fa46ab4116102bf578063beff682411610186578063e657a2b2116100ef578063f2fde38b116100a9578063f74032f011610084578063f74032f014610e44578063fac24d5714610e6c578063fe3ee9c114610e74578063ffd497b914610e87575f80fd5b8063f2fde38b14610e15578063f398332414610e28578063f447a63714610e31575f80fd5b8063e657a2b214610d6b578063eaac8c3214610d7e578063ec70cbc714610d91578063ed5614b614610da3578063efe1d6d314610dac578063f242c9e014610dbf575f80fd5b8063d547741f11610140578063d547741f14610cd6578063d69efdc514610ce9578063db006a7514610cfc578063dd62ed3e14610d0f578063dfb3cdc214610d47578063e30c397814610d5a575f80fd5b8063beff682414610c6d578063c60a04d714610c81578063caa8dac514610c8a578063d25e679814610c9d578063d419db6714610cb0578063d505accf14610cc3575f80fd5b80639eccacf611610228578063af19f4e1116101e2578063af19f4e114610b95578063afbc74b914610ba8578063afdc611114610bb0578063b0fb162f14610c01578063b52d2efe14610c3b578063bac19d1f14610c5a575f80fd5b80639eccacf614610afa578063a217fddf14610b21578063a3b0b5a314610b28578063a9059cbb14610b4f578063aa36d1d714610b62578063ab78af6714610b82575f80fd5b80638da5cb5b116102795780638da5cb5b14610a895780638e583ca214610a995780638e691b9a14610aac57806391d1485414610abf57806395d89b4114610ad25780639d8bb82f14610af1575f80fd5b80637fa46ab4146109f157806384b0196e14610a18578063851d342514610a33578063852cb9b814610a465780638705057814610a4f5780638ac0002114610a62575f80fd5b80632dc726841161041d57806348d3b7751161038657806361728f3911610340578063715018a61161031b578063715018a6146109bb57806379ba5097146109c35780637dc0d1d0146109cb5780637ecebe00146109de575f80fd5b806361728f39146109595780636fa62b621461098057806370a0823114610993575f80fd5b806348d3b7751461088f5780634a5e42b11461089c578063530e784f146108af5780635a672e81146108c25780635c60da1b146108cb5780635cb6dfff146108de575f80fd5b8063374e72f5116103d7578063374e72f5146107fd578063396f7b231461081c5780633a7bd60c1461082f5780633cc9f456146108425780634105a7dd1461085557806341dbad9a14610868575f80fd5b80632dc72684146107af5780632f2ff15d146107b757806330f1e782146107ca578063313ce567146107d35780633644e515146107e257806336568abe146107ea575f80fd5b80631afb8755116104bf57806324f746971161047957806324f746971461072957806325125e17146107655780632605d55d1461076e578063284c853b146107815780632abe9203146107945780632afbd567146107a7575f80fd5b80631afb87551461069d5780631cb734b2146106a55780631fe543e3146106ae57806320bb2ba4146106c157806323b872dd146106f4578063248a9ca314610707575f80fd5b806315ba56e51161051057806315ba56e51461061357806318160ddd1461061d5780631900ff23146106255780631a098186146106385780631acede4c1461064b5780631af99aca1461065e575f80fd5b806301ffc9a714610557578063038ddfe81461057f57806306fdde0314610596578063095ea7b3146105cc5780630ec38145146105df578063150b7a02146105e7575b5f80fd5b61056a610565366004614b70565b610e9a565b60405190151581526020015b60405180910390f35b61058860515481565b604051908152602001610576565b60408051808201909152601181527008ceadcced2ccf2409c8ca84092dcc8caf607b1b60208201525b6040516105769190614bda565b61056a6105da366004614c00565b610ed0565b603f54610588565b6105fa6105f5366004614c2a565b610ee7565b6040516001600160e01b03199091168152602001610576565b61061b610f23565b005b600754610588565b61061b610633366004614ccf565b610fac565b61061b610646366004614d02565b6110bb565b610588610659366004614c00565b6110ed565b6106857f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610576565b61061b61112a565b610588604d5481565b61061b6106bc366004614d87565b6113ab565b6106d46106cf366004614e28565b611433565b604080519485526020850193909352918301526060820152608001610576565b61056a610702366004614e51565b6114e3565b610588610715366004614e8f565b5f9081526004602052604090206001015490565b6107507f000000000000000000000000000000000000000000000000000000000000000081565b60405163ffffffff9091168152602001610576565b610588604c5481565b61061b61077c366004614e8f565b611506565b61058861078f366004614e8f565b61154c565b61061b6107a2366004614ea6565b61155e565b6105886115bf565b610588611676565b61061b6107c5366004614ec1565b6116d8565b61058860455481565b60405160128152602001610576565b610588611702565b61061b6107f8366004614ec1565b611710565b61058861080b366004614e8f565b60466020525f908152604090205481565b600254610685906001600160a01b031681565b61061b61083d366004614f36565b611743565b610588610850366004614ea6565b611815565b61061b610863366004614d02565b6118b3565b6106857f000000000000000000000000000000000000000000000000000000000000000081565b60535461056a9060ff1681565b61061b6108aa366004614ea6565b6118de565b61061b6108bd366004614ea6565b611b40565b61058860485481565b600354610685906001600160a01b031681565b6109266108ec366004614e8f565b604a6020525f9081526040902080546001820154600283015460038401546004909401546001600160a01b03938416949390921692909185565b604080516001600160a01b039687168152959094166020860152928401919091526060830152608082015260a001610576565b6105887f000000000000000000000000000000000000000000000000000000000000000081565b61058861098e366004614e8f565b611bb1565b6105886109a1366004614ea6565b6001600160a01b03165f9081526005602052604090205490565b61061b611c09565b61061b611c1c565b604454610685906001600160a01b031681565b6105886109ec366004614ea6565b611c60565b6105887f44ac9762eec3a11893fefb11d028bb3102560094137c3ed4518712475b2577cc81565b610a20611c7d565b6040516105769796959493929190614fb6565b610588610a41366004614e8f565b611cbf565b610588604e5481565b610588610a5d366004614ea6565b611cd1565b6105887f000000000000000000000000000000000000000000000000000000000000000081565b5f546001600160a01b0316610685565b61061b610aa736600461504c565b611d12565b61061b610aba366004614e8f565b611ed1565b61056a610acd366004614ec1565b611f17565b60408051808201909152600381526213919560ea1b60208201526105bf565b61058860505481565b6106857f000000000000000000000000000000000000000000000000000000000000000081565b6105885f81565b6105887f8f4f2da22e8ac8f11e15f9fc141cddbb5deea8800186560abb6e68c5496619a981565b61056a610b5d366004614c00565b611f41565b610b75610b70366004614ea6565b611f4e565b60405161057691906150cb565b610685610b90366004614e8f565b612033565b610588610ba336600461515e565b61205b565b610588612327565b610be2610bbe366004614e8f565b60416020525f9081526040902080546001909101546001600160a01b039091169082565b604080516001600160a01b039093168352602083019190915201610576565b610c287f000000000000000000000000000000000000000000000000000000000000000081565b60405161ffff9091168152602001610576565b610588610c49366004614ea6565b604b6020525f908152604090205481565b61061b610c68366004614e8f565b61237d565b6105885f805160206156b483398151915281565b61058860475481565b61061b610c9836600461519c565b61239a565b610588610cab366004614ea6565b612524565b61061b610cbe366004614e8f565b612650565b61061b610cd1366004615206565b61266d565b61061b610ce4366004614ec1565b6127a3565b61061b610cf7366004614ea6565b6127c7565b610588610d0a366004614e8f565b612820565b610588610d1d366004615277565b6001600160a01b039182165f90815260066020908152604080832093909416825291909152205490565b61061b610d55366004614ea6565b612c77565b6001546001600160a01b0316610685565b610588610d79366004614ea6565b612cb0565b61061b610d8c366004614ea6565b612d34565b60535461056a90610100900460ff1681565b610588604f5481565b61061b610dba3660046152a3565b612e15565b610e03610dcd366004614ea6565b604060208190525f9182529020805460018201546002830154600384015460049094015460ff8085169561010090950416939086565b604051610576969594939291906152ea565b61061b610e23366004614ea6565b61343f565b61058860495481565b61061b610e3f366004615277565b6134af565b610685610e52366004614ea6565b60526020525f90815260409020546001600160a01b031681565b6105886134f4565b61061b610e82366004614e8f565b613645565b61061b610e95366004614e8f565b613694565b5f6001600160e01b03198216637965db0b60e01b1480610eca57506301ffc9a760e01b6001600160e01b03198316145b92915050565b5f33610edd8185856136da565b5060019392505050565b5f6001600160a01b0386163014610f10576040516282b42960e81b815260040160405180910390fd5b50630a85bd0160e11b5b95945050505050565b6002546001600160a01b03163314610f555760405163118cdaa760e01b81523360048201526024015b60405180910390fd5b60035460405133916001600160a01b0316907feb7a7d62743daf8cf4055aea544d0a89e2011279ed4105567d010759e6fa4de2905f90a3600280546001600160a01b03199081169091556003805490911633179055565b5f805160206156b4833981519152610fc3816136e7565b6001600160a01b0383165f818152604060208190529020901580610ffb57505f815460ff166002811115610ff957610ff9615093565b145b1561101957604051636448d6e960e11b815260040160405180910390fd5b5f83600381111561102c5761102c615093565b0361104a57604051630ebbbf4760e11b815260040160405180910390fd5b805461010080820460ff16918591849161ff0019169083600381111561107257611072615093565b02179055507f825cf86208d6e259fe9caaefe666269ea1150f31063171007de5cc6e7188f942338683876040516110ac9493929190615328565b60405180910390a15050505050565b5f805160206156b48339815191526110d2816136e7565b50605380549115156101000261ff0019909216919091179055565b5f815f036110fc57505f610eca565b81670de0b6b3a764000061110f85612cb0565b611119919061536e565b6111239190615399565b9050610eca565b5f805160206156b4833981519152611141816136e7565b5f670de0b6b3a764000060505460515461115b919061536e565b6111659190615399565b90505f8160515461117691906153ac565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316158015906111af57505f82115b156111f6578160515f8282546111c591906153ac565b909155506111f69050307f0000000000000000000000000000000000000000000000000000000000000000846136f1565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03161580159061122d57505f81115b156112ea578060515f82825461124391906153ac565b909155506112749050307f0000000000000000000000000000000000000000000000000000000000000000836136da565b60405163beceed3960e01b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063beceed39906024015f604051808303815f87803b1580156112d3575f80fd5b505af11580156112e5573d5f803e3d5ffd5b505050505b6049546040516370a0823160e01b81523060048201819052906370a0823190602401602060405180830381865afa158015611327573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061134b91906153bf565b1015611359576113596153d6565b5f81118061136657505f82115b156113a65760408051828152602081018490527ff8fb1ab5e0e30f156c5f69d99c4b242842204f6479e6636c42bb4a9fe22fd38391015b60405180910390a15b505050565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146114255760405163073e64fd60e21b81523360048201526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000166024820152604401610f4c565b61142f828261374e565b5050565b5f805f80670de0b6b3a7640000604e548861144e919061536e565b6114589190615399565b93505f61146585896153ac565b90505f670de0b6b3a764000061147b898461536e565b6114859190615399565b9050818110156114a35793508361149c81836153ac565b92506114d8565b818110156114b3576114b36153d6565b5f6114be83836153ac565b90508295508088106114d2578094506114d6565b8794505b505b505093509350935093565b5f336114f0858285613a8d565b6114fb8585856136f1565b506001949350505050565b5f805160206156b483398151915261151d816136e7565b670de0b6b3a764000082111561154657604051632a9ffab760e21b815260040160405180910390fd5b50604f55565b5f610eca82611559612327565b613b02565b5f805160206156b4833981519152611575816136e7565b6001600160a01b0382165f908152604b602052604081205460518054919290916115a09084906153ea565b9091555050506001600160a01b03165f908152604b6020526040812055565b603f545f90815b8181101561167157600160405f603f84815481106115e6576115e66153fd565b5f9182526020808320909101546001600160a01b0316835282019290925260400190205460ff61010090910416600381111561162457611624615093565b03611669575f611659603f8381548110611640576116406153fd565b5f918252602090912001546001600160a01b0316612cb0565b905061166581856153ea565b9350505b6001016115c6565b505090565b603f545f9081908190815b818110156116d157603f818154811061169c5761169c6153fd565b5f918252602090912001546001600160a01b031693506116bb84611cd1565b9250848311156116c9578294505b600101611681565b5050505090565b5f828152600460205260409020600101546116f2816136e7565b6116fc8383613b54565b50505050565b5f61170b613be5565b905090565b6001600160a01b03811633146117395760405163334bd91960e11b815260040160405180910390fd5b6113a68282613d0e565b61174b613d79565b603e5460ff1615156001036117725760405162dc149f60e41b815260040160405180910390fd5b6117895f805160206156b483398151915233613b54565b506053805461ffff19166001179055604480546001600160a01b0387166001600160a01b03199091161790556117c18484848461239a565b505067016345785d8a00006045555050670e27c49886e60000604c5550670de0b6b3a7640000604d556611c37937e08000604e819055604f556702c68af0bb140000605055603e805460ff19166001179055565b60445460405163b3596f0760e01b81526001600160a01b0383811660048301525f92839291169063b3596f0790602401602060405180830381865afa158015611860573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061188491906153bf565b6001600160a01b0384165f908152604060208190529020600301549091506118ac908261536e565b9392505050565b5f805160206156b48339815191526118ca816136e7565b506053805460ff1916911515919091179055565b5f805160206156b48339815191526118f5816136e7565b6001600160a01b0382165f81815260406020819052902090158061192d57505f815460ff16600281111561192b5761192b615093565b145b1561194b57604051636448d6e960e11b815260040160405180910390fd5b60038101541515806119605750600481015415155b1561197e576040516330cc049760e11b815260040160405180910390fd5b600281015415611990576119906153d6565b805461ffff19168155603f545f90815b818110156119e557603f81815481106119bb576119bb6153fd565b5f918252602090912001546001600160a01b03908116908716036119dd578092505b6001016119a0565b5081158015611a235750846001600160a01b0316603f8381548110611a0c57611a0c6153fd565b5f918252602090912001546001600160a01b031614155b15611a415760405163470cbf4760e01b815260040160405180910390fd5b5f603f611a4f6001846153ac565b81548110611a5f57611a5f6153fd565b5f91825260209091200154603f80546001600160a01b039092169250829185908110611a8d57611a8d6153fd565b905f5260205f20015f6101000a8154816001600160a01b0302191690836001600160a01b03160217905550603f805480611ac957611ac9615411565b5f8281526020902081015f1990810180546001600160a01b03191690550190556040517fa5c0e60615e5aa51b3e2943bbd8db0d90edf30e6eafae884bc090e944e183d2090611b3090339089906001600160a01b0392831681529116602082015260400190565b60405180910390a1505050505050565b5f805160206156b4833981519152611b57816136e7565b604480546001600160a01b038481166001600160a01b031983168117909355604080519190921680825260208201939093527fd52b2b9b7e9ee655fcb95d2e5b9e0c9f69e7ef2b8e9d2d0ea78402d576d22e22910161139d565b5f604754821215611bd25750506047545f9081526046602052604090205490565b604854821315611bf25750506048545f9081526046602052604090205490565b505f9081526046602052604090205490565b919050565b611c11613d79565b611c1a5f613da5565b565b60015433906001600160a01b03168114611c545760405163118cdaa760e01b81526001600160a01b0382166004820152602401610f4c565b611c5d81613da5565b50565b6001600160a01b0381165f908152600c6020526040812054610eca565b5f6060805f805f6060611c8e613dbe565b611c96613deb565b604080515f80825260208201909252600f60f81b9b939a50919850469750309650945092509050565b5f610eca82611ccc612327565b613e18565b6001600160a01b0381165f9081526040602081905281206003810154808303611cfa575f611d0a565b808260020154611d0a9190615399565b949350505050565b5f805160206156b4833981519152611d29816136e7565b6001600160a01b0384161580611d6e57506001836002811115611d4e57611d4e615093565b14158015611d6e57506002836002811115611d6b57611d6b615093565b14155b15611d8c57604051636448d6e960e11b815260040160405180910390fd5b5f826003811115611d9f57611d9f615093565b03611dbd57604051630ebbbf4760e11b815260040160405180910390fd5b6001600160a01b0384165f90815260406020819052812090815460ff166002811115611deb57611deb615093565b14611e0957604051631e7c29bf60e01b815260040160405180910390fd5b80548490829060ff19166001836002811115611e2757611e27615093565b021790555080548390829061ff001916610100836003811115611e4c57611e4c615093565b0217905550603f80546001810182555f919091527fc03004e3ce0784bf68186394306849f9b7b1200073105cd9aeb554a1802b58fd0180546001600160a01b0319166001600160a01b0387161790556040517f86cd39558dedd904177e5c8e34a5c34968f9eb6acdeb26fcf5d12731d07b780e906110ac903390889088908890615425565b5f805160206156b4833981519152611ee8816136e7565b670de0b6b3a7640000821115611f1157604051632a9ffab760e21b815260040160405180910390fd5b50604e55565b5f9182526004602090815260408084206001600160a01b0393909316845291905290205460ff1690565b5f33610edd8185856136f1565b611f826040805160c08101909152805f81526020015f81526020015f81526020015f81526020015f81526020015f81525090565b6001600160a01b0382165f9081526040602081905290819020815160c081019092528054829060ff166002811115611fbc57611fbc615093565b6002811115611fcd57611fcd615093565b81528154602090910190610100900460ff166003811115611ff057611ff0615093565b600381111561200157612001615093565b815260018201546020820152600282015460408201526003820154606082015260049091015460809091015292915050565b603f8181548110612042575f80fd5b5f918252602090912001546001600160a01b0316905081565b5f806120656115bf565b90505f612070612327565b9050835f80826001600160401b0381111561208d5761208d614d21565b6040519080825280602002602001820160405280156120b6578160200160208202803683370190505b5090505f5b8381101561231a575f8989838181106120d6576120d66153fd565b6120ec9260206040909202019081019150614ea6565b6001600160a01b0381165f90815260406020819052808220815160c0810190925280549394509192909190829060ff16600281111561212d5761212d615093565b600281111561213e5761213e615093565b81528154602090910190610100900460ff16600381111561216157612161615093565b600381111561217257612172615093565b815260200160018201548152602001600282015481526020016003820154815260200160048201548152505090508383815181106121b2576121b26153fd565b6020026020010151816040018181516121cb91906153ea565b90525060445460405163b3596f0760e01b81526001600160a01b0384811660048301525f92169063b3596f0790602401602060405180830381865afa158015612216573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061223a91906153bf565b90505f612247828a613b02565b90505f61225961098e86858e88613e4c565b9050855b898110156122d4578e8e82818110612277576122776153fd565b61228d9260206040909202019081019150614ea6565b6001600160a01b0316866001600160a01b0316036122cc578781815181106122b7576122b76153fd565b6020026020010180516122c99061544a565b90525b60010161225d565b505f805f806122e68686604954611433565b935093509350935081836122fa91906153ea565b612304908d6153ea565b9b508960010199505050505050505050506120bb565b5090979650505050505050565b603f545f90815b81811015611671575f612366603f838154811061234d5761234d6153fd565b5f918252602090912001546001600160a01b0316611815565b905061237281856153ea565b93505060010161232e565b5f805160206156b4833981519152612394816136e7565b50604555565b5f805160206156b48339815191526123b1816136e7565b8382146123d15760405163512509d360e11b815260040160405180910390fd5b5f8085815b81811015612519575f8989838181106123f1576123f16153fd565b9050602002013590505f88888481811061240d5761240d6153fd565b905060200201359050805f03612436576040516376611bc960e01b815260040160405180910390fd5b825f03612447576047829055612492565b612452866001615462565b82146124715760405163191108d960e11b815260040160405180910390fd5b848110156124925760405163090de36b60e21b815260040160405180910390fd5b61249d6001856153ac565b83036124a95760488290555b811580156124bf5750670de0b6b3a76400008114155b156124dd5760405163e501e31560e01b815260040160405180910390fd5b8060465f8d8d878181106124f3576124f36153fd565b602090810292909201358352508101919091526040015f205590945092506001016123d6565b505050505050505050565b60445460405163b3596f0760e01b81526001600160a01b0380841660048301525f92610eca9285929091169063b3596f0790602401602060405180830381865afa158015612574573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061259891906153bf565b6125a06115bf565b6001600160a01b0386165f9081526040602081905290819020815160c081019092528054829060ff1660028111156125da576125da615093565b60028111156125eb576125eb615093565b81528154602090910190610100900460ff16600381111561260e5761260e615093565b600381111561261f5761261f615093565b8152602001600182015481526020016002820154815260200160038201548152602001600482015481525050613e4c565b5f805160206156b4833981519152612667816136e7565b50604d55565b834211156126915760405163313c898160e11b815260048101859052602401610f4c565b5f7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98888886126dc8c6001600160a01b03165f908152600c6020526040902080546001810190915590565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090505f61273682613f07565b90505f61274582878787613f33565b9050896001600160a01b0316816001600160a01b03161461278c576040516325c0072360e11b81526001600160a01b0380831660048301528b166024820152604401610f4c565b6127978a8a8a6136da565b50505050505050505050565b5f828152600460205260409020600101546127bd816136e7565b6116fc8383613d0e565b6127cf613d79565b600280546001600160a01b0319166001600160a01b03838116918217909255600354604051919216907f67f679e13fe9dca16f3079221965ec41838cb8881cbc0f440bc13507c6b214c2905f90a350565b6053545f90610100900460ff161561285b5761285b7f44ac9762eec3a11893fefb11d028bb3102560094137c3ed4518712475b2577cc6136e7565b815f0361287b57604051631fd92deb60e31b815260040160405180910390fd5b6128856042613f5f565b5f036128a7576040516001621fb1e560e11b0319815260040160405180910390fd5b5f6128b0611676565b90505f670de0b6b3a7640000604f54836128ca919061536e565b6128d49190615399565b90505f670de0b6b3a7640000604c54846128ee919061536e565b6128f89190615399565b90505f61290583836153ea565b905061291b3330612916898561536e565b6136f1565b612925868261536e565b335f908152604b6020526040812080549091906129439084906153ea565b909155505060405163dc311dd360e01b81527f000000000000000000000000000000000000000000000000000000000000000060048201525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063dc311dd3906024015f60405180830381865afa1580156129cb573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526129f291908101906154a4565b505050506bffffffffffffffffffffffff169050604d54811015612a29576040516382fba8b760e01b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316639b1c385e6040518060c001604052807f000000000000000000000000000000000000000000000000000000000000000081526020017f000000000000000000000000000000000000000000000000000000000000000081526020017f000000000000000000000000000000000000000000000000000000000000000061ffff1681526020017f000000000000000000000000000000000000000000000000000000000000000063ffffffff168152602001600163ffffffff168152602001612b2b60405180602001604052805f1515815250613f68565b8152506040518263ffffffff1660e01b8152600401612b4a9190615591565b6020604051808303815f875af1158015612b66573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612b8a91906153bf565b95506040518060a00160405280336001600160a01b03168152602001336001600160a01b03168152602001838152602001888152602001612bcb6042613f5f565b90525f878152604a6020908152604091829020835181546001600160a01b039182166001600160a01b0319918216178355858401516001840180549190931691161790558383015160028201556060808501516003830155608090940151600490910155815189815290810185905290810189905233917f5952c21ab4e64f9ce2d0daf53a8286da3c634eab5a86ccdf38ebefc3087ea301910160405180910390a25050505050919050565b5f805160206156b4833981519152612c8e816136e7565b6001600160a01b0382165f908152604b60205260409020546113a68382613fd9565b60445460405163b3596f0760e01b81526001600160a01b0383811660048301525f92839291169063b3596f0790602401602060405180830381865afa158015612cfb573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612d1f91906153bf565b9050612d2a836140ba565b6118ac908261536e565b806001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d70573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612d9491906155ed565b6001600160a01b0316336001600160a01b031614612dc4576040516282b42960e81b815260040160405180910390fd5b806001600160a01b03166315ba56e56040518163ffffffff1660e01b81526004015f604051808303815f87803b158015612dfc575f80fd5b505af1158015612e0e573d5f803e3d5ffd5b5050505050565b60535460ff1615612e4957612e497f8f4f2da22e8ac8f11e15f9fc141cddbb5deea8800186560abb6e68c5496619a96136e7565b81156113a6575f612e586115bf565b90505f612e63612327565b90505f805f5b8681101561338f575f888883818110612e8457612e846153fd565b612e9a9260206040909202019081019150614ea6565b90505f898984818110612eaf57612eaf6153fd565b9050604002016020013590505f612ec68383614143565b6001600160a01b0384165f9081526040602081905290209091506001815460ff166002811115612ef857612ef8615093565b141580612f1f575060038154610100900460ff166003811115612f1d57612f1d615093565b145b80612f4357505f8154610100900460ff166003811115612f4157612f41615093565b145b15612f6157604051636448d6e960e11b815260040160405180910390fd5b60445460405163b3596f0760e01b81526001600160a01b0386811660048301525f92169063b3596f0790602401602060405180830381865afa158015612fa9573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612fcd91906153bf565b90505f612fda828b613b02565b905080836002015f828254612fef91906153ea565b90915550506040516370a0823160e01b81523060048201525f906001600160a01b038816906370a0823190602401602060405180830381865afa158015613038573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061305c91906153bf565b9050613069604286614189565b15613076576130766153d6565b6130816042866141a0565b156130e7575f858152604160205260409020546001600160a01b03166130e7576040805180820182526001600160a01b03898116825260208083018a81525f8a81526041909252939020915182546001600160a01b031916911617815590516001909101555b604051632142170760e11b8152336004820152306024820152604481018790526001600160a01b038816906342842e0e906064015f604051808303815f87803b158015613132575f80fd5b505af1158015613144573d5f803e3d5ffd5b50506040516370a0823160e01b81523060048201528392506001600160a01b038a1691506370a0823190602401602060405180830381865afa15801561318c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906131b091906153bf565b6131ba91906153ac565b6001146131da57604051631947c14d60e31b815260040160405180910390fd5b50670de0b6b3a764000060018454610100900460ff16600381111561320157613201615093565b036132405761323d61098e88858f886040518060c00160405290815f82015f9054906101000a900460ff1660028111156125da576125da615093565b90505b836001015f81546132509061544a565b919050819055505f805f806132688686604954611433565b935093509350935082848261327d91906153ea565b61328791906153ea565b613291908f6153ea565b9d508360515f8282546132a491906153ea565b909155506132b4905082846153ea565b6132be908e6153ea565b9c5080156132dd578060495f8282546132d791906153ea565b90915550505b811561330d578160495410613308578160495f8282546132fd91906153ac565b9091555061330d9050565b5f6049555b604080518a8152602081018c9052908101889052606081018590526080810184905260a0810183905260c081018290526001600160a01b038c1690339081907fa7c42ea0dcfdf07b7b88c53f079a11e7565c8cf2422e82c5757dbe3a7ae66df09060e00160405180910390a48b6001019b505050505050505050505050612e69565b505f5b868110156133ff5760405f8989848181106133af576133af6153fd565b6133c59260206040909202019081019150614ea6565b6001600160a01b03166001600160a01b031681526020019081526020015f206003015f81546133f39061544a565b90915550600101613392565b508481101561342157604051634edec39960e01b815260040160405180910390fd5b61342b30836141ab565b6134363033836136f1565b50505050505050565b613447613d79565b600180546001600160a01b0383166001600160a01b031990911681179091556134775f546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b5f805160206156b48339815191526134c6816136e7565b506001600160a01b039182165f90815260526020526040902080546001600160a01b03191691909216179055565b603f545f908190815b8181101561363d575f60405f603f848154811061351c5761351c6153fd565b5f9182526020808320909101546001600160a01b031683528201929092526040908101909120815160c081019092528054829060ff16600281111561356357613563615093565b600281111561357457613574615093565b81528154602090910190610100900460ff16600381111561359757613597615093565b60038111156135a8576135a8615093565b815260018281015460208301526002830154604083015260038301546060830152600490920154608090910152909150816020015160038111156135ee576135ee615093565b03613634575f613624603f848154811061360a5761360a6153fd565b5f918252602090912001546001600160a01b0316836141df565b905061363081866153ea565b9450505b506001016134fd565b509092915050565b5f805160206156b483398151915261365c816136e7565b61366e670de0b6b3a7640000806153ea565b82111561368e57604051632a9ffab760e21b815260040160405180910390fd5b50604c55565b5f805160206156b48339815191526136ab816136e7565b670de0b6b3a76400008211156136d457604051632a9ffab760e21b815260040160405180910390fd5b50605055565b6113a68383836001614260565b611c5d8133614332565b6001600160a01b03831661371a57604051634b637e8f60e11b81525f6004820152602401610f4c565b6001600160a01b0382166137435760405163ec442f0560e01b81525f6004820152602401610f4c565b6113a683838361436b565b5f828152604a60209081526040808320815160a08101835281546001600160a01b03908116808352600184015490911694820185905260028301549382018490526003830154606083018190526004909301546080830152909490939291906137b7828461536e565b6001600160a01b0385165f908152604b60205260409020549091508111156137f257604051633775d15760e11b815260040160405180910390fd5b5f6137fd6042613f5f565b90505f81886080015111613815578760800151613817565b815b90508084116138265783613828565b805b604080518082019091525f808252602082018190529195505f805f5b88811015613a4b575f8e5f8151811061385f5761385f6153fd565b6020026020010151828c60405160200161388c939291909283526020830191909152604082015260600190565b604051602081830303815290604052805190602001205f1c90506138b08188614491565b604f549196509450670de0b6b3a7640000906138cc908661536e565b6138d69190615399565b9250886138e384866153ea565b11156138f1575f9550613925565b6138fd858d8f8761458e565b61390783856153ea565b613911908a6153ac565b98508661391d81615608565b975050600195505b845f01516001600160a01b03168d6001600160a01b03168d6001600160a01b03167f32c481f9f839443a353613e2cf1b07e35f527dfe3645e32fb3c23ea6d49391e1613978895f01518a60200151614143565b60208a01516044548b5160405163b3596f0760e01b81526001600160a01b0391821660048201528c92919091169063b3596f0790602401602060405180830381865afa1580156139ca573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906139ee91906153bf565b670de0b6b3a7640000604f548d613a05919061536e565b613a0f9190615399565b60408051958652602086019490945292840191909152606083015260808201528a151560a082015260c00160405180910390a450600101613844565b506001600160a01b038a165f908152604b6020526040902054871115613a7357613a736153d6565b613a7d8a88613fd9565b5050505050505050505050505050565b6001600160a01b038381165f908152600660209081526040808320938616835292905220545f1981146116fc5781811015613af457604051637dc7a0d960e11b81526001600160a01b03841660048201526024810182905260448101839052606401610f4c565b6116fc84848484035f614260565b5f80613b0d60075490565b9050805f03613b3f57670de0b6b3a764000060455485613b2d919061536e565b613b379190615399565b915050610eca565b82613b4a828661536e565b611d0a9190615399565b5f613b5f8383611f17565b613bde575f8381526004602090815260408083206001600160a01b03861684529091529020805460ff19166001179055613b963390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4506001610eca565b505f610eca565b5f306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016148015613c3d57507f000000000000000000000000000000000000000000000000000000000000000046145b15613c6757507f000000000000000000000000000000000000000000000000000000000000000090565b61170b604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f0000000000000000000000000000000000000000000000000000000000000000918101919091527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a08201525f9060c00160405160208183030381529060405280519060200120905090565b5f613d198383611f17565b15613bde575f8381526004602090815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a4506001610eca565b5f546001600160a01b03163314611c1a5760405163118cdaa760e01b8152336004820152602401610f4c565b600180546001600160a01b0319169055611c5d816146fc565b606061170b7f0000000000000000000000000000000000000000000000000000000000000000600a61474b565b606061170b7f0000000000000000000000000000000000000000000000000000000000000000600b61474b565b5f80613e2360075490565b9050805f03613e4157604554613b2d670de0b6b3a76400008661536e565b80613b4a848661536e565b5f835f03613e5b57505f611d0a565b5f613e6686856110ed565b9050670de0b6b3a76400008103613e80575f915050611d0a565b5f836040015186613e91919061536e565b90505f613e9c6134f4565b90505f670de0b6b3a7640000613eb2858461536e565b613ebc9190615399565b905087670de0b6b3a7640000613ed2868361536e565b613edc9190615399565b613ee6919061561d565b613ef0828561561d565b613efa919061563c565b9998505050505050505050565b5f610eca613f13613be5565b8360405161190160f01b8152600281019290925260228201526042902090565b5f805f80613f43888888886147ed565b925092509250613f5382826148b5565b50909695505050505050565b5f610eca825490565b60607f92fd13387c7fe7befbc38d303d6468778fb9731bc4583f17d92989c6fcfdeaaa82604051602401613fa191511515815260200190565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915292915050565b6001600160a01b0382165f908152604b60205260409020548181101561401257604051633775d15760e11b815260040160405180910390fd5b6001600160a01b0383165f908152604b6020526040812080548492906140399084906153ac565b9091555061404a90503084846136f1565b826001600160a01b03167f75389868cdf1173cb66026bd6868aecbfa44c163370c022a878dc8c6f5c260e08360405161408591815260200190565b60405180910390a260515460495461409d91906153ea565b305f9081526005602052604090205410156113a6576113a66153d6565b6001600160a01b038082165f9081526052602052604081205490911680156140e257806140e4565b825b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561411f573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906118ac91906153bf565b6040516bffffffffffffffffffffffff19606084901b166020820152603481018290525f9060540160405160208183030381529060405280519060200120905092915050565b5f81815260018301602052604081205415156118ac565b5f6118ac838361496d565b6001600160a01b0382166141d45760405163ec442f0560e01b81525f6004820152602401610f4c565b61142f5f838361436b565b60445460405163b3596f0760e01b81526001600160a01b0384811660048301525f92839291169063b3596f0790602401602060405180830381865afa15801561422a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061424e91906153bf565b9050826040015181611d0a919061536e565b6001600160a01b0384166142895760405163e602df0560e01b81525f6004820152602401610f4c565b6001600160a01b0383166142b257604051634a1406b160e11b81525f6004820152602401610f4c565b6001600160a01b038085165f90815260066020908152604080832093871683529290522082905580156116fc57826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258460405161432491815260200190565b60405180910390a350505050565b61433c8282611f17565b61142f5760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401610f4c565b6001600160a01b038316614395578060075f82825461438a91906153ea565b909155506144059050565b6001600160a01b0383165f90815260056020526040902054818110156143e75760405163391434e360e21b81526001600160a01b03851660048201526024810182905260448101839052606401610f4c565b6001600160a01b0384165f9081526005602052604090209082900390555b6001600160a01b0382166144215760078054829003905561443f565b6001600160a01b0382165f9081526005602052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161448491815260200190565b60405180910390a3505050565b604080518082019091525f80825260208201525f806144b9670de0b6b3a76400005f19615399565b6144c39086615668565b90505f6144d9670de0b6b3a76400005f19615399565b6144eb670de0b6b3a76400008461536e565b6144f59190615399565b90505f670de0b6b3a764000061450b878461536e565b6145159190615399565b905060415f6145256042846149b2565b815260208082019290925260409081015f20815180830190925280546001600160a01b0316808352600190910154928201929092529550614568576145686153d6565b845161457390611cd1565b9350835f03614584576145846153d6565b5050509250929050565b83516001600160a01b03165f90815260406020819052902060028101546145b69083906153ac565b6002820155604f545f90670de0b6b3a7640000906145d4908561536e565b6145de9190615399565b90508060515f8282546145f191906153ea565b90915550614601905030846149bd565b61460b81846153ea565b6001600160a01b0386165f908152604b6020526040812080549091906146329084906153ac565b9091555050855160208701515f9161464991614143565b90506146566042826149f1565b1561468857600383018054905f61466c83615608565b9091555050600183018054905f61468283615608565b91905055505b865160208801516040516323b872dd60e01b81523060048201526001600160a01b03888116602483015260448201929092529116906323b872dd906064015f604051808303815f87803b1580156146dd575f80fd5b505af11580156146ef573d5f803e3d5ffd5b5050505050505050505050565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b606060ff831461475e57611123836149fc565b81805461476a9061567b565b80601f01602080910402602001604051908101604052809291908181526020018280546147969061567b565b80156147e15780601f106147b8576101008083540402835291602001916147e1565b820191905f5260205f20905b8154815290600101906020018083116147c457829003601f168201915b50505050509050610eca565b5f80807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a084111561482657505f915060039050826148ab565b604080515f808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015614877573d5f803e3d5ffd5b5050604051601f1901519150506001600160a01b0381166148a257505f9250600191508290506148ab565b92505f91508190505b9450945094915050565b5f8260038111156148c8576148c8615093565b036148d1575050565b60018260038111156148e5576148e5615093565b036149035760405163f645eedf60e01b815260040160405180910390fd5b600282600381111561491757614917615093565b036149385760405163fce698f760e01b815260048101829052602401610f4c565b600382600381111561494c5761494c615093565b0361142f576040516335e2f38360e21b815260048101829052602401610f4c565b5f818152600183016020526040812054613bde57508154600181810184555f848152602080822090930184905584548482528286019093526040902091909155610eca565b5f6118ac8383614a39565b6001600160a01b0382166149e657604051634b637e8f60e11b81525f6004820152602401610f4c565b61142f825f8361436b565b5f6118ac8383614a5f565b60605f614a0883614b49565b6040805160208082528183019092529192505f91906020820181803683375050509182525060208101929092525090565b5f825f018281548110614a4e57614a4e6153fd565b905f5260205f200154905092915050565b5f8181526001830160205260408120548015614b39575f614a816001836153ac565b85549091505f90614a94906001906153ac565b9050808214614af3575f865f018281548110614ab257614ab26153fd565b905f5260205f200154905080875f018481548110614ad257614ad26153fd565b5f918252602080832090910192909255918252600188019052604090208390555b8554869080614b0457614b04615411565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f905560019350505050610eca565b5f915050610eca565b5092915050565b5f60ff8216601f811115610eca57604051632cd44ac360e21b815260040160405180910390fd5b5f60208284031215614b80575f80fd5b81356001600160e01b0319811681146118ac575f80fd5b5f81518084525f5b81811015614bbb57602081850181015186830182015201614b9f565b505f602082860101526020601f19601f83011685010191505092915050565b602081525f6118ac6020830184614b97565b6001600160a01b0381168114611c5d575f80fd5b5f8060408385031215614c11575f80fd5b8235614c1c81614bec565b946020939093013593505050565b5f805f805f60808688031215614c3e575f80fd5b8535614c4981614bec565b94506020860135614c5981614bec565b93506040860135925060608601356001600160401b03811115614c7a575f80fd5b8601601f81018813614c8a575f80fd5b80356001600160401b03811115614c9f575f80fd5b886020828401011115614cb0575f80fd5b959894975092955050506020019190565b803560048110611c04575f80fd5b5f8060408385031215614ce0575f80fd5b8235614ceb81614bec565b9150614cf960208401614cc1565b90509250929050565b5f60208284031215614d12575f80fd5b813580151581146118ac575f80fd5b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f191681016001600160401b0381118282101715614d5d57614d5d614d21565b604052919050565b5f6001600160401b03821115614d7d57614d7d614d21565b5060051b60200190565b5f8060408385031215614d98575f80fd5b8235915060208301356001600160401b03811115614db4575f80fd5b8301601f81018513614dc4575f80fd5b8035614dd7614dd282614d65565b614d35565b8082825260208201915060208360051b850101925087831115614df8575f80fd5b6020840193505b82841015614e1a578335825260209384019390910190614dff565b809450505050509250929050565b5f805f60608486031215614e3a575f80fd5b505081359360208301359350604090920135919050565b5f805f60608486031215614e63575f80fd5b8335614e6e81614bec565b92506020840135614e7e81614bec565b929592945050506040919091013590565b5f60208284031215614e9f575f80fd5b5035919050565b5f60208284031215614eb6575f80fd5b81356118ac81614bec565b5f8060408385031215614ed2575f80fd5b823591506020830135614ee481614bec565b809150509250929050565b5f8083601f840112614eff575f80fd5b5081356001600160401b03811115614f15575f80fd5b6020830191508360208260051b8501011115614f2f575f80fd5b9250929050565b5f805f805f60608688031215614f4a575f80fd5b8535614f5581614bec565b945060208601356001600160401b03811115614f6f575f80fd5b614f7b88828901614eef565b90955093505060408601356001600160401b03811115614f99575f80fd5b614fa588828901614eef565b969995985093965092949392505050565b60ff60f81b8816815260e060208201525f614fd460e0830189614b97565b8281036040840152614fe68189614b97565b606084018890526001600160a01b038716608085015260a0840186905283810360c0850152845180825260208087019350909101905f5b8181101561503b57835183526020938401939092019160010161501d565b50909b9a5050505050505050505050565b5f805f6060848603121561505e575f80fd5b833561506981614bec565b925060208401356003811061507c575f80fd5b915061508a60408501614cc1565b90509250925092565b634e487b7160e01b5f52602160045260245ffd5b600381106150b7576150b7615093565b9052565b600481106150b7576150b7615093565b5f60c0820190506150dd8284516150a7565b60208301516150ef60208401826150bb565b5060408301516040830152606083015160608301526080830151608083015260a083015160a083015292915050565b5f8083601f84011261512e575f80fd5b5081356001600160401b03811115615144575f80fd5b6020830191508360208260061b8501011115614f2f575f80fd5b5f806020838503121561516f575f80fd5b82356001600160401b03811115615184575f80fd5b6151908582860161511e565b90969095509350505050565b5f805f80604085870312156151af575f80fd5b84356001600160401b038111156151c4575f80fd5b6151d087828801614eef565b90955093505060208501356001600160401b038111156151ee575f80fd5b6151fa87828801614eef565b95989497509550505050565b5f805f805f805f60e0888a03121561521c575f80fd5b873561522781614bec565b9650602088013561523781614bec565b95506040880135945060608801359350608088013560ff8116811461525a575f80fd5b9699959850939692959460a0840135945060c09093013592915050565b5f8060408385031215615288575f80fd5b823561529381614bec565b91506020830135614ee481614bec565b5f805f604084860312156152b5575f80fd5b83356001600160401b038111156152ca575f80fd5b6152d68682870161511e565b909790965060209590950135949350505050565b60c081016152f882896150a7565b61530560208301886150bb565b8560408301528460608301528360808301528260a0830152979650505050505050565b6001600160a01b038581168252841660208201526080810161534d60408301856150bb565b610f1a60608301846150bb565b634e487b7160e01b5f52601160045260245ffd5b8082028115828204841417610eca57610eca61535a565b634e487b7160e01b5f52601260045260245ffd5b5f826153a7576153a7615385565b500490565b81810381811115610eca57610eca61535a565b5f602082840312156153cf575f80fd5b5051919050565b634e487b7160e01b5f52600160045260245ffd5b80820180821115610eca57610eca61535a565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52603160045260245ffd5b6001600160a01b038581168252841660208201526080810161534d60408301856150a7565b5f6001820161545b5761545b61535a565b5060010190565b8082018281125f8312801582168215821617156154815761548161535a565b505092915050565b80516bffffffffffffffffffffffff81168114611c04575f80fd5b5f805f805f60a086880312156154b8575f80fd5b6154c186615489565b94506154cf60208701615489565b935060408601516001600160401b03811681146154ea575f80fd5b60608701519093506154fb81614bec565b60808701519092506001600160401b03811115615516575f80fd5b8601601f81018813615526575f80fd5b8051615534614dd282614d65565b8082825260208201915060208360051b85010192508a831115615555575f80fd5b6020840193505b8284101561558057835161556f81614bec565b82526020938401939091019061555c565b809450505050509295509295909350565b60208152815160208201526020820151604082015261ffff604083015116606082015263ffffffff606083015116608082015263ffffffff60808301511660a08201525f60a083015160c080840152611d0a60e0840182614b97565b5f602082840312156155fd575f80fd5b81516118ac81614bec565b5f816156165761561661535a565b505f190190565b8181035f831280158383131683831282161715614b4257614b4261535a565b5f8261564a5761564a615385565b600160ff1b82145f19841416156156635761566361535a565b500590565b5f8261567657615676615385565b500690565b600181811c9082168061568f57607f821691505b6020821081036156ad57634e487b7160e01b5f52602260045260245ffd5b5091905056feddd94edc7da5bca8f576c77964a4737ba5172c728e2d539e672f0229d1e9ec2da2646970667358221220a1dcbdeaefb6e0474be103d56b83a10a8cb2843ef3c5999f99d5f30cd9f5099664736f6c634300081a003300000000000000000000000000000000000000000000000000000000000000000000000000000000000000009940d40a6d648655da345976e820051f2b273534000000000000000000000000d7f86b4b8cae7d942340ff628f82735b7a20893a3fd2fec10d06ee8f65e7f2e95f5c56511359ece3f33960ad8a866ae24a8ff10b00000000000000000000000000000000000000000000000000000000002625a00000000000000000000000000000000000000000000000000000000000000003837b6b0b6218cf26fcf360c564ba774c692fb3f5b08855ab6fbb3138fcf08680
Deployed Bytecode
0x608060405234801561000f575f80fd5b5060043610610553575f3560e01c80637fa46ab4116102bf578063beff682411610186578063e657a2b2116100ef578063f2fde38b116100a9578063f74032f011610084578063f74032f014610e44578063fac24d5714610e6c578063fe3ee9c114610e74578063ffd497b914610e87575f80fd5b8063f2fde38b14610e15578063f398332414610e28578063f447a63714610e31575f80fd5b8063e657a2b214610d6b578063eaac8c3214610d7e578063ec70cbc714610d91578063ed5614b614610da3578063efe1d6d314610dac578063f242c9e014610dbf575f80fd5b8063d547741f11610140578063d547741f14610cd6578063d69efdc514610ce9578063db006a7514610cfc578063dd62ed3e14610d0f578063dfb3cdc214610d47578063e30c397814610d5a575f80fd5b8063beff682414610c6d578063c60a04d714610c81578063caa8dac514610c8a578063d25e679814610c9d578063d419db6714610cb0578063d505accf14610cc3575f80fd5b80639eccacf611610228578063af19f4e1116101e2578063af19f4e114610b95578063afbc74b914610ba8578063afdc611114610bb0578063b0fb162f14610c01578063b52d2efe14610c3b578063bac19d1f14610c5a575f80fd5b80639eccacf614610afa578063a217fddf14610b21578063a3b0b5a314610b28578063a9059cbb14610b4f578063aa36d1d714610b62578063ab78af6714610b82575f80fd5b80638da5cb5b116102795780638da5cb5b14610a895780638e583ca214610a995780638e691b9a14610aac57806391d1485414610abf57806395d89b4114610ad25780639d8bb82f14610af1575f80fd5b80637fa46ab4146109f157806384b0196e14610a18578063851d342514610a33578063852cb9b814610a465780638705057814610a4f5780638ac0002114610a62575f80fd5b80632dc726841161041d57806348d3b7751161038657806361728f3911610340578063715018a61161031b578063715018a6146109bb57806379ba5097146109c35780637dc0d1d0146109cb5780637ecebe00146109de575f80fd5b806361728f39146109595780636fa62b621461098057806370a0823114610993575f80fd5b806348d3b7751461088f5780634a5e42b11461089c578063530e784f146108af5780635a672e81146108c25780635c60da1b146108cb5780635cb6dfff146108de575f80fd5b8063374e72f5116103d7578063374e72f5146107fd578063396f7b231461081c5780633a7bd60c1461082f5780633cc9f456146108425780634105a7dd1461085557806341dbad9a14610868575f80fd5b80632dc72684146107af5780632f2ff15d146107b757806330f1e782146107ca578063313ce567146107d35780633644e515146107e257806336568abe146107ea575f80fd5b80631afb8755116104bf57806324f746971161047957806324f746971461072957806325125e17146107655780632605d55d1461076e578063284c853b146107815780632abe9203146107945780632afbd567146107a7575f80fd5b80631afb87551461069d5780631cb734b2146106a55780631fe543e3146106ae57806320bb2ba4146106c157806323b872dd146106f4578063248a9ca314610707575f80fd5b806315ba56e51161051057806315ba56e51461061357806318160ddd1461061d5780631900ff23146106255780631a098186146106385780631acede4c1461064b5780631af99aca1461065e575f80fd5b806301ffc9a714610557578063038ddfe81461057f57806306fdde0314610596578063095ea7b3146105cc5780630ec38145146105df578063150b7a02146105e7575b5f80fd5b61056a610565366004614b70565b610e9a565b60405190151581526020015b60405180910390f35b61058860515481565b604051908152602001610576565b60408051808201909152601181527008ceadcced2ccf2409c8ca84092dcc8caf607b1b60208201525b6040516105769190614bda565b61056a6105da366004614c00565b610ed0565b603f54610588565b6105fa6105f5366004614c2a565b610ee7565b6040516001600160e01b03199091168152602001610576565b61061b610f23565b005b600754610588565b61061b610633366004614ccf565b610fac565b61061b610646366004614d02565b6110bb565b610588610659366004614c00565b6110ed565b6106857f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610576565b61061b61112a565b610588604d5481565b61061b6106bc366004614d87565b6113ab565b6106d46106cf366004614e28565b611433565b604080519485526020850193909352918301526060820152608001610576565b61056a610702366004614e51565b6114e3565b610588610715366004614e8f565b5f9081526004602052604090206001015490565b6107507f00000000000000000000000000000000000000000000000000000000002625a081565b60405163ffffffff9091168152602001610576565b610588604c5481565b61061b61077c366004614e8f565b611506565b61058861078f366004614e8f565b61154c565b61061b6107a2366004614ea6565b61155e565b6105886115bf565b610588611676565b61061b6107c5366004614ec1565b6116d8565b61058860455481565b60405160128152602001610576565b610588611702565b61061b6107f8366004614ec1565b611710565b61058861080b366004614e8f565b60466020525f908152604090205481565b600254610685906001600160a01b031681565b61061b61083d366004614f36565b611743565b610588610850366004614ea6565b611815565b61061b610863366004614d02565b6118b3565b6106857f0000000000000000000000009940d40a6d648655da345976e820051f2b27353481565b60535461056a9060ff1681565b61061b6108aa366004614ea6565b6118de565b61061b6108bd366004614ea6565b611b40565b61058860485481565b600354610685906001600160a01b031681565b6109266108ec366004614e8f565b604a6020525f9081526040902080546001820154600283015460038401546004909401546001600160a01b03938416949390921692909185565b604080516001600160a01b039687168152959094166020860152928401919091526060830152608082015260a001610576565b6105887f3fd2fec10d06ee8f65e7f2e95f5c56511359ece3f33960ad8a866ae24a8ff10b81565b61058861098e366004614e8f565b611bb1565b6105886109a1366004614ea6565b6001600160a01b03165f9081526005602052604090205490565b61061b611c09565b61061b611c1c565b604454610685906001600160a01b031681565b6105886109ec366004614ea6565b611c60565b6105887f44ac9762eec3a11893fefb11d028bb3102560094137c3ed4518712475b2577cc81565b610a20611c7d565b6040516105769796959493929190614fb6565b610588610a41366004614e8f565b611cbf565b610588604e5481565b610588610a5d366004614ea6565b611cd1565b6105887f837b6b0b6218cf26fcf360c564ba774c692fb3f5b08855ab6fbb3138fcf0868081565b5f546001600160a01b0316610685565b61061b610aa736600461504c565b611d12565b61061b610aba366004614e8f565b611ed1565b61056a610acd366004614ec1565b611f17565b60408051808201909152600381526213919560ea1b60208201526105bf565b61058860505481565b6106857f000000000000000000000000d7f86b4b8cae7d942340ff628f82735b7a20893a81565b6105885f81565b6105887f8f4f2da22e8ac8f11e15f9fc141cddbb5deea8800186560abb6e68c5496619a981565b61056a610b5d366004614c00565b611f41565b610b75610b70366004614ea6565b611f4e565b60405161057691906150cb565b610685610b90366004614e8f565b612033565b610588610ba336600461515e565b61205b565b610588612327565b610be2610bbe366004614e8f565b60416020525f9081526040902080546001909101546001600160a01b039091169082565b604080516001600160a01b039093168352602083019190915201610576565b610c287f000000000000000000000000000000000000000000000000000000000000000381565b60405161ffff9091168152602001610576565b610588610c49366004614ea6565b604b6020525f908152604090205481565b61061b610c68366004614e8f565b61237d565b6105885f805160206156b483398151915281565b61058860475481565b61061b610c9836600461519c565b61239a565b610588610cab366004614ea6565b612524565b61061b610cbe366004614e8f565b612650565b61061b610cd1366004615206565b61266d565b61061b610ce4366004614ec1565b6127a3565b61061b610cf7366004614ea6565b6127c7565b610588610d0a366004614e8f565b612820565b610588610d1d366004615277565b6001600160a01b039182165f90815260066020908152604080832093909416825291909152205490565b61061b610d55366004614ea6565b612c77565b6001546001600160a01b0316610685565b610588610d79366004614ea6565b612cb0565b61061b610d8c366004614ea6565b612d34565b60535461056a90610100900460ff1681565b610588604f5481565b61061b610dba3660046152a3565b612e15565b610e03610dcd366004614ea6565b604060208190525f9182529020805460018201546002830154600384015460049094015460ff8085169561010090950416939086565b604051610576969594939291906152ea565b61061b610e23366004614ea6565b61343f565b61058860495481565b61061b610e3f366004615277565b6134af565b610685610e52366004614ea6565b60526020525f90815260409020546001600160a01b031681565b6105886134f4565b61061b610e82366004614e8f565b613645565b61061b610e95366004614e8f565b613694565b5f6001600160e01b03198216637965db0b60e01b1480610eca57506301ffc9a760e01b6001600160e01b03198316145b92915050565b5f33610edd8185856136da565b5060019392505050565b5f6001600160a01b0386163014610f10576040516282b42960e81b815260040160405180910390fd5b50630a85bd0160e11b5b95945050505050565b6002546001600160a01b03163314610f555760405163118cdaa760e01b81523360048201526024015b60405180910390fd5b60035460405133916001600160a01b0316907feb7a7d62743daf8cf4055aea544d0a89e2011279ed4105567d010759e6fa4de2905f90a3600280546001600160a01b03199081169091556003805490911633179055565b5f805160206156b4833981519152610fc3816136e7565b6001600160a01b0383165f818152604060208190529020901580610ffb57505f815460ff166002811115610ff957610ff9615093565b145b1561101957604051636448d6e960e11b815260040160405180910390fd5b5f83600381111561102c5761102c615093565b0361104a57604051630ebbbf4760e11b815260040160405180910390fd5b805461010080820460ff16918591849161ff0019169083600381111561107257611072615093565b02179055507f825cf86208d6e259fe9caaefe666269ea1150f31063171007de5cc6e7188f942338683876040516110ac9493929190615328565b60405180910390a15050505050565b5f805160206156b48339815191526110d2816136e7565b50605380549115156101000261ff0019909216919091179055565b5f815f036110fc57505f610eca565b81670de0b6b3a764000061110f85612cb0565b611119919061536e565b6111239190615399565b9050610eca565b5f805160206156b4833981519152611141816136e7565b5f670de0b6b3a764000060505460515461115b919061536e565b6111659190615399565b90505f8160515461117691906153ac565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316158015906111af57505f82115b156111f6578160515f8282546111c591906153ac565b909155506111f69050307f0000000000000000000000000000000000000000000000000000000000000000846136f1565b7f0000000000000000000000009940d40a6d648655da345976e820051f2b2735346001600160a01b03161580159061122d57505f81115b156112ea578060515f82825461124391906153ac565b909155506112749050307f0000000000000000000000009940d40a6d648655da345976e820051f2b273534836136da565b60405163beceed3960e01b8152600481018290527f0000000000000000000000009940d40a6d648655da345976e820051f2b2735346001600160a01b03169063beceed39906024015f604051808303815f87803b1580156112d3575f80fd5b505af11580156112e5573d5f803e3d5ffd5b505050505b6049546040516370a0823160e01b81523060048201819052906370a0823190602401602060405180830381865afa158015611327573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061134b91906153bf565b1015611359576113596153d6565b5f81118061136657505f82115b156113a65760408051828152602081018490527ff8fb1ab5e0e30f156c5f69d99c4b242842204f6479e6636c42bb4a9fe22fd38391015b60405180910390a15b505050565b336001600160a01b037f000000000000000000000000d7f86b4b8cae7d942340ff628f82735b7a20893a16146114255760405163073e64fd60e21b81523360048201526001600160a01b037f000000000000000000000000d7f86b4b8cae7d942340ff628f82735b7a20893a166024820152604401610f4c565b61142f828261374e565b5050565b5f805f80670de0b6b3a7640000604e548861144e919061536e565b6114589190615399565b93505f61146585896153ac565b90505f670de0b6b3a764000061147b898461536e565b6114859190615399565b9050818110156114a35793508361149c81836153ac565b92506114d8565b818110156114b3576114b36153d6565b5f6114be83836153ac565b90508295508088106114d2578094506114d6565b8794505b505b505093509350935093565b5f336114f0858285613a8d565b6114fb8585856136f1565b506001949350505050565b5f805160206156b483398151915261151d816136e7565b670de0b6b3a764000082111561154657604051632a9ffab760e21b815260040160405180910390fd5b50604f55565b5f610eca82611559612327565b613b02565b5f805160206156b4833981519152611575816136e7565b6001600160a01b0382165f908152604b602052604081205460518054919290916115a09084906153ea565b9091555050506001600160a01b03165f908152604b6020526040812055565b603f545f90815b8181101561167157600160405f603f84815481106115e6576115e66153fd565b5f9182526020808320909101546001600160a01b0316835282019290925260400190205460ff61010090910416600381111561162457611624615093565b03611669575f611659603f8381548110611640576116406153fd565b5f918252602090912001546001600160a01b0316612cb0565b905061166581856153ea565b9350505b6001016115c6565b505090565b603f545f9081908190815b818110156116d157603f818154811061169c5761169c6153fd565b5f918252602090912001546001600160a01b031693506116bb84611cd1565b9250848311156116c9578294505b600101611681565b5050505090565b5f828152600460205260409020600101546116f2816136e7565b6116fc8383613b54565b50505050565b5f61170b613be5565b905090565b6001600160a01b03811633146117395760405163334bd91960e11b815260040160405180910390fd5b6113a68282613d0e565b61174b613d79565b603e5460ff1615156001036117725760405162dc149f60e41b815260040160405180910390fd5b6117895f805160206156b483398151915233613b54565b506053805461ffff19166001179055604480546001600160a01b0387166001600160a01b03199091161790556117c18484848461239a565b505067016345785d8a00006045555050670e27c49886e60000604c5550670de0b6b3a7640000604d556611c37937e08000604e819055604f556702c68af0bb140000605055603e805460ff19166001179055565b60445460405163b3596f0760e01b81526001600160a01b0383811660048301525f92839291169063b3596f0790602401602060405180830381865afa158015611860573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061188491906153bf565b6001600160a01b0384165f908152604060208190529020600301549091506118ac908261536e565b9392505050565b5f805160206156b48339815191526118ca816136e7565b506053805460ff1916911515919091179055565b5f805160206156b48339815191526118f5816136e7565b6001600160a01b0382165f81815260406020819052902090158061192d57505f815460ff16600281111561192b5761192b615093565b145b1561194b57604051636448d6e960e11b815260040160405180910390fd5b60038101541515806119605750600481015415155b1561197e576040516330cc049760e11b815260040160405180910390fd5b600281015415611990576119906153d6565b805461ffff19168155603f545f90815b818110156119e557603f81815481106119bb576119bb6153fd565b5f918252602090912001546001600160a01b03908116908716036119dd578092505b6001016119a0565b5081158015611a235750846001600160a01b0316603f8381548110611a0c57611a0c6153fd565b5f918252602090912001546001600160a01b031614155b15611a415760405163470cbf4760e01b815260040160405180910390fd5b5f603f611a4f6001846153ac565b81548110611a5f57611a5f6153fd565b5f91825260209091200154603f80546001600160a01b039092169250829185908110611a8d57611a8d6153fd565b905f5260205f20015f6101000a8154816001600160a01b0302191690836001600160a01b03160217905550603f805480611ac957611ac9615411565b5f8281526020902081015f1990810180546001600160a01b03191690550190556040517fa5c0e60615e5aa51b3e2943bbd8db0d90edf30e6eafae884bc090e944e183d2090611b3090339089906001600160a01b0392831681529116602082015260400190565b60405180910390a1505050505050565b5f805160206156b4833981519152611b57816136e7565b604480546001600160a01b038481166001600160a01b031983168117909355604080519190921680825260208201939093527fd52b2b9b7e9ee655fcb95d2e5b9e0c9f69e7ef2b8e9d2d0ea78402d576d22e22910161139d565b5f604754821215611bd25750506047545f9081526046602052604090205490565b604854821315611bf25750506048545f9081526046602052604090205490565b505f9081526046602052604090205490565b919050565b611c11613d79565b611c1a5f613da5565b565b60015433906001600160a01b03168114611c545760405163118cdaa760e01b81526001600160a01b0382166004820152602401610f4c565b611c5d81613da5565b50565b6001600160a01b0381165f908152600c6020526040812054610eca565b5f6060805f805f6060611c8e613dbe565b611c96613deb565b604080515f80825260208201909252600f60f81b9b939a50919850469750309650945092509050565b5f610eca82611ccc612327565b613e18565b6001600160a01b0381165f9081526040602081905281206003810154808303611cfa575f611d0a565b808260020154611d0a9190615399565b949350505050565b5f805160206156b4833981519152611d29816136e7565b6001600160a01b0384161580611d6e57506001836002811115611d4e57611d4e615093565b14158015611d6e57506002836002811115611d6b57611d6b615093565b14155b15611d8c57604051636448d6e960e11b815260040160405180910390fd5b5f826003811115611d9f57611d9f615093565b03611dbd57604051630ebbbf4760e11b815260040160405180910390fd5b6001600160a01b0384165f90815260406020819052812090815460ff166002811115611deb57611deb615093565b14611e0957604051631e7c29bf60e01b815260040160405180910390fd5b80548490829060ff19166001836002811115611e2757611e27615093565b021790555080548390829061ff001916610100836003811115611e4c57611e4c615093565b0217905550603f80546001810182555f919091527fc03004e3ce0784bf68186394306849f9b7b1200073105cd9aeb554a1802b58fd0180546001600160a01b0319166001600160a01b0387161790556040517f86cd39558dedd904177e5c8e34a5c34968f9eb6acdeb26fcf5d12731d07b780e906110ac903390889088908890615425565b5f805160206156b4833981519152611ee8816136e7565b670de0b6b3a7640000821115611f1157604051632a9ffab760e21b815260040160405180910390fd5b50604e55565b5f9182526004602090815260408084206001600160a01b0393909316845291905290205460ff1690565b5f33610edd8185856136f1565b611f826040805160c08101909152805f81526020015f81526020015f81526020015f81526020015f81526020015f81525090565b6001600160a01b0382165f9081526040602081905290819020815160c081019092528054829060ff166002811115611fbc57611fbc615093565b6002811115611fcd57611fcd615093565b81528154602090910190610100900460ff166003811115611ff057611ff0615093565b600381111561200157612001615093565b815260018201546020820152600282015460408201526003820154606082015260049091015460809091015292915050565b603f8181548110612042575f80fd5b5f918252602090912001546001600160a01b0316905081565b5f806120656115bf565b90505f612070612327565b9050835f80826001600160401b0381111561208d5761208d614d21565b6040519080825280602002602001820160405280156120b6578160200160208202803683370190505b5090505f5b8381101561231a575f8989838181106120d6576120d66153fd565b6120ec9260206040909202019081019150614ea6565b6001600160a01b0381165f90815260406020819052808220815160c0810190925280549394509192909190829060ff16600281111561212d5761212d615093565b600281111561213e5761213e615093565b81528154602090910190610100900460ff16600381111561216157612161615093565b600381111561217257612172615093565b815260200160018201548152602001600282015481526020016003820154815260200160048201548152505090508383815181106121b2576121b26153fd565b6020026020010151816040018181516121cb91906153ea565b90525060445460405163b3596f0760e01b81526001600160a01b0384811660048301525f92169063b3596f0790602401602060405180830381865afa158015612216573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061223a91906153bf565b90505f612247828a613b02565b90505f61225961098e86858e88613e4c565b9050855b898110156122d4578e8e82818110612277576122776153fd565b61228d9260206040909202019081019150614ea6565b6001600160a01b0316866001600160a01b0316036122cc578781815181106122b7576122b76153fd565b6020026020010180516122c99061544a565b90525b60010161225d565b505f805f806122e68686604954611433565b935093509350935081836122fa91906153ea565b612304908d6153ea565b9b508960010199505050505050505050506120bb565b5090979650505050505050565b603f545f90815b81811015611671575f612366603f838154811061234d5761234d6153fd565b5f918252602090912001546001600160a01b0316611815565b905061237281856153ea565b93505060010161232e565b5f805160206156b4833981519152612394816136e7565b50604555565b5f805160206156b48339815191526123b1816136e7565b8382146123d15760405163512509d360e11b815260040160405180910390fd5b5f8085815b81811015612519575f8989838181106123f1576123f16153fd565b9050602002013590505f88888481811061240d5761240d6153fd565b905060200201359050805f03612436576040516376611bc960e01b815260040160405180910390fd5b825f03612447576047829055612492565b612452866001615462565b82146124715760405163191108d960e11b815260040160405180910390fd5b848110156124925760405163090de36b60e21b815260040160405180910390fd5b61249d6001856153ac565b83036124a95760488290555b811580156124bf5750670de0b6b3a76400008114155b156124dd5760405163e501e31560e01b815260040160405180910390fd5b8060465f8d8d878181106124f3576124f36153fd565b602090810292909201358352508101919091526040015f205590945092506001016123d6565b505050505050505050565b60445460405163b3596f0760e01b81526001600160a01b0380841660048301525f92610eca9285929091169063b3596f0790602401602060405180830381865afa158015612574573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061259891906153bf565b6125a06115bf565b6001600160a01b0386165f9081526040602081905290819020815160c081019092528054829060ff1660028111156125da576125da615093565b60028111156125eb576125eb615093565b81528154602090910190610100900460ff16600381111561260e5761260e615093565b600381111561261f5761261f615093565b8152602001600182015481526020016002820154815260200160038201548152602001600482015481525050613e4c565b5f805160206156b4833981519152612667816136e7565b50604d55565b834211156126915760405163313c898160e11b815260048101859052602401610f4c565b5f7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98888886126dc8c6001600160a01b03165f908152600c6020526040902080546001810190915590565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090505f61273682613f07565b90505f61274582878787613f33565b9050896001600160a01b0316816001600160a01b03161461278c576040516325c0072360e11b81526001600160a01b0380831660048301528b166024820152604401610f4c565b6127978a8a8a6136da565b50505050505050505050565b5f828152600460205260409020600101546127bd816136e7565b6116fc8383613d0e565b6127cf613d79565b600280546001600160a01b0319166001600160a01b03838116918217909255600354604051919216907f67f679e13fe9dca16f3079221965ec41838cb8881cbc0f440bc13507c6b214c2905f90a350565b6053545f90610100900460ff161561285b5761285b7f44ac9762eec3a11893fefb11d028bb3102560094137c3ed4518712475b2577cc6136e7565b815f0361287b57604051631fd92deb60e31b815260040160405180910390fd5b6128856042613f5f565b5f036128a7576040516001621fb1e560e11b0319815260040160405180910390fd5b5f6128b0611676565b90505f670de0b6b3a7640000604f54836128ca919061536e565b6128d49190615399565b90505f670de0b6b3a7640000604c54846128ee919061536e565b6128f89190615399565b90505f61290583836153ea565b905061291b3330612916898561536e565b6136f1565b612925868261536e565b335f908152604b6020526040812080549091906129439084906153ea565b909155505060405163dc311dd360e01b81527f837b6b0b6218cf26fcf360c564ba774c692fb3f5b08855ab6fbb3138fcf0868060048201525f907f000000000000000000000000d7f86b4b8cae7d942340ff628f82735b7a20893a6001600160a01b03169063dc311dd3906024015f60405180830381865afa1580156129cb573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526129f291908101906154a4565b505050506bffffffffffffffffffffffff169050604d54811015612a29576040516382fba8b760e01b815260040160405180910390fd5b7f000000000000000000000000d7f86b4b8cae7d942340ff628f82735b7a20893a6001600160a01b0316639b1c385e6040518060c001604052807f3fd2fec10d06ee8f65e7f2e95f5c56511359ece3f33960ad8a866ae24a8ff10b81526020017f837b6b0b6218cf26fcf360c564ba774c692fb3f5b08855ab6fbb3138fcf0868081526020017f000000000000000000000000000000000000000000000000000000000000000361ffff1681526020017f00000000000000000000000000000000000000000000000000000000002625a063ffffffff168152602001600163ffffffff168152602001612b2b60405180602001604052805f1515815250613f68565b8152506040518263ffffffff1660e01b8152600401612b4a9190615591565b6020604051808303815f875af1158015612b66573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612b8a91906153bf565b95506040518060a00160405280336001600160a01b03168152602001336001600160a01b03168152602001838152602001888152602001612bcb6042613f5f565b90525f878152604a6020908152604091829020835181546001600160a01b039182166001600160a01b0319918216178355858401516001840180549190931691161790558383015160028201556060808501516003830155608090940151600490910155815189815290810185905290810189905233917f5952c21ab4e64f9ce2d0daf53a8286da3c634eab5a86ccdf38ebefc3087ea301910160405180910390a25050505050919050565b5f805160206156b4833981519152612c8e816136e7565b6001600160a01b0382165f908152604b60205260409020546113a68382613fd9565b60445460405163b3596f0760e01b81526001600160a01b0383811660048301525f92839291169063b3596f0790602401602060405180830381865afa158015612cfb573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612d1f91906153bf565b9050612d2a836140ba565b6118ac908261536e565b806001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d70573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612d9491906155ed565b6001600160a01b0316336001600160a01b031614612dc4576040516282b42960e81b815260040160405180910390fd5b806001600160a01b03166315ba56e56040518163ffffffff1660e01b81526004015f604051808303815f87803b158015612dfc575f80fd5b505af1158015612e0e573d5f803e3d5ffd5b5050505050565b60535460ff1615612e4957612e497f8f4f2da22e8ac8f11e15f9fc141cddbb5deea8800186560abb6e68c5496619a96136e7565b81156113a6575f612e586115bf565b90505f612e63612327565b90505f805f5b8681101561338f575f888883818110612e8457612e846153fd565b612e9a9260206040909202019081019150614ea6565b90505f898984818110612eaf57612eaf6153fd565b9050604002016020013590505f612ec68383614143565b6001600160a01b0384165f9081526040602081905290209091506001815460ff166002811115612ef857612ef8615093565b141580612f1f575060038154610100900460ff166003811115612f1d57612f1d615093565b145b80612f4357505f8154610100900460ff166003811115612f4157612f41615093565b145b15612f6157604051636448d6e960e11b815260040160405180910390fd5b60445460405163b3596f0760e01b81526001600160a01b0386811660048301525f92169063b3596f0790602401602060405180830381865afa158015612fa9573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612fcd91906153bf565b90505f612fda828b613b02565b905080836002015f828254612fef91906153ea565b90915550506040516370a0823160e01b81523060048201525f906001600160a01b038816906370a0823190602401602060405180830381865afa158015613038573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061305c91906153bf565b9050613069604286614189565b15613076576130766153d6565b6130816042866141a0565b156130e7575f858152604160205260409020546001600160a01b03166130e7576040805180820182526001600160a01b03898116825260208083018a81525f8a81526041909252939020915182546001600160a01b031916911617815590516001909101555b604051632142170760e11b8152336004820152306024820152604481018790526001600160a01b038816906342842e0e906064015f604051808303815f87803b158015613132575f80fd5b505af1158015613144573d5f803e3d5ffd5b50506040516370a0823160e01b81523060048201528392506001600160a01b038a1691506370a0823190602401602060405180830381865afa15801561318c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906131b091906153bf565b6131ba91906153ac565b6001146131da57604051631947c14d60e31b815260040160405180910390fd5b50670de0b6b3a764000060018454610100900460ff16600381111561320157613201615093565b036132405761323d61098e88858f886040518060c00160405290815f82015f9054906101000a900460ff1660028111156125da576125da615093565b90505b836001015f81546132509061544a565b919050819055505f805f806132688686604954611433565b935093509350935082848261327d91906153ea565b61328791906153ea565b613291908f6153ea565b9d508360515f8282546132a491906153ea565b909155506132b4905082846153ea565b6132be908e6153ea565b9c5080156132dd578060495f8282546132d791906153ea565b90915550505b811561330d578160495410613308578160495f8282546132fd91906153ac565b9091555061330d9050565b5f6049555b604080518a8152602081018c9052908101889052606081018590526080810184905260a0810183905260c081018290526001600160a01b038c1690339081907fa7c42ea0dcfdf07b7b88c53f079a11e7565c8cf2422e82c5757dbe3a7ae66df09060e00160405180910390a48b6001019b505050505050505050505050612e69565b505f5b868110156133ff5760405f8989848181106133af576133af6153fd565b6133c59260206040909202019081019150614ea6565b6001600160a01b03166001600160a01b031681526020019081526020015f206003015f81546133f39061544a565b90915550600101613392565b508481101561342157604051634edec39960e01b815260040160405180910390fd5b61342b30836141ab565b6134363033836136f1565b50505050505050565b613447613d79565b600180546001600160a01b0383166001600160a01b031990911681179091556134775f546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b5f805160206156b48339815191526134c6816136e7565b506001600160a01b039182165f90815260526020526040902080546001600160a01b03191691909216179055565b603f545f908190815b8181101561363d575f60405f603f848154811061351c5761351c6153fd565b5f9182526020808320909101546001600160a01b031683528201929092526040908101909120815160c081019092528054829060ff16600281111561356357613563615093565b600281111561357457613574615093565b81528154602090910190610100900460ff16600381111561359757613597615093565b60038111156135a8576135a8615093565b815260018281015460208301526002830154604083015260038301546060830152600490920154608090910152909150816020015160038111156135ee576135ee615093565b03613634575f613624603f848154811061360a5761360a6153fd565b5f918252602090912001546001600160a01b0316836141df565b905061363081866153ea565b9450505b506001016134fd565b509092915050565b5f805160206156b483398151915261365c816136e7565b61366e670de0b6b3a7640000806153ea565b82111561368e57604051632a9ffab760e21b815260040160405180910390fd5b50604c55565b5f805160206156b48339815191526136ab816136e7565b670de0b6b3a76400008211156136d457604051632a9ffab760e21b815260040160405180910390fd5b50605055565b6113a68383836001614260565b611c5d8133614332565b6001600160a01b03831661371a57604051634b637e8f60e11b81525f6004820152602401610f4c565b6001600160a01b0382166137435760405163ec442f0560e01b81525f6004820152602401610f4c565b6113a683838361436b565b5f828152604a60209081526040808320815160a08101835281546001600160a01b03908116808352600184015490911694820185905260028301549382018490526003830154606083018190526004909301546080830152909490939291906137b7828461536e565b6001600160a01b0385165f908152604b60205260409020549091508111156137f257604051633775d15760e11b815260040160405180910390fd5b5f6137fd6042613f5f565b90505f81886080015111613815578760800151613817565b815b90508084116138265783613828565b805b604080518082019091525f808252602082018190529195505f805f5b88811015613a4b575f8e5f8151811061385f5761385f6153fd565b6020026020010151828c60405160200161388c939291909283526020830191909152604082015260600190565b604051602081830303815290604052805190602001205f1c90506138b08188614491565b604f549196509450670de0b6b3a7640000906138cc908661536e565b6138d69190615399565b9250886138e384866153ea565b11156138f1575f9550613925565b6138fd858d8f8761458e565b61390783856153ea565b613911908a6153ac565b98508661391d81615608565b975050600195505b845f01516001600160a01b03168d6001600160a01b03168d6001600160a01b03167f32c481f9f839443a353613e2cf1b07e35f527dfe3645e32fb3c23ea6d49391e1613978895f01518a60200151614143565b60208a01516044548b5160405163b3596f0760e01b81526001600160a01b0391821660048201528c92919091169063b3596f0790602401602060405180830381865afa1580156139ca573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906139ee91906153bf565b670de0b6b3a7640000604f548d613a05919061536e565b613a0f9190615399565b60408051958652602086019490945292840191909152606083015260808201528a151560a082015260c00160405180910390a450600101613844565b506001600160a01b038a165f908152604b6020526040902054871115613a7357613a736153d6565b613a7d8a88613fd9565b5050505050505050505050505050565b6001600160a01b038381165f908152600660209081526040808320938616835292905220545f1981146116fc5781811015613af457604051637dc7a0d960e11b81526001600160a01b03841660048201526024810182905260448101839052606401610f4c565b6116fc84848484035f614260565b5f80613b0d60075490565b9050805f03613b3f57670de0b6b3a764000060455485613b2d919061536e565b613b379190615399565b915050610eca565b82613b4a828661536e565b611d0a9190615399565b5f613b5f8383611f17565b613bde575f8381526004602090815260408083206001600160a01b03861684529091529020805460ff19166001179055613b963390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4506001610eca565b505f610eca565b5f306001600160a01b037f00000000000000000000000053522e768df19c51df73863a574825d292d1d88a16148015613c3d57507f000000000000000000000000000000000000000000000000000000000000000146145b15613c6757507f7c040f5309727889c76a394cac57d7829d9aba50cf3b4124c9e9dd337bd3ba8d90565b61170b604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f22583cd651ec835793df94a187c3e236662c2f0522b0afb187ba9268dde6a2d5918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a08201525f9060c00160405160208183030381529060405280519060200120905090565b5f613d198383611f17565b15613bde575f8381526004602090815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a4506001610eca565b5f546001600160a01b03163314611c1a5760405163118cdaa760e01b8152336004820152602401610f4c565b600180546001600160a01b0319169055611c5d816146fc565b606061170b7f46756e67696679204e465420496e646578000000000000000000000000000011600a61474b565b606061170b7f3100000000000000000000000000000000000000000000000000000000000001600b61474b565b5f80613e2360075490565b9050805f03613e4157604554613b2d670de0b6b3a76400008661536e565b80613b4a848661536e565b5f835f03613e5b57505f611d0a565b5f613e6686856110ed565b9050670de0b6b3a76400008103613e80575f915050611d0a565b5f836040015186613e91919061536e565b90505f613e9c6134f4565b90505f670de0b6b3a7640000613eb2858461536e565b613ebc9190615399565b905087670de0b6b3a7640000613ed2868361536e565b613edc9190615399565b613ee6919061561d565b613ef0828561561d565b613efa919061563c565b9998505050505050505050565b5f610eca613f13613be5565b8360405161190160f01b8152600281019290925260228201526042902090565b5f805f80613f43888888886147ed565b925092509250613f5382826148b5565b50909695505050505050565b5f610eca825490565b60607f92fd13387c7fe7befbc38d303d6468778fb9731bc4583f17d92989c6fcfdeaaa82604051602401613fa191511515815260200190565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915292915050565b6001600160a01b0382165f908152604b60205260409020548181101561401257604051633775d15760e11b815260040160405180910390fd5b6001600160a01b0383165f908152604b6020526040812080548492906140399084906153ac565b9091555061404a90503084846136f1565b826001600160a01b03167f75389868cdf1173cb66026bd6868aecbfa44c163370c022a878dc8c6f5c260e08360405161408591815260200190565b60405180910390a260515460495461409d91906153ea565b305f9081526005602052604090205410156113a6576113a66153d6565b6001600160a01b038082165f9081526052602052604081205490911680156140e257806140e4565b825b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561411f573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906118ac91906153bf565b6040516bffffffffffffffffffffffff19606084901b166020820152603481018290525f9060540160405160208183030381529060405280519060200120905092915050565b5f81815260018301602052604081205415156118ac565b5f6118ac838361496d565b6001600160a01b0382166141d45760405163ec442f0560e01b81525f6004820152602401610f4c565b61142f5f838361436b565b60445460405163b3596f0760e01b81526001600160a01b0384811660048301525f92839291169063b3596f0790602401602060405180830381865afa15801561422a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061424e91906153bf565b9050826040015181611d0a919061536e565b6001600160a01b0384166142895760405163e602df0560e01b81525f6004820152602401610f4c565b6001600160a01b0383166142b257604051634a1406b160e11b81525f6004820152602401610f4c565b6001600160a01b038085165f90815260066020908152604080832093871683529290522082905580156116fc57826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258460405161432491815260200190565b60405180910390a350505050565b61433c8282611f17565b61142f5760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401610f4c565b6001600160a01b038316614395578060075f82825461438a91906153ea565b909155506144059050565b6001600160a01b0383165f90815260056020526040902054818110156143e75760405163391434e360e21b81526001600160a01b03851660048201526024810182905260448101839052606401610f4c565b6001600160a01b0384165f9081526005602052604090209082900390555b6001600160a01b0382166144215760078054829003905561443f565b6001600160a01b0382165f9081526005602052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161448491815260200190565b60405180910390a3505050565b604080518082019091525f80825260208201525f806144b9670de0b6b3a76400005f19615399565b6144c39086615668565b90505f6144d9670de0b6b3a76400005f19615399565b6144eb670de0b6b3a76400008461536e565b6144f59190615399565b90505f670de0b6b3a764000061450b878461536e565b6145159190615399565b905060415f6145256042846149b2565b815260208082019290925260409081015f20815180830190925280546001600160a01b0316808352600190910154928201929092529550614568576145686153d6565b845161457390611cd1565b9350835f03614584576145846153d6565b5050509250929050565b83516001600160a01b03165f90815260406020819052902060028101546145b69083906153ac565b6002820155604f545f90670de0b6b3a7640000906145d4908561536e565b6145de9190615399565b90508060515f8282546145f191906153ea565b90915550614601905030846149bd565b61460b81846153ea565b6001600160a01b0386165f908152604b6020526040812080549091906146329084906153ac565b9091555050855160208701515f9161464991614143565b90506146566042826149f1565b1561468857600383018054905f61466c83615608565b9091555050600183018054905f61468283615608565b91905055505b865160208801516040516323b872dd60e01b81523060048201526001600160a01b03888116602483015260448201929092529116906323b872dd906064015f604051808303815f87803b1580156146dd575f80fd5b505af11580156146ef573d5f803e3d5ffd5b5050505050505050505050565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b606060ff831461475e57611123836149fc565b81805461476a9061567b565b80601f01602080910402602001604051908101604052809291908181526020018280546147969061567b565b80156147e15780601f106147b8576101008083540402835291602001916147e1565b820191905f5260205f20905b8154815290600101906020018083116147c457829003601f168201915b50505050509050610eca565b5f80807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a084111561482657505f915060039050826148ab565b604080515f808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015614877573d5f803e3d5ffd5b5050604051601f1901519150506001600160a01b0381166148a257505f9250600191508290506148ab565b92505f91508190505b9450945094915050565b5f8260038111156148c8576148c8615093565b036148d1575050565b60018260038111156148e5576148e5615093565b036149035760405163f645eedf60e01b815260040160405180910390fd5b600282600381111561491757614917615093565b036149385760405163fce698f760e01b815260048101829052602401610f4c565b600382600381111561494c5761494c615093565b0361142f576040516335e2f38360e21b815260048101829052602401610f4c565b5f818152600183016020526040812054613bde57508154600181810184555f848152602080822090930184905584548482528286019093526040902091909155610eca565b5f6118ac8383614a39565b6001600160a01b0382166149e657604051634b637e8f60e11b81525f6004820152602401610f4c565b61142f825f8361436b565b5f6118ac8383614a5f565b60605f614a0883614b49565b6040805160208082528183019092529192505f91906020820181803683375050509182525060208101929092525090565b5f825f018281548110614a4e57614a4e6153fd565b905f5260205f200154905092915050565b5f8181526001830160205260408120548015614b39575f614a816001836153ac565b85549091505f90614a94906001906153ac565b9050808214614af3575f865f018281548110614ab257614ab26153fd565b905f5260205f200154905080875f018481548110614ad257614ad26153fd565b5f918252602080832090910192909255918252600188019052604090208390555b8554869080614b0457614b04615411565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f905560019350505050610eca565b5f915050610eca565b5092915050565b5f60ff8216601f811115610eca57604051632cd44ac360e21b815260040160405180910390fd5b5f60208284031215614b80575f80fd5b81356001600160e01b0319811681146118ac575f80fd5b5f81518084525f5b81811015614bbb57602081850181015186830182015201614b9f565b505f602082860101526020601f19601f83011685010191505092915050565b602081525f6118ac6020830184614b97565b6001600160a01b0381168114611c5d575f80fd5b5f8060408385031215614c11575f80fd5b8235614c1c81614bec565b946020939093013593505050565b5f805f805f60808688031215614c3e575f80fd5b8535614c4981614bec565b94506020860135614c5981614bec565b93506040860135925060608601356001600160401b03811115614c7a575f80fd5b8601601f81018813614c8a575f80fd5b80356001600160401b03811115614c9f575f80fd5b886020828401011115614cb0575f80fd5b959894975092955050506020019190565b803560048110611c04575f80fd5b5f8060408385031215614ce0575f80fd5b8235614ceb81614bec565b9150614cf960208401614cc1565b90509250929050565b5f60208284031215614d12575f80fd5b813580151581146118ac575f80fd5b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f191681016001600160401b0381118282101715614d5d57614d5d614d21565b604052919050565b5f6001600160401b03821115614d7d57614d7d614d21565b5060051b60200190565b5f8060408385031215614d98575f80fd5b8235915060208301356001600160401b03811115614db4575f80fd5b8301601f81018513614dc4575f80fd5b8035614dd7614dd282614d65565b614d35565b8082825260208201915060208360051b850101925087831115614df8575f80fd5b6020840193505b82841015614e1a578335825260209384019390910190614dff565b809450505050509250929050565b5f805f60608486031215614e3a575f80fd5b505081359360208301359350604090920135919050565b5f805f60608486031215614e63575f80fd5b8335614e6e81614bec565b92506020840135614e7e81614bec565b929592945050506040919091013590565b5f60208284031215614e9f575f80fd5b5035919050565b5f60208284031215614eb6575f80fd5b81356118ac81614bec565b5f8060408385031215614ed2575f80fd5b823591506020830135614ee481614bec565b809150509250929050565b5f8083601f840112614eff575f80fd5b5081356001600160401b03811115614f15575f80fd5b6020830191508360208260051b8501011115614f2f575f80fd5b9250929050565b5f805f805f60608688031215614f4a575f80fd5b8535614f5581614bec565b945060208601356001600160401b03811115614f6f575f80fd5b614f7b88828901614eef565b90955093505060408601356001600160401b03811115614f99575f80fd5b614fa588828901614eef565b969995985093965092949392505050565b60ff60f81b8816815260e060208201525f614fd460e0830189614b97565b8281036040840152614fe68189614b97565b606084018890526001600160a01b038716608085015260a0840186905283810360c0850152845180825260208087019350909101905f5b8181101561503b57835183526020938401939092019160010161501d565b50909b9a5050505050505050505050565b5f805f6060848603121561505e575f80fd5b833561506981614bec565b925060208401356003811061507c575f80fd5b915061508a60408501614cc1565b90509250925092565b634e487b7160e01b5f52602160045260245ffd5b600381106150b7576150b7615093565b9052565b600481106150b7576150b7615093565b5f60c0820190506150dd8284516150a7565b60208301516150ef60208401826150bb565b5060408301516040830152606083015160608301526080830151608083015260a083015160a083015292915050565b5f8083601f84011261512e575f80fd5b5081356001600160401b03811115615144575f80fd5b6020830191508360208260061b8501011115614f2f575f80fd5b5f806020838503121561516f575f80fd5b82356001600160401b03811115615184575f80fd5b6151908582860161511e565b90969095509350505050565b5f805f80604085870312156151af575f80fd5b84356001600160401b038111156151c4575f80fd5b6151d087828801614eef565b90955093505060208501356001600160401b038111156151ee575f80fd5b6151fa87828801614eef565b95989497509550505050565b5f805f805f805f60e0888a03121561521c575f80fd5b873561522781614bec565b9650602088013561523781614bec565b95506040880135945060608801359350608088013560ff8116811461525a575f80fd5b9699959850939692959460a0840135945060c09093013592915050565b5f8060408385031215615288575f80fd5b823561529381614bec565b91506020830135614ee481614bec565b5f805f604084860312156152b5575f80fd5b83356001600160401b038111156152ca575f80fd5b6152d68682870161511e565b909790965060209590950135949350505050565b60c081016152f882896150a7565b61530560208301886150bb565b8560408301528460608301528360808301528260a0830152979650505050505050565b6001600160a01b038581168252841660208201526080810161534d60408301856150bb565b610f1a60608301846150bb565b634e487b7160e01b5f52601160045260245ffd5b8082028115828204841417610eca57610eca61535a565b634e487b7160e01b5f52601260045260245ffd5b5f826153a7576153a7615385565b500490565b81810381811115610eca57610eca61535a565b5f602082840312156153cf575f80fd5b5051919050565b634e487b7160e01b5f52600160045260245ffd5b80820180821115610eca57610eca61535a565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52603160045260245ffd5b6001600160a01b038581168252841660208201526080810161534d60408301856150a7565b5f6001820161545b5761545b61535a565b5060010190565b8082018281125f8312801582168215821617156154815761548161535a565b505092915050565b80516bffffffffffffffffffffffff81168114611c04575f80fd5b5f805f805f60a086880312156154b8575f80fd5b6154c186615489565b94506154cf60208701615489565b935060408601516001600160401b03811681146154ea575f80fd5b60608701519093506154fb81614bec565b60808701519092506001600160401b03811115615516575f80fd5b8601601f81018813615526575f80fd5b8051615534614dd282614d65565b8082825260208201915060208360051b85010192508a831115615555575f80fd5b6020840193505b8284101561558057835161556f81614bec565b82526020938401939091019061555c565b809450505050509295509295909350565b60208152815160208201526020820151604082015261ffff604083015116606082015263ffffffff606083015116608082015263ffffffff60808301511660a08201525f60a083015160c080840152611d0a60e0840182614b97565b5f602082840312156155fd575f80fd5b81516118ac81614bec565b5f816156165761561661535a565b505f190190565b8181035f831280158383131683831282161715614b4257614b4261535a565b5f8261564a5761564a615385565b600160ff1b82145f19841416156156635761566361535a565b500590565b5f8261567657615676615385565b500690565b600181811c9082168061568f57607f821691505b6020821081036156ad57634e487b7160e01b5f52602260045260245ffd5b5091905056feddd94edc7da5bca8f576c77964a4737ba5172c728e2d539e672f0229d1e9ec2da2646970667358221220a1dcbdeaefb6e0474be103d56b83a10a8cb2843ef3c5999f99d5f30cd9f5099664736f6c634300081a0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000009940d40a6d648655da345976e820051f2b273534000000000000000000000000d7f86b4b8cae7d942340ff628f82735b7a20893a3fd2fec10d06ee8f65e7f2e95f5c56511359ece3f33960ad8a866ae24a8ff10b00000000000000000000000000000000000000000000000000000000002625a00000000000000000000000000000000000000000000000000000000000000003837b6b0b6218cf26fcf360c564ba774c692fb3f5b08855ab6fbb3138fcf08680
-----Decoded View---------------
Arg [0] : _veFUNG (address): 0x0000000000000000000000000000000000000000
Arg [1] : _liqStaking (address): 0x9940d40a6d648655dA345976E820051F2B273534
Arg [2] : _vrfCoordinator (address): 0xD7f86b4b8Cae7D942340FF628F82735b7a20893a
Arg [3] : _keyHash (bytes32): 0x3fd2fec10d06ee8f65e7f2e95f5c56511359ece3f33960ad8a866ae24a8ff10b
Arg [4] : _callbackGasLimit (uint32): 2500000
Arg [5] : _requestConfirmations (uint16): 3
Arg [6] : _subscriptionId (uint256): 59471044147124968570196395929203410233632567646580918448875739371566800078464
-----Encoded View---------------
7 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [1] : 0000000000000000000000009940d40a6d648655da345976e820051f2b273534
Arg [2] : 000000000000000000000000d7f86b4b8cae7d942340ff628f82735b7a20893a
Arg [3] : 3fd2fec10d06ee8f65e7f2e95f5c56511359ece3f33960ad8a866ae24a8ff10b
Arg [4] : 00000000000000000000000000000000000000000000000000000000002625a0
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000003
Arg [6] : 837b6b0b6218cf26fcf360c564ba774c692fb3f5b08855ab6fbb3138fcf08680
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.