Overview
S Balance
S Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
ShelterAuctionController
Compiler Version
v0.8.23+commit.f704f362
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1 /** ▒▓▒ ▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓███▓▓▒ ▒▒▒▒▓▓▓▒▓▓▓▓▓▓▓██▓ ▒██▒▓▓▓▓█▓██████████████████▓ ▒▒▒▓███████████████▒ ▒██▒▓█████████████████████▒ ▒▓██████████▓███████ ▒███████████▓▒ ▒███▓▓██████▓ █████████▒ ▒▓▒▓███████▒ ███████▓ ▒▒▒▒▒▓▓█▓▒ ▓█▓████████ ▒▒▒▒▒ ▒▒▒▒▓▓▓█████▒ ▓█████████▓ ▒▓▓▓▒▓██████▓ ▒▓▓████████▒ ▒██▓▓▓███████▒ ▒▒▓███▓████ ▒███▓█████▒ ▒▒█████▓██▓ ██████▓ ▒▒▒▓██▓██▓█████▒ ▒▒▓▓▒ ▒██▓▒▓▓████████ ▓█████▓███████▓ ██▓▓██████████▒ ▒█████████████ ███████████▓ ▒▓▓▓▓▓▓▒▓ ▒█████████▒ ▒▓▓ ▒▓█▒ ▒▒█▒▒ ▓██████ ▒▒▓▓▒ ▒▒█▒ ▓▒ ▒████ ▒▓█▓█▓▒ ▓▒██▓▒ ██ ▒▓█▓▓▓██▒ ▓█▓▓▓▓▓█▓▓▓▒ ▒▒▒ ▒▒▒▓▓▓▓▒▓▒▒▓▒▓▓▓▓▓▓▓▓▒ ▒▓█▒ ▒▓▒▓█▓ ▒▓█▓▓▓▓▓▓▓▓▓▓▒ ▒▒▒▓▒ ▒▒▒▓▓ ▓▓ ▓▓█▓ ▒▒▓▓ ▒▒█▒ ▒▓▒▓█▓ ▒▒▓▓▓▒▓▒ ▒▓▓▓▒█▒ ▒▒▒█▒ ▒▒█▓▒▒▒▓▓▓▒ ▓██▓▓▓▓▓▓▓███▓ ▒ ▒▓▓█▓ ▒▓▓▓▓█▓█▓ ▒█▓▓▒ ▓▓█▓▒▓█▓▒▒ ▓█▓ ▓███▓ ▓▓▒ ▒▒▓▓█▓▒▒▓█▒ ▒▓██▓ ▓██▓▒ ▒█▓ ▓▓██ ▒▓▓▓▒▒▓█▓ ▒▓████▒ ██▓▓▒▒▒▒▓▓███▓▒ ▒▓▓▓▓▒▒ ▒▓▓▓▓▓▓▓▒▒▒▓█▓▓▓▓█▓▓▒▒▓▓▓▓▓▒ ▒▓████▓▒ ▓▓███████▓▓▒ */ pragma solidity 0.8.23; import "../proxy/Controllable.sol"; import "../relay/ERC2771Context.sol"; import "../interfaces/IShelterAuction.sol"; import "../interfaces/IApplicationEvents.sol"; import "../lib/PackingLib.sol"; import "../lib/ShelterAuctionLib.sol"; contract ShelterAuctionController is Controllable, IShelterAuction, ERC2771Context { //region ------------------------ Constants /// @notice Version of the contract string public constant override VERSION = "1.0.0"; //endregion ------------------------ Constants //region ------------------------ Initializer function init(address controller_) external initializer { __Controllable_init(controller_); ShelterAuctionLib._S().params[IShelterAuction.ShelterAuctionParams.FEE_3] = ShelterAuctionLib.DEFAULT_FEE; } //endregion ------------------------ Initializer //region ------------------------ View function getBid(uint bidId_) external view returns (IShelterAuction.AuctionBid memory) { return ShelterAuctionLib.getBid(bidId_); } function getPosition(uint positionId_) external view returns (IShelterAuction.Position memory) { return ShelterAuctionLib.getPosition(positionId_); } /// @notice Get position currently opened by the given guild. Only one position can be opened at any time. function positionBySeller(uint sellerGuildId_) external view returns (uint positionId) { return ShelterAuctionLib.positionBySeller(sellerGuildId_); } /// @notice Get position currently opened for the given shelter or 0 function posByShelter(uint shelterId_) external view returns (uint positionId) { return ShelterAuctionLib.posByShelter(IController(controller()), shelterId_); } /// @notice Get info about bid opened by the given guild. Only one bid can be opened at any time. /// @return positionId ID of the position that the buyer is going to purchase /// @return bidIndex 0-based index of the opened bid in {positionToBidIds} function positionByBuyer(uint buyerGuildId) external view returns (uint positionId, uint bidIndex) { IShelterAuction.BuyerPositionData memory data = ShelterAuctionLib.positionByBuyer(buyerGuildId); return (data.positionId, data.bidIndex); } /// @notice Total number of currently opened positions function openPositionsLength() external view returns (uint) { return ShelterAuctionLib.openPositionsLength(); } function openPositionByIndex(uint index) external view returns (uint positionId) { return ShelterAuctionLib.openPositionByIndex(index); } /// @notice Timestamp (in seconds) of last created bid for the given position function lastAuctionBidTs(uint positionId) external view returns (uint timestamp) { return ShelterAuctionLib.lastAuctionBidTs(positionId); } /// @notice Total number of currently opened bids for the given position function positionBidsLength(uint positionId) external view returns (uint) { return ShelterAuctionLib.positionBidsLength(positionId); } function positionBidByIndex(uint positionId, uint bidIndex) external view returns (uint) { return ShelterAuctionLib.positionBidByIndex(positionId, bidIndex); } function positionCounter() external view returns (uint) { return ShelterAuctionLib.positionCounter(); } function bidCounter() external view returns (uint) { return ShelterAuctionLib.bidCounter(); } /// @notice Percent of fee (100% = 100_000) that is taken in behalf of the governance from each sold shelter. function fee() external view returns (uint) { return ShelterAuctionLib.fee(); } /// @notice Min amount that is valid to be passed to {bid} for the given position. /// Initial amount is specified by seller in openPosition, than amount is increased with rate {NEXT_AMOUNT_RATIO} /// on creation of each new bid function nextAmount(uint positionId) external view returns (uint) { return ShelterAuctionLib.nextAmount(positionId); } /// @notice Deadline of auction ending. The deadline is changed on each creation of new bid for the given position. function auctionEndTs(uint positionId) external view returns (uint timestamp) { return ShelterAuctionLib.auctionEndTs(positionId, ShelterAuctionLib.AUCTION_DURATION); } //endregion ------------------------ View //region ------------------------ Actions /// @notice Seller action. Open new position, setup min allowed auction price. /// @param shelterId Shelter to be sold. Assume, that message sender belongs to the guild that owns the shelter. /// @param minAuctionPrice Min allowed initial price, 0 is not allowed /// @return id of newly crated position. You can get this ID also by using {positionBySeller} function openPosition(uint shelterId, uint minAuctionPrice) external returns (uint) { return ShelterAuctionLib.openPosition(IController(controller()), _msgSender(), shelterId, minAuctionPrice); } /// @notice Seller action. Close not executed position. function closePosition(uint positionId) external { ShelterAuctionLib.closePosition(IController(controller()), _msgSender(), positionId, ShelterAuctionLib.AUCTION_DURATION, block.timestamp); } /// @notice Buyer action. Create new bid with amount higher than the amount of previously registered bid. /// The amount is taken from guild bank to balance of this contract and returned if the bid is closed. /// @param amount Amount of the bid in terms of the game token. Use {nextAmount} to know min valid value function bid(uint positionId, uint amount) external { ShelterAuctionLib.bid(IController(controller()), _msgSender(), positionId, amount, ShelterAuctionLib.AUCTION_DURATION, block.timestamp); } /// @notice Apply winner-bid by seller or by buyer. Assume that auction ended. /// Transfer winner-bid-amount to the seller. Transfer shelter from seller to the buyer. CLose the position. function applyAuctionBid(uint bidId) external { ShelterAuctionLib.applyAuctionBid(IController(controller()), _msgSender(), bidId, ShelterAuctionLib.AUCTION_DURATION, block.timestamp); } /// @notice Buyer action. Allow to close NOT last bid only. /// Close auction bid and transfer bid-amount back to the buyer. function closeAuctionBid(uint bidId) external { ShelterAuctionLib.closeAuctionBid(IController(controller()), _msgSender(), bidId); } //endregion ------------------------ Actions //region ------------------------ Deployer actions function setFee(uint fee_) external { ShelterAuctionLib.setFee(IController(controller()), fee_); } //endregion ------------------------ Deployer actions }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.23; /// @notice All errors of the app interface IAppErrors { //region ERC20Errors /** * @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); //endregion ERC20Errors //region ERC721Errors /** * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20. * Used in balance queries. * @param owner Address of the current owner of a token. */ error ERC721InvalidOwner(address owner); /** * @dev Indicates a `tokenId` whose `owner` is the zero address. * @param tokenId Identifier number of a token. */ error ERC721NonexistentToken(uint256 tokenId); /** * @dev Indicates an error related to the ownership over a particular token. Used in transfers. * @param sender Address whose tokens are being transferred. * @param tokenId Identifier number of a token. * @param owner Address of the current owner of a token. */ error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC721InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC721InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param tokenId Identifier number of a token. */ error ERC721InsufficientApproval(address operator, uint256 tokenId); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC721InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC721InvalidOperator(address operator); //endregion ERC721Errors error ZeroAddress(); error ZeroValueNotAllowed(); error ZeroToken(); error LengthsMismatch(); error NotEnoughBalance(); error NotEnoughAllowance(); error EmptyNameNotAllowed(); error NotInitialized(); error AlreadyInitialized(); error ReentrancyGuardReentrantCall(); error TooLongString(); error AlreadyDeployed(address deployed); //region Restrictions error ErrorNotDeployer(address sender); error ErrorNotGoc(); error NotGovernance(address sender); error ErrorOnlyEoa(); error NotEOA(address sender); error ErrorForbidden(address sender); error AdminOnly(); error ErrorNotItemController(address sender); error ErrorNotHeroController(address sender); error ErrorNotDungeonFactory(address sender); error ErrorNotObjectController(address sender); error ErrorNotStoryController(); error ErrorNotAllowedSender(); error MintNotAllowed(); //endregion Restrictions //region PackingLib error TooHighValue(uint value); error IntValueOutOfRange(int value); error OutOfBounds(uint index, uint length); error UnexpectedValue(uint expected, uint actual); error WrongValue(uint newValue, uint actual); error IntOutOfRange(int value); error ZeroValue(); /// @notice packCustomDataChange requires an input string with two zero bytes at the beginning /// 0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX0000 /// This error happens if these bytes are not zero error IncompatibleInputString(); error IncorrectOtherItemTypeKind(uint8 kind); //endregion PackingLib //region Hero error ErrorHeroIsNotRegistered(address heroToken); error ErrorHeroIsDead(address heroToken, uint heroTokenId); error ErrorHeroNotInDungeon(); error HeroInDungeon(); error ErrorNotOwner(address token, uint tokenId); error Staked(address heroToken, uint heroId); error NameTaken(); error TooBigName(); error WrongSymbolsInTheName(); error NoPayToken(address token, uint payTokenAmount); error AlreadyHaveReinforcement(); /// @notice SIP-001 - Reinforcement requires 3 skills error ErrorReinforcementRequiresThreeSkills(); error WrongTier(uint tier); error NotEnoughNgLevel(uint8 ngLevel); error NgpNotActive(address hero); error RebornNotAllowed(); error AlreadyPrePaidHero(); //endregion Hero //region Dungeon error ErrorDungeonIsFreeAlready(); error ErrorNoEligibleDungeons(); error ErrorDungeonBusy(); error ErrorNoDungeonsForBiome(uint8 heroBiome); error ErrorDungeonCompleted(); error ErrorAlreadyInDungeon(); error NotEnoughTokens(uint balance, uint expectedBalance); error DungeonAlreadySpecific(uint16 dungNum); error DungeonAlreadySpecific2(uint16 dungNum); error WrongSpecificDungeon(); //endregion Dungeon //region Items error ErrorItemNotEligibleForTheSlot(uint itemType, uint8 itemSlot); error ErrorItemSlotBusyHand(uint8 slot); error ErrorItemSlotBusy(); error ErrorItemNotInSlot(); error ErrorConsumableItemIsUsed(address item); error ErrorCannotRemoveItemFromMap(); error ErrorCannotRemoveDataFromMap(); error EquippedItemsExist(); error ItemEquipped(address item, uint itemId); error ZeroItemMetaType(); error NotZeroOtherItemMetaType(); error ZeroLevel(); error ItemTypeChanged(); error ItemMetaTypeChanged(); error UnknownItem(address item); error ErrorEquipForbidden(); error EquipForbiddenInDungeon(); error TakeOffForbiddenInDungeon(); error Consumable(address item); error NotConsumable(address item); error Broken(address item); error ZeroLife(); error RequirementsToItemAttributes(); error NotEquipped(address item); error ZeroDurability(); error ZeroAugmentation(); error TooHighAgLevel(uint8 augmentationLevel); error UseForbiddenZeroPayToken(); error IncorrectMinMaxAttributeRange(int32 min, int32 max); error SameIdsNotAllowed(); error ZeroFragility(); error OtherTypeItemNotRepairable(); error NotOther(); error DoubleItemUsageForbidden(uint itemIndex, address[] items); error ItemAlreadyUsedInSlot(address item, uint8 equippedSlot); error WrongWayToRegisterItem(); error UnionItemNotFound(address item); error WrongListUnionItemTokens(address item, uint countTokens, uint requiredCountTokens); error UnknownUnionConfig(uint unionConfigId); error UserHasNoKeyPass(address user, address keyPassItem); error MaxValue(uint value); error UnexpectedOtherItem(address item); error NotExist(); //endregion Items //region Stages error ErrorWrongStage(uint stage); error ErrorNotStages(); //endregion Stages //region Level error ErrorWrongLevel(uint heroLevel); error ErrorLevelTooLow(uint heroLevel); error ErrorHeroLevelStartFrom1(); error ErrorWrongLevelUpSum(); error ErrorMaxLevel(); //endregion Level //region Treasure error ErrorNotValidTreasureToken(address treasureToken); //endregion Treasure //region State error ErrorPaused(); error ErrorNotReady(); error ErrorNotObject1(); error ErrorNotObject2(); error ErrorNotCompleted(); //endregion State //region Biome error ErrorNotBiome(); error ErrorIncorrectBiome(uint biome); error TooHighBiome(uint biome); //endregion Biome //region Misc error ErrorWrongMultiplier(uint multiplier); error ErrorNotEnoughMana(uint32 mana, uint requiredMana); error ErrorExperienceMustNotDecrease(); error ErrorNotEnoughExperience(); error ErrorNotChances(); error ErrorNotEligible(address heroToken, uint16 dungNum); error ErrorZeroKarmaNotAllowed(); //endregion Misc //region GOC error GenObjectIdBiomeOverflow(uint8 biome); error GenObjectIdSubTypeOverflow(uint subType); error GenObjectIdIdOverflow(uint id); error UnknownObjectTypeGoc1(uint8 objectType); error UnknownObjectTypeGoc2(uint8 objectType); error UnknownObjectTypeGocLib1(uint8 objectType); error UnknownObjectTypeGocLib2(uint8 objectType); error UnknownObjectTypeForSubtype(uint8 objectSubType); error FightDelay(); error ZeroChance(); error TooHighChance(uint32 chance); error TooHighRandom(uint random); error EmptyObjects(); error ObjectNotFound(); error WrongGetObjectTypeInput(); error WrongChances(uint32 chances, uint32 maxChances); //endregion GOC //region Story error PageNotRemovedError(uint pageId); error NotItem1(); error NotItem2(); error NotRandom(uint32 random); error NotHeroData(); error NotGlobalData(); error ZeroStoryIdRemoveStory(); error ZeroStoryIdStoryAction(); error ZeroStoryIdAction(); error NotEnoughAmount(uint balance, uint requiredAmount); error NotAnswer(); error AnswerStoryIdMismatch(uint16 storyId, uint16 storyIdFromAnswerHash); error AnswerPageIdMismatch(uint16 pageId, uint16 pageIdFromAnswerHash); //endregion Story //region FightLib error NotMagic(); error NotAType(uint atype); //endregion FightLib //region MonsterLib error NotYourDebuffItem(); error UnknownAttackType(uint attackType); error NotYourAttackItem(); /// @notice The skill item cannot be used because it doesn't belong either to the hero or to the hero's helper error NotYourBuffItem(); //endregion MonsterLib //region GameToken error ApproveToZeroAddress(); error MintToZeroAddress(); error TransferToZeroAddress(); error TransferAmountExceedsBalance(uint balance, uint value); error InsufficientAllowance(); error BurnAmountExceedsBalance(); error NotMinter(address sender); //endregion GameToken //region NFT error TokenTransferNotAllowed(); error IdOverflow(uint id); error NotExistToken(uint tokenId); error EquippedItemIsNotAllowedToTransfer(uint tokenId); //endregion NFT //region CalcLib error TooLowX(uint x); //endregion CalcLib //region Controller error NotFutureGovernance(address sender); //endregion Controller //region Oracle error OracleWrongInput(); //endregion Oracle //region ReinforcementController error AlreadyStaked(); error MaxFee(uint8 fee); error MinFee(uint8 fee); error StakeHeroNotStats(); error NotStaked(); error NoStakedHeroes(); error GuildHelperNotAvailable(uint guildId, address helper, uint helperId); error HelperNotAvailableInGivenBiome(); //endregion ReinforcementController //region SponsoredHero error InvalidHeroClass(); error ZeroAmount(); error InvalidProof(); error NoHeroesAvailable(); error AlreadyRegistered(); //endregion SponsoredHero //region SacraRelay error SacraRelayNotOwner(); error SacraRelayNotDelegator(); error SacraRelayNotOperator(); error SacraRelayInvalidChainId(uint callChainId, uint blockChainId); error SacraRelayInvalidNonce(uint callNonce, uint txNonce); error SacraRelayDeadline(); error SacraRelayDelegationExpired(); error SacraRelayNotAllowed(); error SacraRelayInvalidSignature(); /// @notice This error is generated when custom error is caught /// There is no info about custom error in SacraRelay /// but you can decode custom error by selector, see tests error SacraRelayNoErrorSelector(bytes4 selector, string tracingInfo); /// @notice This error is generated when custom error is caught /// There is no info about custom error in SacraRelay /// but you can decode custom error manually from {errorBytes} as following: /// if (keccak256(abi.encodeWithSignature("MyError()")) == keccak256(errorBytes)) { ... } error SacraRelayUnexpectedReturnData(bytes errorBytes, string tracingInfo); error SacraRelayCallToNotContract(address notContract, string tracingInfo); //endregion SacraRelay //region Misc error UnknownHeroClass(uint heroClass); error AbsDiff(int32 a, int32 b); //region Misc //region ------------------------ UserController error NoAvailableLootBox(address msgSender, uint lootBoxKind); error FameHallHeroAlreadyRegistered(uint8 openedNgLevel); //endregion ------------------------ UserController //region ------------------------ Guilds error AlreadyGuildMember(); error NotGuildMember(); error WrongGuild(); error GuildActionForbidden(uint right); error GuildHasMaxSize(uint guildSize); error GuildHasMaxLevel(uint level); error TooLongUrl(); error TooLongDescription(); error CannotRemoveGuildOwnerFromNotEmptyGuild(); error GuildControllerOnly(); error GuildAlreadyHasShelter(); error ShelterIsBusy(); error ShelterIsNotRegistered(); error ShelterIsNotOwnedByTheGuild(); error ShelterIsInUse(); error GuildHasNoShelter(); error ShelterBidIsNotAllowedToBeUsed(); error ShelterHasHeroesInside(); error SecondGuildAdminIsNotAllowed(); error NotEnoughGuildBankBalance(uint guildId); error GuildReinforcementCooldownPeriod(); error NoStakedGuildHeroes(); error NotStakedInGuild(); error ShelterHasNotEnoughLevelForReinforcement(); error NotBusyGuildHelper(); error GuildRequestNotActive(); error GuildRequestNotAvailable(); error NotAdminCannotAddMemberWithNotZeroRights(); //endregion ------------------------ Guilds //region ------------------------ Shelters error ErrorNotShelterController(); error ErrorNotGuildController(); error ShelterHasNotItem(uint shelterId, address item); error MaxNumberItemsSoldToday(uint numSoldItems, uint limit); error GuildHasNotEnoughPvpPoints(uint64 pointsAvailable, uint pointRequired); error FreeShelterItemsAreNotAllowed(uint shelterId, address item); error TooLowShelterLevel(uint8 shelterLevel, uint8 allowedShelterLevel); error NotEnoughPvpPointsCapacity(address user, uint usedPoints, uint pricePvpPoints, uint64 capactiy); error IncorrectShelterLevel(uint8 shelterLevel); //endregion ------------------------ Shelters //region ------------------------ Auction error WrongAuctionPosition(); error AuctionPositionClosed(); error AuctionBidOpened(uint positionId); error TooLowAmountToBid(); error AuctionEnded(); error TooLowAmountForNewBid(); error AuctionSellerOnly(); error AuctionBuyerOnly(); error AuctionBidNotFound(); error AuctionBidClosed(); error OnlyShelterAuction(); error CannotCloseLastBid(); error AuctionNotEnded(); error NotShelterAuction(); error AuctionPositionOpened(uint positionId); error AuctionSellerCannotBid(); error CannotApplyNotLastBid(); error AuctionGuildWithShelterCannotBid(); //endregion ------------------------ Auction //region ------------------------ Pawnshop error AuctionPositionNotSupported(uint positionId); error PositionNotSupported(uint positionId); error NotNftPositionNotSupported(uint positionId); error CallFailed(bytes callResultData); error PawnShopZeroOwner(); error PawnShopZeroFeeRecipient(); error PawnShopNotOwner(); error PawnShopAlreadyAnnounced(); error PawnShopTimeLock(); error PawnShopWrongAddressValue(); error PawnShopWrongUintValue(); error PawnShopZeroAddress(); error PawnShopTooHighValue(); error PawnShopZeroAToken(); error PawnShopZeroCToken(); error PawnShopWrongAmounts(); error PawnShopPosFeeForInstantDealForbidden(); error PawnShopPosFeeAbsurdlyHigh(); error PawnShopIncorrect(); error PawnShopWrongId(); error PawnShopNotBorrower(); error PawnShopPositionClosed(); error PawnShopPositionExecuted(); error PawnShopWrongBidAmount(); error PawnShopTooLowBid(); error PawnShopNewBidTooLow(); error PawnShopBidAlreadyExists(); error PawnShopAuctionEnded(); error PawnShopNotLender(); error PawnShopTooEarlyToClaim(); error PawnShopPositionNotExecuted(); error PawnShopAlreadyClaimed(); error PawnShopAuctionNotEnded(); error PawnShopBidClosed(); error PawnShopNoBids(); error PawnShopAuctionBidNotFound(); error PawnShopWrongBid(); error PawnShopBidNotFound(); //endregion ------------------------ Pawnshop }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.23; import "./IGOC.sol"; import "./IStatController.sol"; import "./IDungeonFactory.sol"; import "./IStoryController.sol"; import "./IFightCalculator.sol"; /// @notice All events of the app interface IApplicationEvents { //region ------------------ StatController event HeroItemSlotChanged( address heroToken, uint heroTokenId, uint itemType, uint itemSlot, address itemToken, uint itemTokenId, bool equip, address caller ); event CurrentStatsChanged( address heroToken, uint heroTokenId, IStatController.ChangeableStats change, bool increase, address caller ); event BonusAttributesChanged( address heroToken, uint heroTokenId, bool add, bool temporally, address caller ); event TemporallyAttributesCleared(address heroToken, uint heroTokenId, address caller); event NewHeroInited(address heroToken, uint heroTokenId, IStatController.ChangeableStats stats); event LevelUp( address heroToken, uint heroTokenId, uint heroClass, IStatController.CoreAttributes change ); event ConsumableUsed(address heroToken, uint heroTokenId, address item); event RemoveConsumableUsage(address heroToken, uint heroTokenId, address item); event HeroCustomDataChanged(address token, uint tokenId, bytes32 index, uint value); event HeroCustomDataChangedNg(address token, uint tokenId, bytes32 index, uint value, uint8 ngLevel); event HeroCustomDataCleared(address token, uint tokenId); event GlobalCustomDataChanged(bytes32 index, uint value); //endregion ------------------ StatController //region ------------------ DungeonFactoryController event DungeonLaunched( uint16 dungeonLogicNum, uint64 dungeonId, address heroToken, uint heroTokenId, address treasuryToken, uint treasuryAmount ); event BossCompleted(uint32 objectId, uint biome, address hero, uint heroId); event FreeDungeonAdded(uint8 biome, uint64 dungeonId); event ObjectOpened(uint64 dungId, address hero, uint id, uint32 objId, uint iteration, uint currentStage); event Clear(uint64 dungId); event DungeonLogicRegistered(uint16 dungLogicId, IDungeonFactory.DungeonGenerateInfo info); event DungeonLogicRemoved(uint16 dungLogicId); event DungeonSpecificLogicRegistered(uint16 dungLogicId, uint biome, uint heroCls); event DungeonSpecificLogicRemoved(uint16 dungLogicId, uint heroLvl, uint heroCls); event DungeonRegistered(uint16 dungLogicId, uint64 dungeonId); event DungeonRemoved(uint16 dungLogicId, uint64 dungeonId); event MinLevelForTreasuryChanged(address token, uint level); event ObjectAction( uint64 dungId, IGOC.ActionResult result, uint currentStage, address heroToken, uint heroTokenId, uint newStage ); /// @notice On add the item to the dungeon event AddTreasuryItem(uint64 dungId, address itemAdr, uint itemId); event AddTreasuryToken(uint64 dungId, address token, uint amount); event ClaimToken(uint64 dungId, address token, uint amount); event ClaimItem(uint64 dungId, address token, uint id); event Entered(uint64 dungId, address hero, uint id); event DungeonCompleted(uint16 dungLogicNum, uint64 dungId, address hero, uint heroId); event Exit(uint64 dungId, bool claim); event ExitForcibly(uint64 dungId, address hero, uint heroId); event FreeDungeonRemoved(uint8 biome, uint64 dungeonId); event HeroCurrentDungeonChanged(address hero, uint heroId, uint64 dungeonId); //endregion ------------------ DungeonFactoryController //region ------------------ GameObjectController event EventRegistered(uint32 objectId, IGOC.EventRegInfo eventRegInfo); event StoryRegistered(uint32 objectId, uint16 storyId); event MonsterRegistered(uint32 objectId, IGOC.MonsterGenInfo monsterGenInfo); event ObjectRemoved(uint32 objectId); event ObjectResultEvent( uint64 dungeonId, uint32 objectId, IGOC.ObjectType objectType, address hero, uint heroId, uint8 stageId, uint iteration, bytes data, IGOC.ActionResult result, uint salt ); //endregion ------------------ GameObjectController //region ------------------ StoryController event SetBurnItemsMeta(uint storyId, IStoryController.AnswerBurnRandomItemMeta meta); event SetNextObjRewriteMeta(uint storyId, IStoryController.NextObjRewriteMeta meta); event SetAnswersMeta(uint storyId, uint16[] answerPageIds, uint8[] answerHeroClasses, uint16[] answerIds); event SetAnswerNextPageMeta(uint storyId, IStoryController.AnswerNextPageMeta meta); event SetAnswerAttributeRequirements(uint storyId, IStoryController.AnswerAttributeRequirementsMeta meta); event SetAnswerItemRequirements(uint storyId, IStoryController.AnswerItemRequirementsMeta meta); event SetAnswerTokenRequirementsMeta(uint storyId, IStoryController.AnswerTokenRequirementsMeta meta); event SetAnswerAttributes(uint storyId, IStoryController.AnswerAttributesMeta meta); event SetAnswerHeroCustomDataRequirementMeta(uint storyId, IStoryController.AnswerCustomDataMeta meta); event SetAnswerGlobalCustomDataRequirementMeta(uint storyId, IStoryController.AnswerCustomDataMeta meta); event SetSuccessInfo(uint storyId, IStoryController.AnswerResultMeta meta); event SetFailInfo(uint storyId, IStoryController.AnswerResultMeta meta); event SetCustomDataResult(uint storyId, IStoryController.AnswerCustomDataResultMeta meta, IStoryController.CustomDataResult _type); event StoryCustomDataRequirements(uint storyId, bytes32 requiredCustomDataIndex, uint requiredCustomDataMinValue, uint requiredCustomDataMaxValue, bool requiredCustomDataIsHero); event StoryRequiredLevel(uint storyId, uint requiredLevel); event StoryFinalized(uint32 objectId, uint storyId); event StoryRemoved(uint32 objectId, uint storyId); event ItemBurned( address heroToken, uint heroTokenId, uint64 dungeonId, uint objectId, address nftToken, uint nftId, uint stageId, uint iteration ); /// @notice Durability of the item was reduced to 0 event ItemBroken( address heroToken, uint heroTokenId, uint64 dungeonId, uint objectId, address nftToken, uint nftId, uint stageId, uint iteration ); event NotEquippedItemBurned( address heroToken, uint heroTokenId, uint64 dungeonId, uint storyId, address nftToken, uint nftId, uint stageId, uint iteration ); event StoryChangeAttributes( uint32 objectId, address heroToken, uint heroTokenId, uint64 dungeonId, uint storyId, uint stageId, uint iteration, int32[] attributes ); //endregion ------------------ StoryController //region ------------------------ HeroController event HeroRegistered(address hero, uint8 heroClass, address payToken, uint payAmount); event HeroCreatedNgp(address hero, uint heroId, string name, address owner, string refCode, uint8 tier, uint8 ngLevel); event BiomeChanged(address hero, uint heroId, uint8 biome); event LevelUp(address hero, uint heroId, address owner, IStatController.CoreAttributes change); event ReinforcementAsked(address hero, uint heroId, address helpHeroToken, uint helpHeroId); event GuildReinforcementAsked(address hero, uint heroId, address helpHeroToken, uint helpHeroId); event OtherItemGuildReinforcement(address item, uint itemId, address hero, uint heroId, address helpHeroToken, uint helpHeroId); event ReinforcementReleased(address hero, uint heroId, address helperToken, uint helperId); event GuildReinforcementReleased(address hero, uint heroId, address helperToken, uint helperId); event Killed(address hero, uint heroId, address killer, bytes32[] dropItems, uint dropTokenAmount); event Reborn(address hero, uint heroId, uint8 newNgLevel); event BossKilled(address account, address hero, uint heroId, uint8 biome, uint8 newNgLevel, bool reborn, uint rewardAmount); event TierSetup(uint8 tier, address hero, uint72 payAmount, uint8[] slots, address[][] items); //endregion ------------------------ HeroController //region ------------------------ FightLib event FightResultProcessed( address sender, IFightCalculator.FightInfoInternal result, IFightCalculator.FightCall callData, uint iteration ); //endregion ------------------------ FightLib //region ------------------------ Oracle event Random(uint number, uint max); //endregion ------------------------ Oracle //region ------------------------ Controller event OfferGovernance(address newGov); event GovernanceAccepted(address gov); event StatControllerChanged(address value); event StoryControllerChanged(address value); event GameObjectControllerChanged(address value); event ReinforcementControllerChanged(address value); event OracleChanged(address value); event TreasuryChanged(address value); event ItemControllerChanged(address value); event HeroControllerChanged(address value); event GameTokenChanged(address value); event DungeonFactoryChanged(address value); event ProxyUpdated(address proxy, address logic); event Claimed(address token, uint amount); event TokenStatusChanged(address token, bool status); event UserControllerChanged(address value); event GuildControllerChanged(address value); event GameTokenPriceChanged(uint value); event RewardsPoolChanged(address value); event Process(address token, uint amount, address from, uint toBurn, uint toTreasury, uint toGov); //endregion ------------------------ Controller //region ------------------------ ReinforcementController event HeroStaked(address heroToken, uint heroId, uint biome, uint score); event HeroStakedV2(address heroToken, uint heroId, uint biome, uint rewardAmount); event HeroWithdraw(address heroToken, uint heroId); event HeroAsk(address heroToken, uint heroId); event HeroAskV2(address heroToken, uint heroId, uint hitsLast24h, uint fixedFee, uint helperRewardAmount); event TokenRewardRegistered(address heroToken, uint heroId, address token, uint amountAdded, uint totalAmount); event GuildTokenRewardRegistered(address heroToken, uint heroId, address token, uint amountAdded, uint guildId); event NftRewardRegistered(address heroToken, uint heroId, address token, uint id); event GuildNftRewardRegistered(address heroToken, uint heroId, address token, uint id, uint guildId); event ToHelperRatioChanged(uint value); event ClaimedToken(address heroToken, uint heroId, address token, uint amount, address recipient); event ClaimedItem(address heroToken, uint heroId, address item, uint itemId, address recipient); event MinLevelChanged(uint8 value); event MinLifeChancesChanged(uint value); //endregion ------------------------ ReinforcementController //region ------------------------ Treasury, reward pool event AssetsSentToDungeon(address dungeon, address token, uint amount); event RewardSentToUser(address receiver, address token, uint rewardAmount); event NotEnoughReward(address receiver, address token, uint rewardAmountToPay); event BaseAmountChanged(uint oldValue, uint newValue); //endregion ------------------------ Treasury, reward pool //region ------------------------ EventLib event EventResult(uint64 dungeonId, address heroToken, uint heroTokenId, uint8 stageId, IStatController.ActionInternalInfo gen, uint iteration); //endregion ------------------------ EventLib //region ------------------------ Item controller and helper contracts event ItemRegistered(address item, IItemController.RegisterItemParams info); event OtherItemRegistered(address item, IItemController.ItemMeta meta, bytes packedItemMetaData); event ItemRemoved(address item); event OtherItemRemoved(address item); event NewItemMinted(address item, uint itemId, IItemController.MintInfo info); event Equipped(address item, uint itemId, address heroToken, uint heroTokenId, uint8 itemSlot); event TakenOff(address item, uint itemId, address heroToken, uint heroTokenId, uint8 itemSlot, address destination); event ItemRepaired(address item, uint itemId, uint consumedItemId, uint16 baseDurability); event FailedToRepairItem(address item, uint itemId, uint consumedItemId, uint16 itemDurability); event Augmented(address item, uint itemId, uint consumedItemId, uint8 augLevel, IItemController.AugmentInfo info); event NotAugmented(address item, uint itemId, uint consumedItemId, uint8 augLevel); event ReduceDurability(address item, uint itemId, uint newDurability); event Used(address item, uint tokenId, address heroToken, uint heroTokenId); event Destroyed(address item, uint itemId); event FragilityReduced(address item, uint itemId, address consumedItem, uint consumedItemId, uint fragility); event ItemControllerHelper(address helper); event SetUnionConfig(uint configId, address[] items, uint[] count, address itemToMint); event RemoveUnionConfig(uint configId); event SetUnionKeyPass(address keyPassItem); event CombineItems(address msgSender, uint configId, address[] items, uint[][] itemIds, address mintedItem, uint mintedItemId); //endregion ------------------------ Item controller and helper contracts //region ------------------------ NFT and GameToken (only custom events, not ERC20/721 standards) event ChangePauseStatus(bool value); event MinterChanged(address value); event UniqueUriChanged(uint id, string uri); event BaseUriChanged(string uri); event HeroMinted(uint heroId); event HeroBurned(uint heroId); event HeroUriByStatusChanged(string uri, uint statusLvl); event ItemMinted(uint tokenId); event ItemBurned(uint tokenId); event UriByRarityChanged(string uri, uint rarity); event SponsoredHeroCreated(address msgSender, address heroAddress, uint heroId, string heroName); //endregion ------------------------ NFT and GameToken (only custom events, not ERC20/721 standards) //region ------------------------ User controller event SetUserName(address user, string name); event SetUserAvatar(address user, string avatar); event LootBoxOpened(address user, uint lootBoxKind, address[] itemTokens, uint[] itemTokenIds); event LootBoxConfigChanged(uint lootBoxKind, address[] mintItems, uint32[] mintItemsChances, uint maxDropItems); event SetFeeRenaming(uint feeRenaming); event ActivityCompleted(address user, bool daily, bool weekly); event FameHallHeroRegistered(address hero, uint heroId, address heroOwner, uint8 openedNgLevel); //endregion ------------------------ User controller //region ------------------------ Guild event GuildCreated(address owner, uint guildId, string name, string urlLogo); event AddToGuild(uint guildId, address newUser); event ChangeGuildRights(uint guildId, address user, uint rights); event RemoveFromGuild(uint guildId, address user); event GuildDeleted(uint guildId); event GuildLevelUp(uint guildId, uint8 newLevel); event GuildRename(uint guildId, string newName); event GuildLogoChanged(uint guildId, string newLogoUrl); event GuildDescriptionChanged(uint guildId, string newDescription); event SetGuildRelation(uint guildId1, uint guildId2, bool peace); event TransferFromGuildBank(address user, address token, uint amount, address recipient); event TransferNftFromGuildBank(address user, address[] nfts, uint[] tokenIds, address recipient); event GuildBankDeployed(uint guildId, address guildBank); event SetToHelperRatio(uint guildId, uint8 value, address user); event TopUpGuildBank(address msgSender, uint guildId, address guildBank, uint amount); event GuildRequestRegistered(address msgSender, uint guildId, string userMessage, uint depositAmount); event GuildRequestStatusChanged(address msgSender, uint guildRequestId, uint8 newStatus, address user); event SetToHelperRatio(uint guildId, address msgSender, uint8 toHelperRatio); event SetGuildRequestDepositAmount(uint guildId, address msgSender, uint amount); event SetGuildBaseFee(uint fee); event SetPvpPointsCapacity(address msgSender, uint64 capacityPvpPoints, address[] users); event SetShelterController(address shelterController); event SetShelterAuction(address shelterAuction); event PayForBidFromGuildBank(uint guildId, uint amount, uint bid); //endregion ------------------------ Guild //region ------------------------ Guild shelter event RegisterShelter(uint sheleterId, uint price); event SetShelterItems( uint shelterId, address[] items, uint64[] pricesInPvpPoints, uint128[] pricesInGameTokens, uint16[] maxItemsPerDayThresholds ); event RemoveShelterItems(uint shelterId, address[] items); event BuyShelter(uint guidlId, uint shelterId); event LeaveShelter(uint guildId, uint shelterId); event NewShelterBid(uint shelterId, uint buyerGuildId, uint amount); event RevokeShelterBid(uint shelterId); event UseShelterBid(uint shelterId, uint sellerGuildId, uint buyerGuidId, uint amount); event PurchaseShelterItem(address msgSender, address item, uint numSoldItems, uint priceInPvpPoints, uint priceInGameToken); event ChangeShelterOwner(uint shelterId, uint fromGuildId, uint toGuildId); event RestInShelter(address msgSender, address heroToken, uint heroTokenId); //endregion ------------------------ Guild shelter //region ------------------------ Guild reinforcement event GuildHeroStaked(address heroToken, uint heroId, uint guildId); event GuildHeroWithdrawn(address heroToken, uint heroId, uint guildId); event GuildHeroAsked(address heroToken, uint heroId, uint guildId, address user); /// @param user Address can be 0 if heroId was already burnt at the moment of reinforcement releasing event GuildHeroReleased(address heroToken, uint heroId, uint guildId, address user); //endregion ------------------------ Guild reinforcement //region ------------------------ Guild auction event AuctionPositionOpened(uint positionId, uint shelterId, uint sellerGuildId, address msgSender, uint minAuctionPrice); event AuctionPositionClosed(uint positionId, address msgSender); event AuctionBidOpened(uint bidId, uint positionId, uint amount, address msgSender); //endregion ------------------------ Guild auction //region ------------------------ Guild bank event GuildBankTransfer(address token, address recipient, uint amount); event GuildBankTransferNft(address to, address nft, uint tokenId); event GuildBankTransferNftMulti(address to, address[] nfts, uint[] tokenIds); //endregion ------------------------ Guild bank //region ------------------------ Pawnshop event PawnShopRouterDeployed(address pawnShop, address gameToken, address routerOwner, address deployed); event PawnShopRouterTransfer(address token, uint amount, address receiver); event PawnShopRouterBulkSell(address[] nfts, uint[] nftIds, uint[] prices, address nftOwner, uint[] positionIds); event PawnShopRouterClosePositions(uint[] positionIds, address receiver); event PawnShopRouterBulkBuy(uint[] positionIds, address receiver); //endregion ------------------------ Pawnshop }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.23; interface IControllable { function VERSION() external pure returns (string memory); function revision() external view returns (uint); function previousImplementation() external view returns (address); function isController(address contract_) external view returns (bool); function isGovernance(address contract_) external view returns (bool); function created() external view returns (uint256); function createdBlock() external view returns (uint256); function controller() external view returns (address); function increaseRevision(address oldLogic) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.23; interface IController { function governance() external view returns (address); function statController() external view returns (address); function storyController() external view returns (address); function gameObjectController() external view returns (address); function reinforcementController() external view returns (address); function oracle() external view returns (address); function treasury() external view returns (address); function itemController() external view returns (address); function heroController() external view returns (address); function dungeonFactory() external view returns (address); function gameToken() external view returns (address); function validTreasuryTokens(address token) external view returns (bool); function isDeployer(address adr) external view returns (bool); function onPause() external view returns (bool); function userController() external view returns (address); function guildController() external view returns (address); function rewardsPool() external view returns (address); function gameTokenPrice() external view returns (uint); function process(address token, uint amount, address from) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.23; import "../openzeppelin/EnumerableSet.sol"; import "../openzeppelin/EnumerableMap.sol"; interface IDungeonFactory { /// @custom:storage-location erc7201:dungeon.factory.main struct MainState { /// @dev biome => dungeonLaunchedId mapping(uint => EnumerableSet.UintSet) freeDungeons; /// @dev hero + heroId + biome (packMapObject) -> completed mapping(bytes32 => bool) bossCompleted; /// @dev hero + heroId + dungNum (packDungeonKey) -> completed mapping(bytes32 => bool) specificDungeonCompleted; /// @notice Max biome completed by the hero /// @dev hero + heroId (nftPacked) -> max biome completed mapping(bytes32 => uint8) maxBiomeCompleted; /// @notice which dungeon the hero is currently in /// @dev hero+id => current DungeonId mapping(bytes32 => uint64) heroCurrentDungeon; // --- /// @notice Specific dungeon for the given pair of hero level + hero class /// ALl specific dungeons are listed also in allSpecificDungeons /// @dev packUint8Array(specReqBiome, specReqHeroClass) => dungNum mapping(bytes32 => uint16) dungeonSpecific; /// @dev contains all specific dungNum for easy management EnumerableSet.UintSet allSpecificDungeons; /// @dev biome => dungNum mapping(uint8 => EnumerableSet.UintSet) dungeonsLogicByBiome; // --- /// @dev max available biome. auto-increment with new dung deploy uint8 maxBiome; /// @notice Address of treasure token => min hero level required /// @dev manual threshold for treasury mapping(address => uint) minLevelForTreasury; /// @notice Contains arrays for SKILL_1, SKILL_2, SKILL_3 with 0 or 1 /// i.e. [0, 1, 0] means that durability of SKILL_2 should be reduced /// @dev hero + heroId => uint8[] array where idx = slotNum mapping(bytes32 => bytes32) skillSlotsForDurabilityReduction; /// @notice Counter of dungeons, it's incremented on launch of a new dungeon uint64 dungeonCounter; /// @dev dungNum = init attributes mapping(uint16 => DungeonAttributes) dungeonAttributes; /// @dev dungeonId => status mapping(uint64 => DungeonStatus) dungeonStatuses; } struct ObjectGenerateInfo { /// @notice List of chamber types for each unique object /// @dev uint8 types, packed using PackingLib.packUint8Array bytes32[] objTypesByStages; /// @notice List of chances for each chamber type /// @dev uint64 chances uint32[][] objChancesByStages; } struct DungeonGenerateInfo { /// @notice List of chamber types for each unique object uint8[][] objTypesByStages; /// @notice List of chances for each chamber type uint32[][] objChancesByStages; uint32[] uniqObjects; uint8 minLevel; uint8 maxLevel; bytes32[] requiredCustomDataIndex; uint64[] requiredCustomDataMinValue; uint64[] requiredCustomDataMaxValue; bool[] requiredCustomDataIsHero; } /// @notice Attributes of the given dungeon logic struct DungeonAttributes { /// @notice Total number of stages that should be passed to complete the dungeon uint8 stages; uint8 biome; /// @notice Default list of objects that should be passed in the dungeon uint32[] uniqObjects; /// @dev min+max (packUint8Array) bytes32 minMaxLevel; bytes32[] requiredCustomDataIndex; /// @notice Packed DungeonGenerateInfo.requiredCustomData: MinValue, MaxValue, IsHero /// @dev min+max+isHero(packStoryCustomDataRequirements) bytes32[] requiredCustomDataValue; ObjectGenerateInfo info; } /// @notice Current status of the given dungeon struct DungeonStatus { uint64 dungeonId; /// @notice Dungeon logic id uint16 dungNum; /// @notice True if the dungeon is completed by the hero bool isCompleted; /// @notice Hero in the dungeon or 0 address heroToken; uint heroTokenId; /// @notice Current object that should be passed by the hero. 0 - new object is not opened uint32 currentObject; /// @notice Current stage in the dungeon that should be passed by the hero. uint8 currentStage; EnumerableMap.AddressToUintMap treasuryTokens; /// @notice All items that were minted on result of made actions bytes32[] treasuryItems; /// @notice Total number of stages that should be passed to complete the dungeon /// This value can be bigger than length of uniqObjects uint8 stages; /// @notice List of objects to be passed in the stage. The list can be dynamically changed during passing the stages uint32[] uniqObjects; } //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// function launchForNewHero(address heroToken, uint heroTokenId, address owner) external returns (uint64 dungeonId); function maxBiomeCompleted(address heroToken, uint heroTokenId) external view returns (uint8); function currentDungeon(address heroToken, uint heroTokenId) external view returns (uint64); function skillSlotsForDurabilityReduction(address heroToken, uint heroTokenId) external view returns (uint8[] memory result); function setBossCompleted(uint32 objectId, address heroToken, uint heroTokenId, uint8 heroBiome) external; /// @notice Hero exists current dungeon forcibly same as when dying but without loosing life chance function exitForcibly(address heroToken, uint heroTokenId, address msgSender) external; function maxAvailableBiome() external view returns (uint8); function reborn(address hero, uint heroId) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @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); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.23; import "./IStatController.sol"; import "./IItemController.sol"; interface IFightCalculator { enum AttackType { UNKNOWN, // 0 MELEE, // 1 MAGIC, // 2 SLOT_3, SLOT_4, SLOT_5, SLOT_6, SLOT_7, SLOT_8, SLOT_9, SLOT_10 } /// @notice Attacker info: suitable both for hero and monsters struct AttackInfo { /// @notice Type of the attack /// by default, if attack token presents, it's magic attack and not-magic otherwise /// but this logic can become more complicated after introducing new attack types AttackType attackType; /// @notice NFT selected by hero for attack, it should be equip on. /// If attacker is a monster, this is a special case (stub NFT with zero ID is used) address attackToken; uint attackTokenId; address[] skillTokens; uint[] skillTokenIds; } struct FighterInfo { int32[] fighterAttributes; IStatController.ChangeableStats fighterStats; AttackType attackType; address attackToken; uint attackTokenId; uint race; } struct Statuses { bool stun; bool burn; bool freeze; bool confuse; bool curse; bool poison; bool gotCriticalHit; bool missed; bool hitBlocked; } struct FightResult { int32 healthA; int32 healthB; int32 manaConsumedA; int32 manaConsumedB; } struct FightCall { FighterInfo fighterA; FighterInfo fighterB; uint64 dungeonId; uint32 objectId; address heroAdr; uint heroId; uint8 stageId; uint iteration; uint8 turn; } struct SkillSlots { bool slot1; bool slot2; bool slot3; } //region ------------------------ FightLib-internal (FightInfoInternal is required by IApplicationEvents..) struct FightInfoInternal { Fighter fighterA; Fighter fighterB; } struct Fighter { IFightCalculator.FighterInfo info; IItemController.AttackInfo magicAttack; int32 health; int32 manaConsumed; int32 damage; int32 damagePoison; int32 damageReflect; IFightCalculator.Statuses statuses; } //endregion ------------------------ FightLib-internal function fight(FightCall memory callData) external returns (FightResult memory); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.23; import "../openzeppelin/EnumerableSet.sol"; import "./IController.sol"; interface IGOC { enum ObjectType { UNKNOWN, // 0 EVENT, // 1 MONSTER, // 2 STORY, // 3 END_SLOT } enum ObjectSubType { UNKNOWN_0, // 0 ENEMY_NPC_1, // 1 ENEMY_NPC_SUPER_RARE_2, // 2 BOSS_3, // 3 SHRINE_4, // 4 CHEST_5, // 5 STORY_6, // 6 STORY_UNIQUE_7, // 7 SHRINE_UNIQUE_8, // 8 CHEST_UNIQUE_9, // 9 ENEMY_NPC_UNIQUE_10, // 10 STORY_ON_ROAD_11, // 11 STORY_UNDERGROUND_12, // 12 STORY_NIGHT_CAMP_13, // 13 STORY_MOUNTAIN_14, // 14 STORY_WATER_15, // 15 STORY_CASTLE_16, // 16 STORY_HELL_17, // 17 STORY_SPACE_18, // 18 STORY_WOOD_19, // 19 STORY_CATACOMBS_20, // 20 STORY_BAD_HOUSE_21, // 21 STORY_GOOD_TOWN_22, // 22 STORY_BAD_TOWN_23, // 23 STORY_BANDIT_CAMP_24, // 24 STORY_BEAST_LAIR_25, // 25 STORY_PRISON_26, // 26 STORY_SWAMP_27, // 27 STORY_INSIDE_28, // 28 STORY_OUTSIDE_29, // 29 STORY_INSIDE_RARE_30, STORY_OUTSIDE_RARE_31, ENEMY_NPC_INSIDE_32, ENEMY_NPC_INSIDE_RARE_33, ENEMY_NPC_OUTSIDE_34, ENEMY_NPC_OUTSIDE_RARE_35, END_SLOT } /// @custom:storage-location erc7201:game.object.controller.main struct MainState { /// @dev objId = biome(00) type(00) id(0000) => biome(uint8) + objType(uint8) /// Id is id of the event, story or monster. mapping(uint32 => bytes32) objectMeta; /// @dev biome(uint8) + objType(uint8) => set of object id mapping(bytes32 => EnumerableSet.UintSet) objectIds; /// @dev heroAdr180 + heroId64 + cType8 + biome8 => set of already played objects. Should be cleared periodically mapping(bytes32 => EnumerableSet.UintSet) playedObjects; /// @dev HeroAdr(160) + heroId(uint64) + objId(uint32) => iteration count. It needs for properly emit events for every new entrance. mapping(bytes32 => uint) iterations; /// @dev objId(uint32) => EventInfo mapping(uint32 => EventInfo) eventInfos; /// @dev objId(uint32) => storyId mapping(uint32 => uint16) storyIds; /// @dev objId(uint32) => MonsterInfo mapping(uint32 => MonsterInfo) monsterInfos; /// @dev hero+id => last fight action timestamp mapping(bytes32 => uint) lastHeroFightTs; /// @dev delay for user actions in fight (suppose to prevent bot actions) uint fightDelay; } struct ActionResult { bool kill; bool completed; address heroToken; address[] mintItems; int32 heal; int32 manaRegen; int32 lifeChancesRecovered; int32 damage; int32 manaConsumed; uint32 objectId; uint32 experience; uint heroTokenId; uint iteration; uint32[] rewriteNextObject; } struct EventInfo { /// @dev chance to use good or bad attributes/stats uint32 goodChance; /// @dev toBytes32ArrayWithIds bytes32[] goodAttributes; bytes32[] badAttributes; /// @dev experience(uint32) + heal(int32) + manaRegen(int32) + lifeChancesRecovered(int32) + damage(int32) + manaConsume(int32) packStatsChange bytes32 statsChange; /// @dev item+chance packItemMintInfo bytes32[] mintItems; } struct MonsterInfo { /// @dev toBytes32ArrayWithIds bytes32[] attributes; /// @dev level(uint8) + race(uint8) + experience(uint32) + maxDropItems(uint8) packMonsterStats bytes32 stats; /// @dev attackToken(160) + attackTokenId(uint64) + attackType(uint8) packAttackInfo bytes32 attackInfo; /// @dev item+chance packItemMintInfo bytes32[] mintItems; /// @dev heroAdr(160) + heroId(uint64) => iteration => GeneratedMonster packed mapping(bytes32 => mapping(uint => bytes32)) _generatedMonsters; } struct MultiplierInfo { uint8 biome; /// @notice NG_LEVEL of the hero who is going to fight with the given monster /// Use type(uint8).max for !NG+ uint8 heroNgLevel; } struct GeneratedMonster { bool generated; uint8 turnCounter; int32 hp; uint32 amplifier; } struct MonsterGenInfo { uint16 monsterId; uint8 biome; ObjectSubType subType; uint8[] attributeIds; int32[] attributeValues; uint8 level; uint8 race; uint32 experience; uint8 maxDropItems; address attackToken; uint64 attackTokenId; uint8 attackType; address[] mintItems; uint32[] mintItemsChances; } struct ActionContext { address sender; address heroToken; IController controller; uint8 biome; uint8 objectSubType; uint8 stageId; uint8 heroNgLevel; uint32 objectId; uint64 dungeonId; uint heroTokenId; uint salt; uint iteration; bytes data; } struct EventRegInfo { uint8 biome; uint16 eventId; ObjectSubType subType; uint32 goodChance; AttributeGenerateInfo goodAttributes; AttributeGenerateInfo badAttributes; uint32 experience; int32 heal; int32 manaRegen; int32 lifeChancesRecovered; int32 damage; int32 manaConsumed; address[] mintItems; uint32[] mintItemsChances; } struct AttributeGenerateInfo { uint8[] ids; int32[] values; } ////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////// /// @dev represent object registration if non zero values function getObjectMeta(uint32 objectId) external view returns (uint8 biome, uint8 objectSubType); function isBattleObject(uint32 objectId) external view returns (bool); function getRandomObject( uint8[] memory cTypes, uint32[] memory chances, uint8 biomeLevel, address heroToken, uint heroTokenId ) external returns (uint32 objectId); function open(address heroToken, uint heroTokenId, uint32 objectId) external returns (uint iteration); function action( address sender, uint64 dungeonId, uint32 objectId, address heroToken, uint heroTokenId, uint8 stageId, bytes memory data ) external returns (ActionResult memory); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.23; import "../openzeppelin/EnumerableSet.sol"; interface IGuildController { enum GuildRightBits { ADMIN_0, RENAME_1, CHANGE_LOGO_2, CHANGE_SHELTER_3, ADD_MEMBER_4, REMOVE_MEMBER_5, BANK_TOKENS_OPERATION_6, CHANGE_ROLES_7, LEVEL_UP_8, SET_RELATION_KIND_9, BANK_ITEMS_OPERATION_10, SET_GUILD_PARAMS_11, CHANGE_PURCHASING_SHELTER_ITEMS_CAPACITY_12 } enum GuildsParams { NONE_0, COUNTER_GUILD_IDS_1, BASE_FEE_2, COUNTER_GUILD_REQUESTS_3, REENTRANT_STATUS_4, SHELTER_CONTROLLER_5, SHELTER_AUCTION_6 } enum GuildRequestStatus { NONE_0, ACCEPTED_1, REJECTED_2, CANCELED_3 } /// @custom:storage-location erc7201:guild.controller.main struct MainState { /// @notice Mapping to store various guilds params (with global values for all guilds) mapping(GuildsParams param => uint value) guildsParam; /// @notice guildId => address of instance of GuildBank contract mapping(uint guildId => address) guildBanks; /// @notice guild id => guild data (owner, name, logo, etc) mapping(uint guildId => GuildData) guildData; /// @notice name => guild id mapping(string guildName => uint guildId) nameToGuild; /// @notice EOA => guild id, EOA can be a member of a single guild only mapping(address member => uint guildId) memberToGuild; /// @notice List of participants of guilds /// @dev Allowed number of members is 20 + 5 * guildLevel mapping(uint guildId => EnumerableSet.AddressSet listEoa) members; /// @notice Rights of the member in the guild, mask of GuildRightBits mapping(address member => uint maskRights) rights; /// @notice _getGuildsPairKey(guild1, guild2) => status (false - war, true - peace) mapping(bytes32 guildsPairKey => bool) relationsPeaceful; // ---------------------------- Request to join to the guild /// @notice Full list of requests registered for the guild mapping(uint guildId => mapping(GuildRequestStatus status => EnumerableSet.UintSet guildRequestIds)) guildRequests; /// @notice List of active requests created by the given user. /// "Active" => deposit should be returned to the user. /// All not-active requests are removed from here automatically. mapping(address user => EnumerableSet.UintSet guildRequestIds) userActiveGuildRequests; /// @notice Data of all guild requests ever created mapping(uint guildRequestId => GuildRequestData) guildRequestData; /// @notice Deposit amount required to create a guild request mapping(uint guildId => GuildRequestDeposit) guildRequestDepositAmounts; /// @notice Counter of spent pvp points + number of guild pvp-points allowed to be used by the guild member mapping(uint guildId => mapping(address member => UserPvpPoints)) userPvpPoints; /// @notice guild id => guildDescription mapping(uint guildId => string) guildDescription; } struct GuildData { /// @notice Not empty unique guild name string guildName; /// @notice URL of guild logo (empty is allowed) string urlLogo; /// @notice Creator (owner) of the guild address owner; /// @notice Guild level [1...10] uint8 guildLevel; /// @notice Percent of guild reinforcement fee Value in range [_FEE_MIN ... _TO_HELPER_RATIO_MAX], i.e. [10..50] uint8 toHelperRatio; /// @notice Global guild points counter, it's incremented on each victory in php-fight. /// @dev Assume here, that uint64 is enough to store any sums of scores uint64 pvpCounter; } struct GuildRequestData { GuildRequestStatus status; /// @notice Creator of the guild request that asks to include him to the guild address user; /// @notice Message to the guild owner from the user string userMessage; uint guildId; } struct GuildRequestDeposit { bool initialized; uint192 amount; } struct UserPvpPoints { /// @notice How many guild pvp-points the user is allowed to use uint64 capacityPvpPoints; /// @notice How many guild pvp-points the user has used uint64 spentPvpPoints; } /// ---------------------------------------------------------------------------------------------- function memberOf(address user) external view returns (uint guildId); function guildToShelter(uint guildId) external view returns (uint shelterId); function getGuildData(uint guildId) external view returns ( string memory guildName, string memory urlLogo, address owner, uint8 guildLevel, uint64 pvpCounter, uint toHelperRatio ); function getRights(address user) external view returns (uint); function getGuildBank(uint guildId) external view returns (address); function shelterController() external view returns (address); function usePvpPoints(uint guildId, address user, uint64 priceInPvpPoints) external; function payFromGuildBank(uint guildId, uint shelterPrice) external; function payFromBalance(uint amount, address user) external; /// @notice Ensure that the {user} has given {right}, revert otherwise function checkPermissions(address user, uint right) external view returns (uint guildId, uint rights); function shelterAuctionController() external view returns (address); function payForAuctionBid(uint guildId, uint amount, uint bid) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.23; import "../openzeppelin/EnumerableSet.sol"; import "../openzeppelin/EnumerableMap.sol"; interface IHeroController { /// @custom:storage-location erc7201:hero.controller.main struct MainState { /// @dev A central place for all hero tokens /// @dev Deprecated. Controller is used instead. address heroTokensVault; /// @dev heroAdr => packed tokenAdr160+ amount96 mapping(address => bytes32) payToken; /// @dev heroAdr => heroCls8 mapping(address => uint8) heroClass; // --- /// @dev hero+id => individual hero name mapping(bytes32 => string) heroName; /// @dev name => hero+id, needs for checking uniq names mapping(string => bytes32) nameToHero; // --- /// @dev hero+id => biome mapping(bytes32 => uint8) heroBiome; /// @notice Exist reinforcement of any kind for the given hero /// @dev hero+id => packed reinforcement helper+id mapping(bytes32 => bytes32) reinforcementHero; /// @dev hero+id => reinforcement packed attributes mapping(bytes32 => bytes32[]) reinforcementHeroAttributes; /// @notice packedHero (hero + id) => count of calls of beforeTokenTransfer mapping(bytes32 => uint) countHeroTransfers; // ------------------------------------ NG plus /// @notice (tier, hero address) => TierInfo, where tier = [2, 3] /// @dev For tier=1 no data is required. Amount for tier 1 is stored in {payToken}, no items are minted /// Token from {payToken} is equal for all tiers mapping(bytes32 packedTierHero => TierInfo) tiers; mapping(bytes32 packedHero => HeroInfo) heroInfo; /// @notice Max NG_LVL reached by the heroes of a given account mapping(address user => uint8 maxNgLevel) maxUserNgLevel; /// @notice When the hero has killed boss on the given biome first time /// packedBiomeNgLevel = packed (biome, NG_LEVEL) mapping(bytes32 packedHero => mapping (bytes32 packedBiomeNgLevel => uint timestamp)) killedBosses; /// @notice Max NG_LEVEL reached by any user uint maxOpenedNgLevel; } /// @notice Tier = hero creation cost option /// There are 3 tiers: /// 1: most chip option, just pay fixed amount {payTokens} - new hero is created /// 2: pay bigger amount - random skill is equipped on the newly created hero /// 3: pay even more amount - random sill + some random items are equipped on the newly created hero struct TierInfo { /// @notice Cost of the hero creation using the given tier in terms of the token stored in {payToken} /// This amount is used for tiers 2, 3. For tier 1 the amount is taken from {payToken} uint amount; /// @notice All slots for which items-to-mint are registered in {itemsToMint} EnumerableSet.UintSet slots; /// @notice slot => items that can be minted and equipped on the hero to the given {slot} after hero creation mapping(uint8 slot => address[] items) itemsToMint; } /// @notice Current NG+-related values struct HeroInfo { /// @notice Hero tier = [0..3]. 0 - the hero is post-paid, it can be changed by upgrading the hero to pre-paid uint8 tier; /// @notice NG_LVL of the hero uint8 ngLevel; /// @notice True if hero has passed last biome on current NG+ and so NG_LEVEL can be incremented (reborn is allowed) bool rebornAllowed; /// @notice Amount paid for the hero on creation OR on upgrade to NG+ /// Amount paid for creation of the hero in terms of game token (!NG+) is NOT stored here. /// @dev uint72 is used here to pack the whole struct to single slot uint72 paidAmount; /// @notice Pay token used to pay {paidAmount} address paidToken; } /// @notice Input data to create new hero struct HeroCreationData { /// @notice Desired NG_LVL of the hero uint8 ngLevel; /// @notice Desired tire of the newly created hero. Allowed values: [1..3] uint8 tier; /// @notice Enter to the dungeon after creation bool enter; /// @notice Desired hero name string heroName; /// @notice Optional: user account for which the hero is created address targetUserAccount; /// @notice Optional: ref-code to be passed to the hero-creation-related event string refCode; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function heroClass(address hero) external view returns (uint8); function heroBiome(address hero, uint heroId) external view returns (uint8); function payTokenInfo(address hero) external view returns (address token, uint amount); function heroReinforcementHelp(address hero, uint heroId) external view returns (address helperHeroToken, uint helperHeroId); function score(address hero, uint heroId) external view returns (uint); function isAllowedToTransfer(address hero, uint heroId) external view returns (bool); function beforeTokenTransfer(address hero, uint heroId) external returns (bool); // --- function create(address hero, string memory heroName_, bool enter) external returns (uint); function kill(address hero, uint heroId) external returns (bytes32[] memory dropItems); /// @notice Take off all items from the hero, reduce life to 1. The hero is NOT burnt. /// Optionally reduce mana to zero and/or decrease life chance. function softKill(address hero, uint heroId, bool decLifeChances, bool resetMana) external returns (bytes32[] memory dropItems); function releaseReinforcement(address hero, uint heroId) external returns (address helperToken, uint helperId); function resetLifeAndMana(address hero, uint heroId) external; function countHeroTransfers(address hero, uint heroId) external view returns (uint); function askGuildReinforcement(address hero, uint heroId, address helper, uint helperId) external; function getHeroInfo(address hero, uint heroId) external view returns (IHeroController.HeroInfo memory data); function registerKilledBoss(address hero, uint heroId, uint32 objectId) external; function maxOpenedNgLevel() external view returns (uint); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.23; import "./IStatController.sol"; import "./IGOC.sol"; import "../openzeppelin/EnumerableSet.sol"; interface IItemController { enum GlobalParam { UNKNOWN_0, /// @notice Address of ItemControllerHelper ITEM_CONTROLLER_HELPER_ADDRESS_1 } /// @custom:storage-location erc7201:item.controller.main struct MainState { ////////////////// GENERATE ////////////////// EnumerableSet.AddressSet items; /// @dev itemAdr => itemMetaType8 + itemLvl8 + itemType8 + baseDurability16 + defaultRarity8 + minAttr8 + maxAttr8 + manaCost32 + req(packed core 128) mapping(address => bytes32) itemMeta; /// @dev itemAdr => packed tokenAdr160+ amount96 mapping(address => bytes32) augmentInfo; // --- common attr --- /// @dev itemAdr => id8 + min(int32) + max(int32) + chance32 mapping(address => bytes32[]) generateInfoAttributes; // --- consumable --- /// @dev itemAdr => ids+values (toBytes32ArrayWithIds) mapping(address => bytes32[]) _itemConsumableAttributes; /// @dev itemAdr => IStatController.ChangeableStats packed int32[] mapping(address => bytes32) itemConsumableStats; // --- buff --- /// @dev itemAdr => id8 + min(int32) + max(int32) + chance32 mapping(address => bytes32[]) generateInfoCasterAttributes; /// @dev itemAdr => id8 + minDmg(int32) + maxDmg(int32) + chance32 mapping(address => bytes32[]) generateInfoTargetAttributes; // --- attack --- /// @dev itemAdr => packed AttackInfo: attackType8 + min32 + max32 + factors(packed core 128) mapping(address => bytes32) generateInfoAttack; ////////////////// ITEMS INFO ////////////////// /// @dev itemAdr+id => itemRarity8 + augmentationLevel8 + itemDurability16 mapping(bytes32 => bytes32) itemInfo; /// @dev itemAdr+id => heroAdr+id mapping(bytes32 => bytes32) equippedOn; // --- common attr --- /// @dev itemAdr+Id => ids+values (toBytes32ArrayWithIds) mapping(bytes32 => bytes32[]) _itemAttributes; // --- consumable --- // consumable stats unchangeable, get them by address // --- buff --- /// @dev itemAdr+Id => ids+values (toBytes32ArrayWithIds) mapping(bytes32 => bytes32[]) _itemCasterAttributes; /// @dev itemAdr+Id => ids+values (toBytes32ArrayWithIds) mapping(bytes32 => bytes32[]) _itemTargetAttributes; // --- attack --- /// @dev itemAdr+Id => packed AttackInfo: attackType8 + min32 + max32 + factors(packed core 128) mapping(bytes32 => bytes32) _itemAttackInfo; ////////////////// Additional generate info ////////////////// /// @notice (itemAdr) => Bitmask of ConsumableActionBits mapping(address => uint) _consumableActionMask; /// --------------------------------- SIP-003: Item fragility /// @notice itemAdr + id => item fragility counter that displays the chance of an unsuccessful repair /// @dev [0...100_000], decimals 3 mapping(bytes32 packedItem => uint fragility) itemFragility; /// @notice Universal mapping to store various addresses and numbers (params of the contract) mapping (GlobalParam param => uint value) globalParam; /// @notice Item address => packedMetadata /// {packedMetaData} is encoded using abi.encode/abi.decode /// Read first byte, detect meta data type by the byte value, apply proper decoder from PackingLib mapping(address item => bytes packedMetaData) packedItemMetaData; } struct RegisterItemParams { ItemMeta itemMeta; address augmentToken; uint augmentAmount; ItemGenerateInfo commonAttributes; IGOC.AttributeGenerateInfo consumableAttributes; IStatController.ChangeableStats consumableStats; ItemGenerateInfo casterAttributes; ItemGenerateInfo targetAttributes; AttackInfo genAttackInfo; /// @notice Bit mask of ConsumableActionBits uint consumableActionMask; } /// @notice Possible actions that can be triggered by using the consumable item enum ConsumableActionBits { CLEAR_TEMPORARY_ATTRIBUTES_0 // other items are used instead this mask } struct ItemGenerateInfo { /// @notice Attribute ids uint8[] ids; /// @notice Min value of the attribute, != 0 int32[] mins; /// @notice Max value of the attribute, != 0 int32[] maxs; /// @notice Chance of the selection [0..MAX_CHANCES] uint32[] chances; } struct ItemMeta { uint8 itemMetaType; // Level in range 1-99. Reducing durability in low level dungeons. lvl/5+1 = biome uint8 itemLevel; IItemController.ItemType itemType; uint16 baseDurability; uint8 defaultRarity; uint32 manaCost; // it doesn't include positions with 100% chance uint8 minRandomAttributes; uint8 maxRandomAttributes; IStatController.CoreAttributes requirements; } // Deprecated. Todo - remove enum FeeType { UNKNOWN, REPAIR, AUGMENT, STORY, END_SLOT } enum ItemRarity { UNKNOWN, // 0 NORMAL, // 1 MAGIC, // 2 RARE, // 3 SET, // 4 UNIQUE, // 5 END_SLOT } enum ItemType { NO_SLOT, // 0 HEAD, // 1 BODY, // 2 GLOVES, // 3 BELT, // 4 AMULET, // 5 RING, // 6 OFF_HAND, // 7 BOOTS, // 8 ONE_HAND, // 9 TWO_HAND, // 10 SKILL, // 11 OTHER, // 12 END_SLOT } enum ItemMetaType { UNKNOWN, // 0 COMMON, // 1 ATTACK, // 2 BUFF, // 3 CONSUMABLE, // 4 END_SLOT } enum AttackType { UNKNOWN, // 0 FIRE, // 1 COLD, // 2 LIGHTNING, // 3 CHAOS, // 4 END_SLOT } struct AttackInfo { AttackType aType; int32 min; int32 max; // if not zero - activate attribute factor for the attribute IStatController.CoreAttributes attributeFactors; } struct ItemInfo { ItemRarity rarity; uint8 augmentationLevel; uint16 durability; } /// @dev The struct is used in events, so it's moved here from the lib struct MintInfo { IItemController.ItemMeta meta; uint8[] attributesIds; int32[] attributesValues; IItemController.ItemRarity itemRarity; IItemController.AttackInfo attackInfo; uint8[] casterIds; int32[] casterValues; uint8[] targetIds; int32[] targetValues; } /// @dev The struct is used in events, so it's moved here from the lib struct AugmentInfo { uint8[] attributesIds; int32[] attributesValues; IItemController.AttackInfo attackInfo; uint8[] casterIds; int32[] casterValues; uint8[] targetIds; int32[] targetValues; } ///region ------------------------ Item type "Other" /// @notice Possible kinds of "Other" items /// Each "Other" item has each own structure for metadata, see OtherItemXXX enum OtherSubtypeKind { UNKNOWN_0, /// @notice Item to reduce fragility, see SCB-1014. Metadata is {OtherItemReduceFragility} REDUCE_FRAGILITY_1, /// @notice This item allows asking guild reinforcement to the guild member USE_GUILD_REINFORCEMENT_2, /// @notice Exit from dungeon (shelter of level 3 is required) EXIT_FROM_DUNGEON_3, /// @notice Rest in the shelter: restore of hp & mp, clear temporally attributes, clear used consumables (shelter of level 3 is required) REST_IN_SHELTER_4, /// @notice Stub item (i.e. OTHER_4) that has no logic in contracts, but it has correct (not empty) packedMetaData EMPTY_NO_LOGIC_5, END_SLOT } struct OtherItemReduceFragility { /// @notice "Other" item kind. It MUST BE first field in the struct. uint8 kind; /// @notice Value on which the fragility will be reduced. /// @dev [0...100%], decimals 3, so the value is in the range [0...10_000] uint248 value; } ///endregion ------------------------ Item type "Other" //////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////// function itemMeta(address item) external view returns (ItemMeta memory meta); function augmentInfo(address item) external view returns (address token, uint amount); function genAttributeInfo(address item) external view returns (ItemGenerateInfo memory info); function genCasterAttributeInfo(address item) external view returns (ItemGenerateInfo memory info); function genTargetAttributeInfo(address item) external view returns (ItemGenerateInfo memory info); function genAttackInfo(address item) external view returns (AttackInfo memory info); function itemInfo(address item, uint itemId) external view returns (ItemInfo memory info); function equippedOn(address item, uint itemId) external view returns (address hero, uint heroId); function itemAttributes(address item, uint itemId) external view returns (int32[] memory values, uint8[] memory ids); function consumableAttributes(address item) external view returns (int32[] memory values, uint8[] memory ids); function consumableStats(address item) external view returns (IStatController.ChangeableStats memory stats); function casterAttributes(address item, uint itemId) external view returns (int32[] memory values, uint8[] memory ids); function targetAttributes(address item, uint itemId) external view returns (int32[] memory values, uint8[] memory ids); function itemAttackInfo(address item, uint itemId) external view returns (AttackInfo memory info); function score(address item, uint tokenId) external view returns (uint); function isAllowedToTransfer(address item, uint tokenId) external view returns (bool); // --- function mint(address item, address recipient) external returns (uint itemId); function reduceDurability(address hero, uint heroId, uint8 biome, bool reduceDurabilityAllSkills) external; function destroy(address item, uint tokenId) external; function takeOffDirectly( address item, uint itemId, address hero, uint heroId, uint8 itemSlot, address destination, bool broken ) external; /// @notice SIP-003: item fragility counter that displays the chance of an unsuccessful repair. /// @dev [0...100%], decimals 3, so the value is in the range [0...10_000] function itemFragility(address item, uint itemId) external view returns (uint); /// @notice SIP-003: The quest mechanic that previously burned the item will increase its fragility by 1% function incBrokenItemFragility(address item, uint itemId) external; function equip( address hero, uint heroId, address[] calldata items, uint[] calldata itemIds, uint8[] calldata itemSlots ) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.23; interface IOracle { function getRandomNumber(uint max, uint seed) external returns (uint); function getRandomNumberInRange(uint min, uint max, uint seed) external returns (uint); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.23; import "../openzeppelin/EnumerableSet.sol"; import "../openzeppelin/EnumerableMap.sol"; interface IShelterAuction { enum ShelterAuctionParams { NONE_0, POSITION_COUNTER_1, BID_COUNTER_2, FEE_3 } //region ------------------------ Data types /// @custom:storage-location erc7201:shelter.auction.main struct MainState { /// @notice Mapping to store auction params (i.e. counters) mapping(ShelterAuctionParams param => uint value) params; /// @notice Hold all positions. Any record should not be removed mapping(uint positionId => Position) positions; /// @dev BidId => Bid. Hold all bids. Any record should not be removed mapping(uint bidId => AuctionBid) auctionBids; /// @notice List of currently opened positions EnumerableSet.UintSet openPositions; /// @notice Seller to position map /// At any moment each guild can have only one opened position to sell mapping(uint sellerGuildId => uint openedPositionId) sellerPosition; /// @notice Position that the buyer is going to purchase. /// At any moment each guild can have only one opened position to purchase mapping(uint buyerGuildId => BuyerPositionData) buyerPosition; /// @notice All open and close bids for the given position mapping(uint positionId => uint[] bidIds) positionToBidIds; /// @notice Timestamp of the last bid for the auction mapping(uint positionId => uint timestamp) lastAuctionBidTs; } struct Position { bool open; /// @notice User that opens the position. The user belongs to the guild with id = {sellerGuildId} address seller; /// @notice Assume that shelter can be stored as uint64 uint64 shelterId; uint128 positionId; /// @notice Min allowed (initial) auction price. Only first bid is able to use it. uint128 minAuctionPrice; uint128 sellerGuildId; } struct AuctionBid { bool open; /// @notice User that opens the bid. The user belongs to the guild with id = {buyerGuildId} address buyer; uint128 bidId; uint128 positionId; /// @notice Bid amount in terms of game token. This amount is transferred from guild Bank to ShelterAuction balance uint128 amount; uint128 buyerGuildId; } struct BuyerPositionData { /// @notice ID of the position that the buyer is going to purchase uint128 positionId; /// @notice 0-based index of the opened bid in {positionToBidIds} uint128 bidIndex; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function positionBySeller(uint sellerGuildId_) external view returns (uint positionId); function positionByBuyer(uint buyerGuildId) external view returns (uint positionId, uint bidIndex); function posByShelter(uint shelterId_) external view returns (uint positionId); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.23; import "../openzeppelin/EnumerableSet.sol"; interface IShelterController { /// @custom:storage-location erc7201:shelter.controller.main struct MainState { /// @notice List of items allowed to be purchased in the shelter mapping(uint shelterId => EnumerableSet.AddressSet) shelterItems; /// @notice Data of items available for purchasing in the given shelter mapping(uint shelterId => mapping(address item => ShelterItemData)) shelterItemData; // @notice Statistics how much items were purchased per day mapping(uint shelterId => mapping(uint32 epochDay => mapping(address item => uint))) countPurchasedItems; /// @notice List of registered shelters in {biome} mapping(uint biome => EnumerableSet.UintSet shelterUids) shelters; /// @notice Initial price of the shelters in game tokens mapping(uint shelterId => uint) shelterPrices; /// @notice Shelters belong to a specific guild (not the player) /// Shelters can be free (don't belong to any guild) mapping(uint shelterId => uint guildId) shelterToGuild; /// @notice Each guild can own 0 or 1 shelter mapping(uint guildId => uint shelterId) guildToShelter; } struct ShelterItemData { /// @notice Price of the item in pvp-points uint64 priceInPvpPoints; /// @notice Price of the item game token uint128 priceInGameToken; /// @notice Max number of items that can be purchases per day in the shelter. 0 - no limitations uint16 maxItemsPerDayLimit; } /// ---------------------------------------------------------------------------------------------- function clearShelter(uint guildId) external; function guildToShelter(uint guildId) external view returns (uint shelterId); function changeShelterOwner(uint shelterId, uint newOwnerGuildId) external; function shelterToGuild(uint shelterId) external view returns (uint guildId); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.23; import "../openzeppelin/EnumerableSet.sol"; import "../openzeppelin/EnumerableMap.sol"; interface IStatController { /// @custom:storage-location erc7201:stat.controller.main struct MainState { mapping(bytes32 => bytes32[]) heroTotalAttributes; /// @dev heroAdr+heroId => int32 packed strength, dexterity, vitality, energy mapping(bytes32 => bytes32) _heroCore; mapping(bytes32 => bytes32[]) heroBonusAttributes; mapping(bytes32 => bytes32[]) heroTemporallyAttributes; /// @dev heroAdr+heroId => uint32 packed level, experience, life, mana, lifeChances mapping(bytes32 => bytes32) heroStats; /// @dev heroAdr+heroId+itemSlot => itemAdr + itemId mapping(bytes32 => bytes32) heroSlots; /// @dev heroAdr+heroId => busy slots uint8[] packed mapping(bytes32 => bytes32) heroBusySlots; mapping(bytes32 => EnumerableSet.AddressSet) usedConsumables; /// @dev heroCustomDataV2 is used instead mapping(bytes32 => mapping(bytes32 => uint)) _deprecated_heroCustomData; mapping(bytes32 => uint) globalCustomData; /// @notice packNftIdWithValue(hero, heroId, ngLevel) => hero custom data map /// @dev initially it was packedHero => hero custom data map mapping(bytes32 => EnumerableMap.Bytes32ToUintMap) heroCustomDataV2; } enum ATTRIBUTES { // core STRENGTH, // 0 DEXTERITY, // 1 VITALITY, // 2 ENERGY, // 3 // attributes DAMAGE_MIN, // 4 DAMAGE_MAX, // 5 ATTACK_RATING, // 6 DEFENSE, // 7 BLOCK_RATING, // 8 LIFE, // 9 MANA, // 10 // resistance FIRE_RESISTANCE, // 11 COLD_RESISTANCE, // 12 LIGHTNING_RESISTANCE, // 13 // dmg against DMG_AGAINST_HUMAN, // 14 DMG_AGAINST_UNDEAD, // 15 DMG_AGAINST_DAEMON, // 16 DMG_AGAINST_BEAST, // 17 // defence against DEF_AGAINST_HUMAN, // 18 DEF_AGAINST_UNDEAD, // 19 DEF_AGAINST_DAEMON, // 20 DEF_AGAINST_BEAST, // 21 // --- unique, not augmentable // hero will not die until have positive chances LIFE_CHANCES, // 22 // increase chance to get an item MAGIC_FIND, // 23 // decrease chance to get an item DESTROY_ITEMS, // 24 // percent of chance x2 dmg CRITICAL_HIT, // 25 // dmg factors MELEE_DMG_FACTOR, // 26 FIRE_DMG_FACTOR, // 27 COLD_DMG_FACTOR, // 28 LIGHTNING_DMG_FACTOR, // 29 // increase attack rating on given percent AR_FACTOR, // 30 // percent of damage will be converted to HP LIFE_STOLEN_PER_HIT, // 31 // amount of mana restored after each battle MANA_AFTER_KILL, // 32 // reduce all damage on percent after all other reductions DAMAGE_REDUCTION, // 33 // -- statuses // chance to stun an enemy, stunned enemy skip next hit STUN, // 34 // chance burn an enemy, burned enemy will loss 50% of defence BURN, // 35 // chance freeze an enemy, frozen enemy will loss 50% of MELEE damage FREEZE, // 36 // chance to reduce enemy's attack rating on 50% CONFUSE, // 37 // chance curse an enemy, cursed enemy will loss 50% of resistance CURSE, // 38 // percent of dmg return to attacker REFLECT_DAMAGE_MELEE, // 39 REFLECT_DAMAGE_MAGIC, // 40 // chance to poison enemy, poisoned enemy will loss 10% of the current health POISON, // 41 // reduce chance get any of uniq statuses RESIST_TO_STATUSES, // 42 END_SLOT // 43 } // possible // HEAL_FACTOR struct CoreAttributes { int32 strength; int32 dexterity; int32 vitality; int32 energy; } struct ChangeableStats { uint32 level; uint32 experience; uint32 life; uint32 mana; uint32 lifeChances; } enum ItemSlots { UNKNOWN, // 0 HEAD, // 1 BODY, // 2 GLOVES, // 3 BELT, // 4 AMULET, // 5 BOOTS, // 6 RIGHT_RING, // 7 LEFT_RING, // 8 RIGHT_HAND, // 9 LEFT_HAND, // 10 TWO_HAND, // 11 SKILL_1, // 12 SKILL_2, // 13 SKILL_3, // 14 END_SLOT // 15 } struct NftItem { address token; uint tokenId; } enum Race { UNKNOWN, // 0 HUMAN, // 1 UNDEAD, // 2 DAEMON, // 3 BEAST, // 4 END_SLOT // 5 } struct ChangeAttributesInfo { address heroToken; uint heroTokenId; int32[] changeAttributes; bool add; bool temporally; } struct BuffInfo { address heroToken; uint heroTokenId; uint32 heroLevel; address[] buffTokens; uint[] buffTokenIds; } /// @dev This struct is used inside event, so it's moved here from lib struct ActionInternalInfo { int32[] posAttributes; int32[] negAttributes; uint32 experience; int32 heal; int32 manaRegen; int32 lifeChancesRecovered; int32 damage; int32 manaConsumed; address[] mintedItems; } function initNewHero(address token, uint tokenId, uint heroClass) external; function heroAttributes(address token, uint tokenId) external view returns (int32[] memory); function heroAttribute(address token, uint tokenId, uint index) external view returns (int32); function heroAttributesLength(address token, uint tokenId) external view returns (uint); function heroBaseAttributes(address token, uint tokenId) external view returns (CoreAttributes memory); function heroCustomData(address token, uint tokenId, bytes32 index) external view returns (uint); function globalCustomData(bytes32 index) external view returns (uint); function heroStats(address token, uint tokenId) external view returns (ChangeableStats memory); function heroItemSlot(address token, uint64 tokenId, uint8 itemSlot) external view returns (bytes32 nftPacked); function heroItemSlots(address heroToken, uint heroTokenId) external view returns (uint8[] memory); function isHeroAlive(address heroToken, uint heroTokenId) external view returns (bool); function levelUp(address token, uint tokenId, uint heroClass, CoreAttributes memory change) external returns (uint newLvl); function changeHeroItemSlot( address heroToken, uint64 heroTokenId, uint itemType, uint8 itemSlot, address itemToken, uint itemTokenId, bool equip ) external; function changeCurrentStats( address token, uint tokenId, ChangeableStats memory change, bool increase ) external; function changeBonusAttributes(ChangeAttributesInfo memory info) external; function registerConsumableUsage(address heroToken, uint heroTokenId, address item) external; function clearUsedConsumables(address heroToken, uint heroTokenId) external; function clearTemporallyAttributes(address heroToken, uint heroTokenId) external; function buffHero(BuffInfo memory info) external view returns (int32[] memory attributes, int32 manaConsumed); function setHeroCustomData(address token, uint tokenId, bytes32 index, uint value) external; function setGlobalCustomData(bytes32 index, uint value) external; /// @notice Restore life and mana during reinforcement /// @dev Life and mana will be increased on ((current life/mana attr value) - (prev life/mana attr value)) /// @param prevAttributes Hero attributes before reinforcement function restoreLifeAndMana(address heroToken, uint heroTokenId, int32[] memory prevAttributes) external; function reborn(address heroToken, uint heroTokenId, uint heroClass) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.23; import "../interfaces/IGOC.sol"; import "../interfaces/IStatController.sol"; import "../interfaces/IItemController.sol"; import "./IController.sol"; import "./IOracle.sol"; import "./IHeroController.sol"; import "../openzeppelin/EnumerableSet.sol"; interface IStoryController { enum AnswerResultId { UNKNOWN, // 0 SUCCESS, // 1 ATTRIBUTE_FAIL, // 2 RANDOM_FAIL, // 3 DELAY_FAIL, // 4 HERO_CUSTOM_DATA_FAIL, // 5 GLOBAL_CUSTOM_DATA_FAIL, // 6 END_SLOT } enum CustomDataResult { UNKNOWN, // 0 HERO_SUCCESS, // 1 HERO_FAIL, // 2 GLOBAL_SUCCESS, // 3 GLOBAL_FAIL, // 4 END_SLOT } /// @custom:storage-location erc7201:story.controller.main struct MainState { // --- STORY REG INFO --- /// @dev Uniq story identification. mapping(uint32 => uint16) storyIds; /// @dev Revers mapping for stories for using in the next object rewrite logic. mapping(uint16 => uint32) idToStory; /// @dev Store used ids for stories. mapping(uint16 => bool) _usedStoryIds; /// @dev Prevent register the story twice mapping(uint32 => bool) registeredStories; // --- ANSWER MAPPING --- /// @dev storyId => all story pages. We need to have this mapping for properly remove meta info mapping(uint16 => EnumerableSet.UintSet) allStoryPages; /// @dev storyId => all possible answers. We need to have this mapping for properly remove meta info mapping(uint16 => EnumerableSet.Bytes32Set) allStoryAnswers; /// @dev storyId + pageId + heroClass (zero is default answers) => storyId + pageId + heroClass (zero is default answers) + answerId mapping(bytes32 => bytes32[]) answers; /// @dev answerUnPackedId + answerResultId => nextPageIds (will be chosen randomly from this array) /// where answerResultId is: /// 0 - unknown, /// 1 - success, /// 2 - attr fail /// 3 - random fail /// 4 - delay fail /// 5 - hero custom data fail /// 6 - global custom data fail /// see COUNT_ANSWER_RESULT_IDS mapping(bytes32 => uint16[]) nextPageIds; /// @dev story + pageId + heroClass (zero is default answers) => random nextObjs (adr + id, like packed nft id) mapping(bytes32 => uint32[]) nextObjectsRewrite; /// @dev answerPackedId => packed array of uint32[] /// 0 - random requirement(uint32, 1 - 99% success of this action, zero means no check) /// 1 - delay requirement(uint32, if time since the last call more than this value the check is fail, zero means no check) /// 2 - isFinalAnswer(uint8) mapping(bytes32 => bytes32) answerAttributes; // --- ANSWER REQUIREMENTS --- /// @dev answerPackedId => array of AttributeRequirementsPacked mapping(bytes32 => bytes32[]) attributeRequirements; /// @dev answerPackedId=> array of ItemRequirementsPacked mapping(bytes32 => bytes32[]) itemRequirements; /// @dev answerPackedId => array of TokenRequirementsPacked mapping(bytes32 => bytes32[]) tokenRequirements; /// @dev answerPackedId => custom data for hero mapping(bytes32 => CustomDataRequirementPacked[]) heroCustomDataRequirement; /// @dev answerPackedId => global custom data mapping(bytes32 => CustomDataRequirementPacked[]) globalCustomDataRequirement; // --- ANSWER RESULTS --- /// @dev answerPackedId => change attributes mapping(bytes32 => bytes32[]) successInfoAttributes; /// @dev answerPackedId => change stats mapping(bytes32 => bytes32) successInfoStats; /// @dev answerPackedId => mint items mapping(bytes32 => bytes32[]) successInfoMintItems; /// @dev answerPackedId => change attributes mapping(bytes32 => bytes32[]) failInfoAttributes; /// @dev answerPackedId => change stats mapping(bytes32 => bytes32) failInfoStats; /// @dev answerPackedId => mint items mapping(bytes32 => bytes32[]) failInfoMintItems; /// @dev answerUnPackedId + CustomDataResult => custom data array change /// where CustomDataResult is /// 1 - hero success /// 2 - hero fail /// 3 - global success /// 4 - global fail /// see COUNT_CUSTOM_DATA_RESULT_IDS mapping(bytes32 => bytes32[]) customDataResult; /// @notice answerPackedId => slot+chance+stopIfBurnt /// @dev Since SIP-003 the items are not burn but broke mapping(bytes32 => bytes32[]) burnItem; // --- GENERAL STORY REQUIREMENTS --- /// @dev story => Custom hero data requirements for a story. If exist and hero is not eligible should be not chose in a dungeon. mapping(uint => CustomDataRequirementRangePacked[]) storyRequiredHeroData; /// @dev story => Minimal level for the history. 0 means no requirements. mapping(uint => uint) storyRequiredLevel; // --- HERO STATES --- /// @dev hero + heroId + storyId => pageId + heroLastActionTS mapping(bytes32 => bytes32) heroState; // --- OTHER --- /// @dev storyId => build hash for the last update mapping(uint16 => uint) storyBuildHash; /// @notice Number of already minted items by the user within the given iteration of the story. /// Only minting of the given number of items is allowed per iteration (see MAX_MINTED_ITEMS_PER_ITERATION). /// @dev hero, heroId, story => mintedInIteration /// This map is not cleared: storyId:objectId is 1:1, each object has own sequence of iterations without duplicates mapping(bytes32 => mapping(uint iteration => uint countMintedItems)) mintedInIteration; } /// @dev We need to have flat structure coz Solidity can not handle arrays of structs properly struct StoryMetaInfo { uint16 storyId; // --- story reqs bytes32[] requiredCustomDataIndex; uint64[] requiredCustomDataMinValue; uint64[] requiredCustomDataMaxValue; bool[] requiredCustomDataIsHero; uint minLevel; // --- answer reqs AnswersMeta answersMeta; AnswerNextPageMeta answerNextPage; AnswerAttributeRequirementsMeta answerAttributeRequirements; AnswerItemRequirementsMeta answerItemRequirements; AnswerTokenRequirementsMeta answerTokenRequirements; AnswerAttributesMeta answerAttributes; AnswerCustomDataMeta answerHeroCustomDataRequirement; AnswerCustomDataMeta answerGlobalCustomDataRequirement; // --- answer results AnswerBurnRandomItemMeta answerBurnRandomItemMeta; NextObjRewriteMeta nextObjRewriteMeta; // --- story results AnswerResultMeta successInfo; AnswerResultMeta failInfo; AnswerCustomDataResultMeta successHeroCustomData; AnswerCustomDataResultMeta failHeroCustomData; AnswerCustomDataResultMeta successGlobalCustomData; AnswerCustomDataResultMeta failGlobalCustomData; } struct NextObjRewriteMeta { uint16[] nextObjPageIds; uint8[] nextObjHeroClasses; uint32[][] nextObjIds; } struct AnswersMeta { uint16[] answerPageIds; uint8[] answerHeroClasses; uint16[] answerIds; } struct AnswerNextPageMeta { uint16[] pageId; uint8[] heroClass; uint16[] answerId; uint8[] answerResultIds; uint16[][] answerNextPageIds; } struct AnswerAttributeRequirementsMeta { uint16[] pageId; uint8[] heroClass; uint16[] answerId; bool[][] cores; uint8[][] ids; int32[][] values; } struct AnswerItemRequirementsMeta { uint16[] pageId; uint8[] heroClass; uint16[] answerId; address[][] requireItems; bool[][] requireItemBurn; bool[][] requireItemEquipped; } struct AnswerTokenRequirementsMeta { uint16[] pageId; uint8[] heroClass; uint16[] answerId; address[][] requireToken; uint88[][] requireAmount; bool[][] requireTransfer; } struct AnswerAttributesMeta { uint16[] pageId; uint8[] heroClass; uint16[] answerId; uint32[] randomRequirements; uint32[] delayRequirements; bool[] isFinalAnswer; } struct AnswerCustomDataMeta { uint16[] pageId; uint8[] heroClass; uint16[] answerId; bytes32[][] dataIndexes; bool[][] mandatory; uint64[][] dataValuesMin; uint64[][] dataValuesMax; } struct AnswerResultMeta { uint16[] pageId; uint8[] heroClass; uint16[] answerId; uint8[][] attributeIds; /// @dev Max value is limitied by int24, see toBytes32ArrayWithIds impl int32[][] attributeValues; uint32[] experience; int32[] heal; int32[] manaRegen; int32[] lifeChancesRecovered; int32[] damage; int32[] manaConsumed; address[][] mintItems; uint32[][] mintItemsChances; } struct AnswerCustomDataResultMeta { uint16[] pageId; uint8[] heroClass; uint16[] answerId; bytes32[][] dataIndexes; int16[][] dataValues; } struct AnswerBurnRandomItemMeta { uint16[] pageId; uint8[] heroClass; uint16[] answerId; /// @notice 0 - random slot uint8[][] slots; /// @notice typical chances are [0..100] (no decimals here) uint64[][] chances; /// @notice Since SIP-003 the burning is replaced by breaking bu the name is kept as is bool[][] isStopIfBurnt; } struct CustomDataRequirementPacked { bytes32 index; /// @dev min(uint64) + max(uint64) + mandatory(uint8) bytes32 data; } struct CustomDataRequirementRangePacked { bytes32 index; /// @dev min(uint64) + max(uint64) + isHeroData(uint8) bytes32 data; } struct StatsChange { uint32 experience; int32 heal; int32 manaRegen; int32 lifeChancesRecovered; int32 damage; int32 manaConsumed; } struct StoryActionContext { uint stageId; uint iteration; bytes32 answerIdHash; bytes32 answerAttributes; address sender; address heroToken; IController controller; IStatController statController; IHeroController heroController; IOracle oracle; IItemController itemController; uint8 heroClass; uint8 heroClassFromAnswerHash; uint8 biome; uint16 storyId; uint16 storyIdFromAnswerHash; uint16 pageIdFromAnswerHash; uint16 answerNumber; uint16 pageId; uint32 objectId; uint64 dungeonId; uint40 heroLastActionTS; uint80 heroTokenId; IStatController.ChangeableStats heroStats; } // --- WRITE --- function storyAction( address sender, uint64 dungeonId, uint32 objectId, uint stageId, address heroToken, uint heroTokenId, uint8 biome, uint iteration, bytes memory data ) external returns (IGOC.ActionResult memory); // --- READ --- function isStoryAvailableForHero(uint32 objectId, address heroToken, uint heroTokenId) external view returns (bool); function idToStory(uint16 id) external view returns (uint32 objectId); function heroPage(address hero, uint80 heroId, uint16 storyId) external view returns (uint16 pageId); function storyIds(uint32 objectId) external view returns (uint16); function registeredStories(uint32 objectId) external view returns (bool); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.23; import "../interfaces/IItemController.sol"; import "../interfaces/IStatController.sol"; import "../interfaces/IAppErrors.sol"; library PackingLib { ////////////////////////// // ---- PACKING LOGIC ---- ////////////////////////// //region ------------------------------------ COMMON function packNftId(address token, uint id) internal pure returns (bytes32 serialized) { if (id > uint(type(uint64).max)) revert IAppErrors.TooHighValue(id); serialized = bytes32(uint(uint160(token))); serialized |= bytes32(uint(uint64(id))) << 160; } function unpackNftId(bytes32 data) internal pure returns (address token, uint id) { token = address(uint160(uint(data))); id = uint(data) >> 160; } function packAddressWithAmount(address token, uint amount) internal pure returns (bytes32 data) { if (amount > uint(type(uint96).max)) revert IAppErrors.TooHighValue(amount); data = bytes32(uint(uint160(token))); data |= bytes32(uint(uint96(amount))) << 160; } function unpackAddressWithAmount(bytes32 data) internal pure returns (address token, uint amount) { token = address(uint160(uint(data))); amount = uint(data) >> 160; } function packItemMintInfo(address item, uint32 chance) internal pure returns (bytes32 data) { data = bytes32(uint(uint160(item))); data |= bytes32(uint(chance)) << 160; } function unpackItemMintInfo(bytes32 data) internal pure returns (address item, uint32 chance) { item = address(uint160(uint(data))); chance = uint32(uint(data) >> 160); } /// @param customDataIndex We assume, that two lowest bytes of this string are always zero /// So, the string looks like following: 0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX0000 /// Last 2 bytes will be used to encode {value} function packCustomDataChange(bytes32 customDataIndex, int16 value) internal pure returns (bytes32 data) { if (uint(customDataIndex) != (uint(customDataIndex) >> 16) << 16) revert IAppErrors.IncompatibleInputString(); data = bytes32(uint(customDataIndex)); data |= bytes32(uint(uint16(value))); } function unpackCustomDataChange(bytes32 data) internal pure returns (bytes32 customDataIndex, int16 value) { customDataIndex = bytes32((uint(data) >> 16) << 16); value = int16(int(uint(uint16(uint(data))))); } /// @dev min(uint64) + max(uint64) + isHeroData/isMandatory(uint8) function packCustomDataRequirements(uint64 min, uint64 max, bool key) internal pure returns (bytes32 data) { data = bytes32(uint(min)); data |= bytes32(uint(max)) << 64; data |= bytes32(uint(key ? uint8(1) : uint8(0))) << (64 + 64); } function unpackCustomDataRequirements(bytes32 data) internal pure returns (uint64 min, uint64 max, bool key) { min = uint64(uint(data)); max = uint64(uint(data) >> 64); key = uint8(uint(data) >> (64 + 64)) == uint8(1); } function packStatsChange( uint32 experience, int32 heal, int32 manaRegen, int32 lifeChancesRecovered, int32 damage, int32 manaConsumed ) internal pure returns (bytes32 data) { data = bytes32(uint(experience)); data |= bytes32(uint(uint32(heal))) << 32; data |= bytes32(uint(uint32(manaRegen))) << (32 + 32); data |= bytes32(uint(uint32(lifeChancesRecovered))) << (32 + 32 + 32); data |= bytes32(uint(uint32(damage))) << (32 + 32 + 32 + 32); data |= bytes32(uint(uint32(manaConsumed))) << (32 + 32 + 32 + 32 + 32); } function unpackStatsChange(bytes32 data) internal pure returns ( uint32 experience, int32 heal, int32 manaRegen, int32 lifeChancesRecovered, int32 damage, int32 manaConsumed ) { experience = uint32(uint(data)); heal = int32(int(uint(data) >> 32)); manaRegen = int32(int(uint(data) >> (32 + 32))); lifeChancesRecovered = int32(int(uint(data) >> (32 + 32 + 32))); damage = int32(int(uint(data) >> (32 + 32 + 32 + 32))); manaConsumed = int32(int(uint(data) >> (32 + 32 + 32 + 32 + 32))); } function packNftIdWithValue(address token, uint id, uint32 value) internal pure returns (bytes32 serialized) { if (id > uint(type(uint64).max)) revert IAppErrors.TooHighValue(id); serialized = bytes32(uint(uint160(token))); serialized |= bytes32(uint(uint64(id))) << 160; serialized |= bytes32(uint(value)) << 160 + 64; } function unpackNftIdWithValue(bytes32 data) internal pure returns (address token, uint id, uint32 value) { token = address(uint160(uint(data))); id = uint64(uint(data) >> 160); value = uint32(uint(data) >> 160 + 64); } //endregion ------------------------------------ COMMON //region ------------------------------------ WORLD/BATTLEFIELD MAP function packMapObject(address objectAddress, uint64 objectId, uint8 objectType) internal pure returns (bytes32 packedData) { packedData = bytes32(bytes20(objectAddress)); packedData |= bytes32(uint(objectId) << 32); packedData |= bytes32(uint(objectType) << 24); } function unpackMapObject(bytes32 packedData) internal pure returns (address objectAddress, uint64 objectId, uint8 objectType) { objectAddress = address(bytes20(packedData)); objectId = uint64(uint(packedData) >> 32); objectType = uint8(uint(packedData) >> 24); } function packCoordinate(uint128 x, uint128 y) internal pure returns (bytes32 packedData) { packedData = bytes32(uint(x)); packedData |= bytes32(uint(y) << 128); } function unpackCoordinate(bytes32 packedData) internal pure returns (uint128 x, uint128 y) { x = uint128(uint(packedData)); y = uint128(uint(packedData) >> 128); } /// @param x Assume x <= max uint64 /// @param y Assume y <= max uint64 function packBattlefieldId(uint8 biomeMapFieldId, uint8 territoryNumber, uint128 x, uint128 y) internal pure returns (bytes32 packedData) { // 256 => 128 + 128; // 1) 128 is used for biomeMapFieldId, territoryNumber and probably other fields in the future // 2) 128 is used to store x, y as uint64, uint64 // we will use uint64 for coordinates assuming it is more than enough for biome map packedData = bytes32(uint(biomeMapFieldId)); packedData |= bytes32(uint(territoryNumber) << (8)); packedData |= bytes32(uint(uint64(x)) << 128); packedData |= bytes32(uint(uint64(y)) << (64 + 128)); } function unpackBattlefieldId(bytes32 packedData) internal pure returns (uint8 biomeMapFieldId, uint8 territoryNumber, uint128 x, uint128 y) { biomeMapFieldId = uint8(uint(packedData)); territoryNumber = uint8(uint(packedData) >> (8)); x = uint128(uint64(uint(packedData) >> (128))); y = uint128(uint64(uint(packedData) >> (64 + 128))); } //endregion ------------------------------------ WORLD/BATTLEFIELD MAP //region ------------------------------------ REINFORCEMENT function packReinforcementHeroInfo(uint8 biome, uint128 score, uint8 fee, uint64 stakeTs) internal pure returns (bytes32 packedData) { packedData = bytes32(uint(biome)); packedData |= bytes32(uint(score) << 8); packedData |= bytes32(uint(fee) << (8 + 128)); packedData |= bytes32(uint(stakeTs) << (8 + 128 + 8)); } function unpackReinforcementHeroInfo(bytes32 packedData) internal pure returns (uint8 biome, uint128 score, uint8 fee, uint64 stakeTs) { biome = uint8(uint(packedData)); score = uint128(uint(packedData) >> 8); fee = uint8(uint(packedData) >> (8 + 128)); stakeTs = uint64(uint(packedData) >> (8 + 128 + 8)); } function packConfigReinforcementV2(uint32 min, uint32 max, uint32 lowDivider, uint32 highDivider, uint8 levelLimit) internal pure returns (bytes32 packedData) { packedData = bytes32(uint(min)); packedData |= bytes32(uint(max) << 32); packedData |= bytes32(uint(lowDivider) << 64); packedData |= bytes32(uint(highDivider) << 96); packedData |= bytes32(uint(levelLimit) << 128); } function unpackConfigReinforcementV2(bytes32 packedData) internal pure returns (uint32 min, uint32 max, uint32 lowDivider, uint32 highDivider, uint8 levelLimit) { min = uint32(uint(packedData)); max = uint32(uint(packedData) >> 32); lowDivider = uint32(uint(packedData) >> 64); highDivider = uint32(uint(packedData) >> 96); levelLimit = uint8(uint(packedData) >> 128); } //endregion ------------------------------------ REINFORCEMENT //region ------------------------------------ DUNGEON function packDungeonKey(address heroAdr, uint80 heroId, uint16 dungLogicNum) internal pure returns (bytes32 data) { data = bytes32(uint(uint160(heroAdr))); data |= bytes32(uint(heroId)) << 160; data |= bytes32(uint(dungLogicNum)) << (160 + 80); } function unpackDungeonKey(bytes32 data) internal pure returns (address heroAdr, uint80 heroId, uint16 dungLogicNum) { heroAdr = address(uint160(uint(data))); heroId = uint80(uint(data) >> 160); dungLogicNum = uint16(uint(data) >> (160 + 80)); } // --- GAME OBJECTS --- function packIterationKey(address heroAdr, uint64 heroId, uint32 objId) internal pure returns (bytes32 data) { data = bytes32(uint(uint160(heroAdr))); data |= bytes32(uint(heroId)) << 160; data |= bytes32(uint(objId)) << (160 + 64); } function unpackIterationKey(bytes32 data) internal pure returns (address heroAdr, uint64 heroId, uint32 objId) { heroAdr = address(uint160(uint(data))); heroId = uint64(uint(data) >> 160); objId = uint32(uint(data) >> (160 + 64)); } function packMonsterStats( uint8 level, uint8 race, uint32 experience, uint8 maxDropItems ) internal pure returns (bytes32 data) { data = bytes32(uint(level)); data |= bytes32(uint(race)) << 8; data |= bytes32(uint(experience)) << (8 + 8); data |= bytes32(uint(maxDropItems)) << (8 + 8 + 32); } function unpackMonsterStats(bytes32 data) internal pure returns ( uint8 level, uint8 race, uint32 experience, uint8 maxDropItems ) { level = uint8(uint(data)); race = uint8(uint(data) >> 8); experience = uint32(uint(data) >> (8 + 8)); maxDropItems = uint8(uint(data) >> (8 + 8 + 32)); } function packAttackInfo( address attackToken, uint64 attackTokenId, uint8 attackType ) internal pure returns (bytes32 data) { data = bytes32(uint(uint160(attackToken))); data |= bytes32(uint(attackTokenId)) << 160; data |= bytes32(uint(attackType)) << (160 + 64); } function unpackAttackInfo(bytes32 data) internal pure returns ( address attackToken, uint64 attackTokenId, uint8 attackType ) { attackToken = address(uint160(uint(data))); attackTokenId = uint64(uint(data) >> 160); attackType = uint8(uint(data) >> (160 + 64)); } function packPlayedObjKey(address heroAdr, uint64 heroId, uint8 oType, uint8 biome) internal pure returns (bytes32 data) { data = bytes32(uint(uint160(heroAdr))); data |= bytes32(uint(heroId)) << 160; data |= bytes32(uint(oType)) << (160 + 64); data |= bytes32(uint(biome)) << (160 + 64 + 8); } function unpackPlayedObjKey(bytes32 data) internal pure returns (address heroAdr, uint64 heroId, uint8 oType, uint8 biome) { heroAdr = address(uint160(uint(data))); heroId = uint64(uint(data) >> 160); oType = uint8(uint(data) >> (160 + 64)); biome = uint8(uint(data) >> (160 + 64 + 8)); } function packGeneratedMonster(bool generated, uint32 amplifier, int32 hp, uint8 turnCounter) internal pure returns (bytes32 data) { data = bytes32(uint(uint8(generated ? 1 : 0))); data |= bytes32(uint(amplifier)) << 8; data |= bytes32(uint(uint32(hp))) << (8 + 32); data |= bytes32(uint(turnCounter)) << (8 + 32 + 32); } function unpackGeneratedMonster(bytes32 data) internal pure returns (bool generated, uint32 amplifier, int32 hp, uint8 turnCounter) { generated = uint8(uint(data)) == uint8(1); amplifier = uint32(uint(data) >> 8); hp = int32(int(uint(data) >> (8 + 32))); turnCounter = uint8(uint(data) >> (8 + 32 + 32)); } //endregion ------------------------------------ DUNGEON //region ------------------------------------ ITEMS /// @notice itemMetaType8 + itemLvl8 + itemType8 + baseDurability16 + defaultRarity8 + minAttr8 + maxAttr8 + manaCost32 + req(packed core 128) /// @param itemType This is ItemType enum function packItemMeta( uint8 itemMetaType, uint8 itemLvl, uint8 itemType, uint16 baseDurability, uint8 defaultRarity, uint8 minAttr, uint8 maxAttr, uint32 manaCost, IStatController.CoreAttributes memory req ) internal pure returns (bytes32 data) { data = bytes32(uint(itemMetaType)); data |= bytes32(uint(itemLvl)) << 8; data |= bytes32(uint(itemType)) << (8 + 8); data |= bytes32(uint(baseDurability)) << (8 + 8 + 8); data |= bytes32(uint(defaultRarity)) << (8 + 8 + 8 + 16); data |= bytes32(uint(minAttr)) << (8 + 8 + 8 + 16 + 8); data |= bytes32(uint(maxAttr)) << (8 + 8 + 8 + 16 + 8 + 8); data |= bytes32(uint(manaCost)) << (8 + 8 + 8 + 16 + 8 + 8 + 8); data |= bytes32(uint(int(req.strength))) << (8 + 8 + 8 + 16 + 8 + 8 + 8 + 32); data |= bytes32(uint(int(req.dexterity))) << (8 + 8 + 8 + 16 + 8 + 8 + 8 + 32 + 32); data |= bytes32(uint(int(req.vitality))) << (8 + 8 + 8 + 16 + 8 + 8 + 8 + 32 + 32 + 32); data |= bytes32(uint(int(req.energy))) << (8 + 8 + 8 + 16 + 8 + 8 + 8 + 32 + 32 + 32 + 32); } function unpackItemMeta(bytes32 data) internal pure returns (IItemController.ItemMeta memory) { IItemController.ItemMeta memory result; result.itemMetaType = uint8(uint(data)); result.itemLevel = uint8(uint(data) >> 8); result.itemType = IItemController.ItemType(uint8(uint(data) >> (8 + 8))); result.baseDurability = uint16(uint(data) >> (8 + 8 + 8)); result.defaultRarity = uint8(uint(data) >> (8 + 8 + 8 + 16)); result.minRandomAttributes = uint8(uint(data) >> (8 + 8 + 8 + 16 + 8)); result.maxRandomAttributes = uint8(uint(data) >> (8 + 8 + 8 + 16 + 8 + 8)); result.manaCost = uint32(uint(data) >> (8 + 8 + 8 + 16 + 8 + 8 + 8)); result.requirements.strength = int32(int(uint(data) >> (8 + 8 + 8 + 16 + 8 + 8 + 8 + 32))); result.requirements.dexterity = int32(int(uint(data) >> (8 + 8 + 8 + 16 + 8 + 8 + 8 + 32 + 32))); result.requirements.vitality = int32(int(uint(data) >> (8 + 8 + 8 + 16 + 8 + 8 + 8 + 32 + 32 + 32))); result.requirements.energy = int32(int(uint(data) >> (8 + 8 + 8 + 16 + 8 + 8 + 8 + 32 + 32 + 32 + 32))); return result; } function packItemGenerateInfo(uint8 id, int32 min, int32 max, uint32 chance) internal pure returns (bytes32 data) { data = bytes32(uint(id)); data |= bytes32(uint(uint32(min))) << 8; data |= bytes32(uint(uint32(max))) << (8 + 32); data |= bytes32(uint(chance)) << (8 + 32 + 32); } function unpackItemGenerateInfo(bytes32 data) internal pure returns (uint8 id, int32 min, int32 max, uint32 chance) { id = uint8(uint(data)); min = int32(int(uint(data) >> 8)); max = int32(int(uint(data) >> (8 + 32))); chance = uint32(uint(data) >> (8 + 32 + 32)); } function packItemAttackInfo( uint8 attackType, int32 min, int32 max, int32 factorStr, int32 factorDex, int32 factorVit, int32 factorEng ) internal pure returns (bytes32 data) { data = bytes32(uint(attackType)); data |= bytes32(uint(uint32(min))) << 8; data |= bytes32(uint(uint32(max))) << (8 + 32); data |= bytes32(uint(int(factorStr))) << (8 + 32 + 32); data |= bytes32(uint(int(factorDex))) << (8 + 32 + 32 + 32); data |= bytes32(uint(int(factorVit))) << (8 + 32 + 32 + 32 + 32); data |= bytes32(uint(int(factorEng))) << (8 + 32 + 32 + 32 + 32 + 32); } function unpackItemAttackInfo(bytes32 data) internal pure returns ( uint8 attackType, int32 min, int32 max, int32 factorStr, int32 factorDex, int32 factorVit, int32 factorEng ) { attackType = uint8(uint(data)); min = int32(int(uint(data) >> 8)); max = int32(int(uint(data) >> (8 + 32))); factorStr = int32(int(uint(data) >> (8 + 32 + 32))); factorDex = int32(int(uint(data) >> (8 + 32 + 32 + 32))); factorVit = int32(int(uint(data) >> (8 + 32 + 32 + 32 + 32))); factorEng = int32(int(uint(data) >> (8 + 32 + 32 + 32 + 32 + 32))); } function packItemInfo(uint8 rarity, uint8 augmentationLevel, uint16 durability) internal pure returns (bytes32 data) { data = bytes32(uint(rarity)); data |= bytes32(uint(augmentationLevel)) << 8; data |= bytes32(uint(durability)) << (8 + 8); } function unpackItemInfo(bytes32 data) internal pure returns (uint8 rarity, uint8 augmentationLevel, uint16 durability) { rarity = uint8(uint(data)); augmentationLevel = uint8(uint(data) >> 8); durability = uint16(uint(data) >> (8 + 8)); } //endregion ------------------------------------ ITEMS //region ------------------------------------ STORIES function packStoryPageId(uint16 storyId, uint16 pageId, uint8 heroClass) internal pure returns (bytes32 data) { data = bytes32(uint(storyId)); data |= bytes32(uint(pageId)) << 16; data |= bytes32(uint(heroClass)) << (16 + 16); } function unpackStoryPageId(bytes32 data) internal pure returns (uint16 storyId, uint16 pageId, uint8 heroClass) { storyId = uint16(uint(data)); pageId = uint16(uint(data) >> 16); heroClass = uint8(uint(data) >> (16 + 16)); } function packStoryAnswerId(uint16 storyId, uint16 pageId, uint8 heroClass, uint16 answerId) internal pure returns (bytes32 data) { data = bytes32(uint(storyId)); data |= bytes32(uint(pageId)) << 16; data |= bytes32(uint(heroClass)) << (16 + 16); data |= bytes32(uint(answerId)) << (16 + 16 + 8); } function unpackStoryAnswerId(bytes32 data) internal pure returns (uint16 storyId, uint16 pageId, uint8 heroClass, uint16 answerId) { storyId = uint16(uint(data)); pageId = uint16(uint(data) >> 16); heroClass = uint8(uint(data) >> (16 + 16)); answerId = uint16(uint(data) >> (16 + 16 + 8)); } function packStoryNextPagesId(uint16 storyId, uint16 pageId, uint8 heroClass, uint16 answerId, uint8 resultId) internal pure returns (bytes32 data) { data = bytes32(uint(storyId)); data |= bytes32(uint(pageId)) << 16; data |= bytes32(uint(heroClass)) << (16 + 16); data |= bytes32(uint(answerId)) << (16 + 16 + 8); data |= bytes32(uint(resultId)) << (16 + 16 + 8 + 16); } function unpackStoryNextPagesId(bytes32 data) internal pure returns (uint16 storyId, uint16 pageId, uint8 heroClass, uint16 answerId, uint8 resultId) { storyId = uint16(uint(data)); pageId = uint16(uint(data) >> 16); heroClass = uint8(uint(data) >> (16 + 16)); answerId = uint16(uint(data) >> (16 + 16 + 8)); resultId = uint8(uint(data) >> (16 + 16 + 8 + 16)); } function packStoryAttributeRequirement(uint8 attributeIndex, int32 value, bool isCore) internal pure returns (bytes32 data) { data = bytes32(uint(attributeIndex)); data |= bytes32(uint(uint32(value))) << 8; data |= bytes32(uint(isCore ? uint8(1) : uint8(0))) << (8 + 32); } function unpackStoryAttributeRequirement(bytes32 data) internal pure returns (uint8 attributeIndex, int32 value, bool isCore) { attributeIndex = uint8(uint(data)); value = int32(int(uint(data) >> 8)); isCore = uint8(uint(data) >> (8 + 32)) == uint8(1); } function packStoryItemRequirement(address item, bool requireItemBurn, bool requireItemEquipped) internal pure returns (bytes32 data) { data = bytes32(uint(uint160(item))); data |= bytes32(uint(requireItemBurn ? uint8(1) : uint8(0))) << 160; data |= bytes32(uint(requireItemEquipped ? uint8(1) : uint8(0))) << (160 + 8); } function unpackStoryItemRequirement(bytes32 data) internal pure returns (address item, bool requireItemBurn, bool requireItemEquipped) { item = address(uint160(uint(data))); requireItemBurn = uint8(uint(data) >> 160) == uint8(1); requireItemEquipped = uint8(uint(data) >> (160 + 8)) == uint8(1); } /// @dev max amount is 309,485,009 for token with 18 decimals function packStoryTokenRequirement(address token, uint88 amount, bool requireTransfer) internal pure returns (bytes32 data) { data = bytes32(uint(uint160(token))); data |= bytes32(uint(amount)) << 160; data |= bytes32(uint(requireTransfer ? uint8(1) : uint8(0))) << (160 + 88); } function unpackStoryTokenRequirement(bytes32 data) internal pure returns (address token, uint88 amount, bool requireTransfer) { token = address(uint160(uint(data))); amount = uint88(uint(data) >> 160); requireTransfer = uint8(uint(data) >> (160 + 88)) == uint8(1); } function packStoryCustomDataResult(uint16 storyId, uint16 pageId, uint8 heroClass, uint16 answerId, uint8 customDataResultId) internal pure returns (bytes32 data) { data = bytes32(uint(storyId)); data |= bytes32(uint(pageId)) << 16; data |= bytes32(uint(heroClass)) << (16 + 16); data |= bytes32(uint(answerId)) << (16 + 16 + 8); data |= bytes32(uint(customDataResultId)) << (16 + 16 + 8 + 16); } function unpackStoryCustomDataResult(bytes32 data) internal pure returns (uint16 storyId, uint16 pageId, uint8 heroClass, uint16 answerId, uint8 customDataResultId) { storyId = uint16(uint(data)); pageId = uint16(uint(data) >> 16); heroClass = uint8(uint(data) >> (16 + 16)); answerId = uint16(uint(data) >> (16 + 16 + 8)); customDataResultId = uint8(uint(data) >> (16 + 16 + 8 + 16)); } function packStoryHeroState(uint16 pageId, uint40 heroLastActionTS) internal pure returns (bytes32 data) { data = bytes32(uint(pageId)); data |= bytes32(uint(heroLastActionTS)) << 16; } function unpackStoryHeroState(bytes32 data) internal pure returns (uint16 pageId, uint40 heroLastActionTS) { pageId = uint16(uint(data)); heroLastActionTS = uint40(uint(data) >> 16); } function packStoryHeroStateId(address heroAdr, uint80 heroId, uint16 storyId) internal pure returns (bytes32 data) { data = bytes32(uint(uint160(heroAdr))); data |= bytes32(uint(heroId)) << 160; data |= bytes32(uint(storyId)) << (160 + 80); } function unpackStoryHeroStateId(bytes32 data) internal pure returns (address heroAdr, uint80 heroId, uint16 storyId) { heroAdr = address(uint160(uint(data))); heroId = uint80(uint(data) >> 160); storyId = uint16(uint(data) >> (160 + 80)); } function packStorySimpleRequirement(uint32 randomRequirement, uint32 delayRequirement, bool isFinalAnswer) internal pure returns (bytes32 data) { data = bytes32(uint(randomRequirement)); data |= bytes32(uint(delayRequirement)) << 32; data |= bytes32(uint(isFinalAnswer ? uint8(1) : uint8(0))) << (32 + 32); } function unpackStorySimpleRequirement(bytes32 data) internal pure returns (uint32 randomRequirement, uint32 delayRequirement, bool isFinalAnswer) { randomRequirement = uint32(uint(data)); delayRequirement = uint32(uint(data) >> 32); isFinalAnswer = uint8(uint(data) >> (32 + 32)) == uint8(1); } function packBreakInfo(uint8 slot, uint64 chance, bool stopIfBroken) internal pure returns (bytes32 data) { data = bytes32(uint(slot)); data |= bytes32(uint(chance)) << 8; data |= bytes32(uint(stopIfBroken ? uint8(1) : uint8(0))) << (8 + 64); } function unpackBreakInfo(bytes32 data) internal pure returns (uint8 slot, uint64 chance, bool stopIfBurned) { slot = uint8(uint(data)); chance = uint64(uint(data) >> 8); stopIfBurned = uint8(uint(data) >> (8 + 64)) == uint8(1); } //endregion ------------------------------------ STORIES //region ------------------------------------ Hero controller function packTierHero(uint8 tier, address hero) internal pure returns (bytes32 packedTierHero) { packedTierHero = bytes32(uint(tier)); packedTierHero |= bytes32(uint(uint160(hero)) << 8); } function unpackTierHero(bytes32 packedTierHero) internal pure returns (uint8 tier, address hero) { tier = uint8(uint(packedTierHero)); hero = address(uint160(uint(packedTierHero) >> 8)); } //endregion ------------------------------------ Hero controller //////////////////////////////////////////////////////////////////////////////////// // ---- ARRAYS LOGIC ---- //////////////////////////////////////////////////////////////////////////////////// //region ------------------------------------ SIMPLE ARRAYS function packUint8Array(uint8[] memory data) internal pure returns (bytes32) { uint len = data.length; if (len > 32) revert IAppErrors.OutOfBounds(len, 32); bytes32 result; for (uint i = 0; i < len; i++) { result |= bytes32(uint(data[i])) << (i * 8); } return result; } /// @notice Simple faster version of {packUint8Array} for small number of items /// It allows to exclude dynamic array creation. function packUint8Array3(uint8 a, uint8 b, uint8 c) internal pure returns (bytes32) { bytes32 result = bytes32(uint(a)); result |= bytes32(uint(b)) << (1 * 8); result |= bytes32(uint(c)) << (2 * 8); return result; } function unpackUint8Array(bytes32 data) internal pure returns (uint8[] memory) { uint8[] memory result = new uint8[](32); for (uint i = 0; i < 32; i++) { result[i] = uint8(uint(data) >> (i * 8)); } return result; } /// @notice Simple faster version of {unpackUint8Array} for small number of items /// It allows to exclude only first 3 values function unpackUint8Array3(bytes32 data) internal pure returns (uint8 a, uint8 b, uint8 c) { a = uint8(uint(data)); b = uint8(uint(data) >> (1 * 8)); c = uint8(uint(data) >> (2 * 8)); } function changeUnit8ArrayWithCheck(bytes32 data, uint index, uint8 value, uint8 expectedPrevValue) internal pure returns (bytes32 newData) { uint8[] memory arr = unpackUint8Array(data); if (arr[index] != expectedPrevValue) revert IAppErrors.UnexpectedValue(uint(expectedPrevValue), uint(arr[index])); arr[index] = value; return packUint8Array(arr); } function packInt32Array(int32[] memory data) internal pure returns (bytes32) { uint len = data.length; if (len > 8) revert IAppErrors.OutOfBounds(len, 8); bytes32 result; for (uint i; i < len; i++) { result |= bytes32(uint(uint32(data[i]))) << (i * 32); } return result; } function unpackInt32Array(bytes32 data) internal pure returns (int32[] memory) { int32[] memory result = new int32[](8); for (uint i = 0; i < 8; i++) { result[i] = int32(int(uint(data) >> (i * 32))); } return result; } function packUint32Array(uint32[] memory data) internal pure returns (bytes32) { uint len = data.length; if (len > 8) revert IAppErrors.OutOfBounds(len, 8); bytes32 result; for (uint i = 0; i < len; i++) { result |= bytes32(uint(data[i])) << (i * 32); } return result; } function unpackUint32Array(bytes32 data) internal pure returns (uint32[] memory) { uint32[] memory result = new uint32[](8); for (uint i = 0; i < 8; i++) { result[i] = uint32(uint(data) >> (i * 32)); } return result; } //endregion ------------------------------------ SIMPLE ARRAYS //region ------------------------------------ COMPLEX ARRAYS // We should represent arrays without concrete size. // For this reason we must not revert IAppErrors.on out of bounds but return zero value instead. // we need it for properly unpack packed arrays with ids // function getInt32AsInt24(bytes32[] memory arr, uint idx) internal pure returns (int32) { // if (idx / 8 >= arr.length) { // return int32(0); // } // return int32(int24(int(uint(arr[idx / 8]) >> ((idx % 8) * 32)))); // } // we need it for properly unpack packed arrays with ids // function getUnit8From32Step(bytes32[] memory arr, uint idx) internal pure returns (uint8) { // if (idx / 8 >= arr.length) { // return uint8(0); // } // return uint8(uint(arr[idx / 8]) >> ((idx % 8) * 32 + 24)); // } function getInt32Memory(bytes32[] memory arr, uint idx) internal pure returns (int32) { if (idx / 8 >= arr.length) { return int32(0); } return int32(int(uint(arr[idx / 8]) >> ((idx % 8) * 32))); } function getInt32(bytes32[] storage arr, uint idx) internal view returns (int32) { // additional gas usage, but we should not revert IAppErrors.on out of bounds if (idx / 8 >= arr.length) { return int32(0); } return int32(int(uint(arr[idx / 8]) >> ((idx % 8) * 32))); } function setInt32(bytes32[] storage arr, uint idx, int32 value) internal { uint pos = idx / 8; uint shift = (idx % 8) * 32; uint curLength = arr.length; if (pos >= curLength) { arr.push(0); for (uint i = curLength; i < pos; ++i) { arr.push(0); } } arr[pos] = bytes32(uint(arr[pos]) & ~(uint(0xffffffff) << shift) | (uint(uint32(value)) & 0xffffffff) << shift); } /// @notice Increment {idx}-th item on {value} function changeInt32(bytes32[] storage arr, uint idx, int32 value) internal returns (int32 newValue, int32 change) { int32 cur = int32(int(getInt32(arr, idx))); int newValueI = int(cur) + int(value); newValue = int32(newValueI); change = int32(newValueI - int(cur)); setInt32(arr, idx, newValue); } function toInt32Array(bytes32[] memory arr, uint size) internal pure returns (int32[] memory) { int32[] memory result = new int32[](size); for (uint i = 0; i < arr.length; i++) { for (uint j; j < 8; ++j) { uint idx = i * 8 + j; if (idx >= size) break; result[idx] = getInt32Memory(arr, idx); } } return result; } /// @dev pack int32 array into bytes32 array function toBytes32Array(int32[] memory arr) internal pure returns (bytes32[] memory) { uint size = arr.length / 8 + 1; bytes32[] memory result = new bytes32[](size); for (uint i; i < size; ++i) { for (uint j; j < 8; ++j) { uint idx = i * 8 + j; if (idx >= arr.length) break; result[i] |= bytes32(uint(uint32(arr[idx]))) << (j * 32); } } return result; } /// @dev pack int32 array into bytes32 array using last 8bytes for ids /// we can not use zero values coz will not able to properly unpack it later function toBytes32ArrayWithIds(int32[] memory arr, uint8[] memory ids) internal pure returns (bytes32[] memory) { if (arr.length != ids.length) revert IAppErrors.LengthsMismatch(); uint size = arr.length / 8 + 1; bytes32[] memory result = new bytes32[](size); for (uint i; i < size; ++i) { for (uint j; j < 8; ++j) { uint idx = i * 8 + j; if (idx >= arr.length) break; if (arr[idx] > type(int24).max || arr[idx] < type(int24).min) revert IAppErrors.IntOutOfRange(int(arr[idx])); if (arr[idx] == 0) revert IAppErrors.ZeroValue(); result[i] |= bytes32(uint(uint24(int24(arr[idx])))) << (j * 32); result[i] |= bytes32(uint(ids[idx])) << (j * 32 + 24); } } return result; } /// @dev we do not know exact size of array, assume zero values is not acceptable for this array function toInt32ArrayWithIds(bytes32[] memory arr) internal pure returns (int32[] memory values, uint8[] memory ids) { uint len = arr.length; uint size = len * 8; int32[] memory valuesTmp = new int32[](size); uint8[] memory idsTmp = new uint8[](size); uint counter; for (uint i = 0; i < len; i++) { for (uint j; j < 8; ++j) { uint idx = i * 8 + j; // if (idx >= size) break; // it looks like a useless check valuesTmp[idx] = int32(int24(int(uint(arr[i]) >> (j * 32)))); // getInt32AsInt24(arr, idx); idsTmp[idx] = uint8(uint(arr[i]) >> (j * 32 + 24)); // getUnit8From32Step(arr, idx); if (valuesTmp[idx] == 0) { break; } counter++; } } values = new int32[](counter); ids = new uint8[](counter); for (uint i; i < counter; ++i) { values[i] = valuesTmp[i]; ids[i] = idsTmp[i]; } } //endregion ------------------------------------ COMPLEX ARRAYS //region ------------------------------------ Guilds /// @dev ShelterID is uint. But in the code we assume that this ID can be stored as uint64 (see auctions) /// @param biome 1, 2, 3... /// @param shelterLevel 1, 2 or 3. /// @param shelterIndex 0, 1, 2 ... function packShelterId(uint8 biome, uint8 shelterLevel, uint8 shelterIndex) internal pure returns (uint) { return uint(biome) | (uint(shelterLevel) << 8) | (uint(shelterIndex) << 16); } function unpackShelterId(uint shelterId) internal pure returns (uint8 biome, uint8 shelterLevel, uint8 shelterIndex) { return (uint8(shelterId), uint8(shelterId >> 8), uint8(shelterId >> 16)); } //endregion ------------------------------------ Guilds //region ------------------------------------ Metadata of IItemController.OtherSubtypeKind function getOtherItemTypeKind(bytes memory packedData) internal pure returns (IItemController.OtherSubtypeKind) { bytes32 serialized; assembly { serialized := mload(add(packedData, 32)) } uint8 kind = uint8(uint(serialized)); if (kind == 0 || kind >= uint8(IItemController.OtherSubtypeKind.END_SLOT)) revert IAppErrors.IncorrectOtherItemTypeKind(kind); return IItemController.OtherSubtypeKind(kind); } function packOtherItemReduceFragility(uint value) internal pure returns (bytes memory packedData) { bytes32 serialized = bytes32(uint(uint8(IItemController.OtherSubtypeKind.REDUCE_FRAGILITY_1))); serialized |= bytes32(uint(uint248(value))) << 8; return bytes.concat(serialized); } function unpackOtherItemReduceFragility(bytes memory packedData) internal pure returns (uint) { bytes32 serialized; assembly { serialized := mload(add(packedData, 32)) } uint8 kind = uint8(uint(serialized)); if (kind != uint8(IItemController.OtherSubtypeKind.REDUCE_FRAGILITY_1)) revert IAppErrors.IncorrectOtherItemTypeKind(kind); uint value = uint248(uint(serialized) >> 8); return value; } //endregion ------------------------------------ Metadata of IItemController.OtherSubtypeKind }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.23; import "../interfaces/IERC20.sol"; import "../interfaces/IAppErrors.sol"; import "../interfaces/IApplicationEvents.sol"; import "../interfaces/IController.sol"; import "../interfaces/IGuildController.sol"; import "../interfaces/IShelterAuction.sol"; import "../interfaces/IShelterController.sol"; import "../openzeppelin/EnumerableSet.sol"; library ShelterAuctionLib { using EnumerableSet for EnumerableSet.UintSet; //region ------------------------ Constants /// @dev keccak256(abi.encode(uint256(keccak256("shelter.auction.main")) - 1)) & ~bytes32(uint256(0xff)) bytes32 internal constant SHELTER_AUCTION_MAIN_STORAGE_LOCATION = 0x597e4e55fd306bfc6bfaaa6b3e10d80a4b0fe770b166ac704f10504e76e97c00; // shelter.auction.main uint internal constant AUCTION_DURATION = 1 days; uint internal constant FEE_DENOMINATOR = 100_000; uint internal constant DEFAULT_FEE = 100; uint internal constant MAX_FEE = 50_000; /// @notice Min allowed amount of next bid is {prev amount} * {NEXT_AMOUNT_RATIO} / 100 uint internal constant NEXT_AMOUNT_RATIO = 110; //endregion ------------------------ Constants //region ------------------------ Storage function _S() internal pure returns (IShelterAuction.MainState storage s) { assembly { s.slot := SHELTER_AUCTION_MAIN_STORAGE_LOCATION } return s; } //endregion ------------------------ Storage //region ------------------------ Restrictions function _onlyNotPaused(IController controller) internal view { if (controller.onPause()) revert IAppErrors.ErrorPaused(); } function _onlyDeployer(IController controller) internal view { if (!controller.isDeployer(msg.sender)) revert IAppErrors.ErrorNotDeployer(msg.sender); } //endregion ------------------------ Restrictions //region ------------------------ View function getBid(uint bidId_) internal view returns (IShelterAuction.AuctionBid memory) { return _S().auctionBids[bidId_]; } function getPosition(uint positionId_) internal view returns (IShelterAuction.Position memory) { return _S().positions[positionId_]; } function positionBySeller(uint sellerGuildId_) internal view returns (uint positionId) { return _S().sellerPosition[sellerGuildId_]; } function posByShelter(IController controller, uint shelterId_) internal view returns (uint positionId) { IGuildController guildController = IGuildController(controller.guildController()); address shelterController = guildController.shelterController(); return shelterController == address(0) ? 0 : positionBySeller(IShelterController(shelterController).shelterToGuild(shelterId_)); } function positionByBuyer(uint buyerGuildId) internal view returns (IShelterAuction.BuyerPositionData memory) { return _S().buyerPosition[buyerGuildId]; } function openPositionsLength() internal view returns (uint) { return _S().openPositions.length(); } function openPositionByIndex(uint index) internal view returns (uint positionId) { return _S().openPositions.at(index); } function lastAuctionBidTs(uint positionId) internal view returns (uint timestamp) { return _S().lastAuctionBidTs[positionId]; } function positionBidsLength(uint positionId) internal view returns (uint) { return _S().positionToBidIds[positionId].length; } function positionBidByIndex(uint positionId, uint bidIndex) internal view returns (uint) { return _S().positionToBidIds[positionId][bidIndex]; } function positionCounter() internal view returns (uint) { return _S().params[IShelterAuction.ShelterAuctionParams.POSITION_COUNTER_1]; } function bidCounter() internal view returns (uint) { return _S().params[IShelterAuction.ShelterAuctionParams.BID_COUNTER_2]; } function fee() internal view returns (uint) { return _S().params[IShelterAuction.ShelterAuctionParams.FEE_3]; } function nextAmount(uint positionId) internal view returns (uint) { uint[] storage bidIds = _S().positionToBidIds[positionId]; uint length = bidIds.length; if (length == 0) { return _S().positions[positionId].minAuctionPrice; } else { IShelterAuction.AuctionBid storage lastBid = _S().auctionBids[bidIds[length - 1]]; return lastBid.amount * NEXT_AMOUNT_RATIO / 100; } } function auctionEndTs(uint positionId, uint auctionDuration) internal view returns (uint timestamp) { uint lastBidTimestamp = _S().lastAuctionBidTs[positionId]; return lastBidTimestamp == 0 ? 0 : lastBidTimestamp + auctionDuration; } //endregion ------------------------ View //region ------------------------ Actions /// @notice Seller action. Open new position, setup min allowed auction price. function openPosition(IController controller, address msgSender, uint shelterId, uint minAuctionPrice) internal returns (uint) { _onlyNotPaused(controller); if (minAuctionPrice == 0) revert IAppErrors.ZeroValueNotAllowed(); IGuildController guildController = IGuildController(controller.guildController()); (uint sellerGuildId, ) = _checkPermissions(msgSender, guildController, IGuildController.GuildRightBits.CHANGE_SHELTER_3); uint existPositionId = _S().sellerPosition[sellerGuildId]; if (existPositionId != 0) revert IAppErrors.AuctionPositionOpened(existPositionId); if (guildController.guildToShelter(sellerGuildId) != shelterId) revert IAppErrors.ShelterIsNotOwnedByTheGuild(); if (shelterId == 0) revert IAppErrors.ZeroValueNotAllowed(); uint positionId = _generateId(IShelterAuction.ShelterAuctionParams.POSITION_COUNTER_1); _S().openPositions.add(positionId); _S().positions[positionId] = IShelterAuction.Position({ positionId: uint128(positionId), shelterId: uint64(shelterId), open: true, sellerGuildId: uint128(sellerGuildId), seller: msgSender, minAuctionPrice: uint128(minAuctionPrice) }); _S().sellerPosition[sellerGuildId] = positionId; emit IApplicationEvents.AuctionPositionOpened(positionId, shelterId, sellerGuildId, msgSender, minAuctionPrice); return positionId; } /// @notice Seller action. Close not executed position. function closePosition(IController controller, address msgSender, uint positionId, uint auctionDuration, uint blockTimestamp) internal { _onlyNotPaused(controller); // Any member of the seller-guild can close position if he has enough permission. // On the contrary, original position creator is NOT able to close position if he has not rights anymore IGuildController guildController = IGuildController(controller.guildController()); (uint sellerGuildId, ) = _checkPermissions(msgSender, guildController, IGuildController.GuildRightBits.CHANGE_SHELTER_3); IShelterAuction.Position storage pos = _S().positions[positionId]; if (pos.positionId != positionId) revert IAppErrors.WrongAuctionPosition(); if (pos.sellerGuildId != sellerGuildId) revert IAppErrors.AuctionSellerOnly(); if (!pos.open) revert IAppErrors.AuctionPositionClosed(); uint lastBidTimestamp = _S().lastAuctionBidTs[positionId]; if (lastBidTimestamp != 0 && lastBidTimestamp + auctionDuration < blockTimestamp) revert IAppErrors.AuctionEnded(); _S().openPositions.remove(positionId); delete _S().sellerPosition[sellerGuildId]; pos.open = false; emit IApplicationEvents.AuctionPositionClosed(positionId, msgSender); } /// @notice Buyer action. Create new bid with amount higher than the amount of previously registered bid. /// Assume approve for bid-amount function bid( IController controller, address msgSender, uint positionId, uint amount, uint auctionDuration, uint blockTimestamp ) internal { _onlyNotPaused(controller); IGuildController guildController = IGuildController(controller.guildController()); (uint buyerGuildId, ) = _checkPermissions(msgSender, guildController, IGuildController.GuildRightBits.CHANGE_SHELTER_3); IShelterAuction.Position storage pos = _S().positions[positionId]; if (pos.positionId != positionId) revert IAppErrors.WrongAuctionPosition(); if (!pos.open) revert IAppErrors.AuctionPositionClosed(); if (pos.sellerGuildId == buyerGuildId) revert IAppErrors.AuctionSellerCannotBid(); IShelterAuction.BuyerPositionData storage buyerPos = _S().buyerPosition[buyerGuildId]; if (buyerPos.positionId != 0) revert IAppErrors.AuctionBidOpened(buyerPos.positionId); uint[] storage bidIds = _S().positionToBidIds[positionId]; // assume here that shelterController cannot be 0 (it's useless to use ShelterAuction otherwise) if (0 != IShelterController(guildController.shelterController()).guildToShelter(buyerGuildId)) revert IAppErrors.AuctionGuildWithShelterCannotBid(); // open auction bid uint length = bidIds.length; if (length == 0) { if (amount < pos.minAuctionPrice) revert IAppErrors.TooLowAmountToBid(); } else { if (_S().lastAuctionBidTs[positionId] + auctionDuration < blockTimestamp) revert IAppErrors.AuctionEnded(); IShelterAuction.AuctionBid storage lastBid = _S().auctionBids[bidIds[length - 1]]; if (lastBid.amount * NEXT_AMOUNT_RATIO / 100 > amount) revert IAppErrors.TooLowAmountForNewBid(); } IShelterAuction.AuctionBid memory newBid = IShelterAuction.AuctionBid({ bidId: uint128(_generateId(IShelterAuction.ShelterAuctionParams.BID_COUNTER_2)), amount: uint128(amount), positionId: uint128(positionId), open: true, buyer: msgSender, buyerGuildId: uint128(buyerGuildId) }); bidIds.push(newBid.bidId); _S().auctionBids[newBid.bidId] = newBid; _S().buyerPosition[buyerGuildId] = IShelterAuction.BuyerPositionData({ positionId: uint128(positionId), bidIndex: uint128(length) }); _S().lastAuctionBidTs[positionId] = blockTimestamp; // get amount from buyer guild bank on the balance of this contract guildController.payForAuctionBid(buyerGuildId, amount, newBid.bidId); emit IApplicationEvents.AuctionBidOpened(newBid.bidId, positionId, amount, msgSender); } /// @notice Apply winner-bid by seller or by buyer. Assume that auction ended. /// Transfer winner-bid-amount to the seller. Transfer shelter from seller to the buyer. CLose the position. function applyAuctionBid(IController controller, address msgSender, uint bidId, uint auctionDuration, uint blockTimestamp) internal { _onlyNotPaused(controller); IGuildController guildController = IGuildController(controller.guildController()); (uint guildId, ) = _checkPermissions(msgSender, guildController, IGuildController.GuildRightBits.CHANGE_SHELTER_3); IShelterAuction.AuctionBid storage _bid = _S().auctionBids[bidId]; uint positionId = _bid.positionId; if (positionId == 0) revert IAppErrors.AuctionBidNotFound(); if (!_bid.open) revert IAppErrors.AuctionBidClosed(); IShelterAuction.Position storage pos = _S().positions[positionId]; if (!pos.open) revert IAppErrors.AuctionPositionClosed(); if (_S().lastAuctionBidTs[positionId] + auctionDuration >= blockTimestamp) revert IAppErrors.AuctionNotEnded(); { uint[] storage bidIds = _S().positionToBidIds[positionId]; if (bidIds[bidIds.length - 1] != bidId) revert IAppErrors.CannotApplyNotLastBid(); } uint sellerGuildId = pos.sellerGuildId; { uint buyerGuildId = _bid.buyerGuildId; if (guildId != sellerGuildId && guildId != buyerGuildId) revert IAppErrors.ErrorNotAllowedSender(); // close the bid, close the position pos.open = false; _bid.open = false; _S().openPositions.remove(positionId); delete _S().sellerPosition[sellerGuildId]; delete _S().buyerPosition[buyerGuildId]; // move shelter from the seller to the buyer IShelterController shelterController = IShelterController(guildController.shelterController()); shelterController.changeShelterOwner(pos.shelterId, buyerGuildId); } // transfer amount to balance of guild bank of the seller, transfer fee to controller address gameToken = controller.gameToken(); uint amount = _bid.amount; uint toGov = amount * fee() / FEE_DENOMINATOR; if (toGov != 0) { IERC20(gameToken).transfer(address(controller), toGov); } address sellerGuildBank = guildController.getGuildBank(sellerGuildId); IERC20(gameToken).transfer(sellerGuildBank, amount - toGov); } /// @notice Buyer action. Allow to close not last bid at any time. /// Last (active) bid can be closed only if position is closed by the seller. /// Close auction bid and transfer bid-amount back to the buyer. function closeAuctionBid(IController controller, address msgSender, uint bidId) internal { _onlyNotPaused(controller); IGuildController guildController = IGuildController(controller.guildController()); (uint guildId, ) = _checkPermissions(msgSender, guildController, IGuildController.GuildRightBits.CHANGE_SHELTER_3); IShelterAuction.AuctionBid storage _bid = _S().auctionBids[bidId]; uint positionId = _bid.positionId; if (positionId == 0) revert IAppErrors.AuctionBidNotFound(); if (_bid.buyerGuildId != guildId) revert IAppErrors.AuctionBuyerOnly(); if (!_bid.open) revert IAppErrors.AuctionBidClosed(); uint[] storage bidIds = _S().positionToBidIds[positionId]; bool lastBid = bidIds[bidIds.length - 1] == bidId; // close the bid IShelterAuction.Position storage pos = _S().positions[positionId]; if (lastBid && pos.open) revert IAppErrors.CannotCloseLastBid(); _bid.open = false; delete _S().buyerPosition[guildId]; // return full amount back to the buyer address buyerGuildBank = guildController.getGuildBank(guildId); address gameToken = controller.gameToken(); IERC20(gameToken).transfer(buyerGuildBank, _bid.amount); } //endregion ------------------------ Actions //region ------------------------ Deployer actions function setFee(IController controller, uint fee_) internal { _onlyDeployer(controller); if (fee_ > MAX_FEE) revert IAppErrors.TooHighValue(fee_); _S().params[IShelterAuction.ShelterAuctionParams.FEE_3] = fee_; } //endregion ------------------------ Deployer actions //region ------------------------ Internal logic /// @notice Generate id, increment id-counter /// @dev uint is used to store id. In the code we assume that it's safe to use uint128 to store such ids function _generateId(IShelterAuction.ShelterAuctionParams paramId) internal returns (uint uid) { uid = _S().params[paramId] + 1; _S().params[paramId] = uid; } /// @notice Check if the {user} has given permission in the guild. Permissions are specified by bitmask {rights}. /// Admin is marked by zero bit, he has all permissions always. function _checkPermissions(address user, IGuildController guildController, IGuildController.GuildRightBits right) internal view returns (uint guildId, uint rights) { guildId = guildController.memberOf(user); if (guildId == 0) revert IAppErrors.NotGuildMember(); rights = guildController.getRights(user); if (!( (rights & (2**uint(IGuildController.GuildRightBits.ADMIN_0))) != 0 || (rights & (2**uint(right))) != 0 )) { revert IAppErrors.GuildActionForbidden(uint(right)); } } //endregion ------------------------ Internal logic }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.23; /// @title Library for setting / getting slot variables (used in upgradable proxy contracts) /// @author bogdoslav library SlotsLib { /// @notice Version of the contract /// @dev Should be incremented when contract changed string public constant SLOT_LIB_VERSION = "1.0.0"; // ************* GETTERS ******************* /// @dev Gets a slot as bytes32 function getBytes32(bytes32 slot) internal view returns (bytes32 result) { assembly { result := sload(slot) } } /// @dev Gets a slot as an address function getAddress(bytes32 slot) internal view returns (address result) { assembly { result := sload(slot) } } /// @dev Gets a slot as uint256 function getUint(bytes32 slot) internal view returns (uint result) { assembly { result := sload(slot) } } // ************* ARRAY GETTERS ******************* /// @dev Gets an array length function arrayLength(bytes32 slot) internal view returns (uint result) { assembly { result := sload(slot) } } /// @dev Gets a slot array by index as address /// @notice First slot is array length, elements ordered backward in memory /// @notice This is unsafe, without checking array length. function addressAt(bytes32 slot, uint index) internal view returns (address result) { bytes32 pointer = bytes32(uint(slot) - 1 - index); assembly { result := sload(pointer) } } // ************* SETTERS ******************* /// @dev Sets a slot with bytes32 /// @notice Check address for 0 at the setter function set(bytes32 slot, bytes32 value) internal { assembly { sstore(slot, value) } } /// @dev Sets a slot with address /// @notice Check address for 0 at the setter function set(bytes32 slot, address value) internal { assembly { sstore(slot, value) } } /// @dev Sets a slot with uint function set(bytes32 slot, uint value) internal { assembly { sstore(slot, value) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableMap.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableMap.js. pragma solidity ^0.8.20; import {EnumerableSet} from "./EnumerableSet.sol"; /** * @dev Library for managing an enumerable variant of Solidity's * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`] * type. * * Maps have the following properties: * * - Entries are added, removed, and checked for existence in constant time * (O(1)). * - Entries are enumerated in O(n). No guarantees are made on the ordering. * * ```solidity * contract Example { * // Add the library methods * using EnumerableMap for EnumerableMap.UintToAddressMap; * * // Declare a set state variable * EnumerableMap.UintToAddressMap private myMap; * } * ``` * * The following map types are supported: * * - `uint256 -> address` (`UintToAddressMap`) since v3.0.0 * - `address -> uint256` (`AddressToUintMap`) since v4.6.0 * - `bytes32 -> bytes32` (`Bytes32ToBytes32Map`) since v4.6.0 * - `uint256 -> uint256` (`UintToUintMap`) since v4.7.0 * - `bytes32 -> uint256` (`Bytes32ToUintMap`) since v4.7.0 * * [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 EnumerableMap, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableMap. * ==== */ library EnumerableMap { using EnumerableSet for EnumerableSet.Bytes32Set; // To implement this library for multiple types with as little code repetition as possible, we write it in // terms of a generic Map type with bytes32 keys and values. The Map implementation uses private functions, // and user-facing implementations such as `UintToAddressMap` are just wrappers around the underlying Map. // This means that we can only create new EnumerableMaps for types that fit in bytes32. /** * @dev Query for a nonexistent map key. */ error EnumerableMapNonexistentKey(bytes32 key); struct Bytes32ToBytes32Map { // Storage of keys EnumerableSet.Bytes32Set _keys; mapping(bytes32 key => bytes32) _values; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(Bytes32ToBytes32Map storage map, bytes32 key, bytes32 value) internal returns (bool) { map._values[key] = value; return map._keys.add(key); } /** * @dev Removes a key-value pair from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(Bytes32ToBytes32Map storage map, bytes32 key) internal returns (bool) { delete map._values[key]; return map._keys.remove(key); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool) { return map._keys.contains(key); } /** * @dev Returns the number of key-value pairs in the map. O(1). */ function length(Bytes32ToBytes32Map storage map) internal view returns (uint256) { return map._keys.length(); } /** * @dev Returns the key-value pair stored at position `index` in the map. O(1). * * Note that there are no guarantees on the ordering of entries inside the * array, and it may change when more entries are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32ToBytes32Map storage map, uint256 index) internal view returns (bytes32, bytes32) { bytes32 key = map._keys.at(index); return (key, map._values[key]); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function tryGet(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool, bytes32) { bytes32 value = map._values[key]; if (value == bytes32(0)) { return (contains(map, key), bytes32(0)); } else { return (true, value); } } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bytes32) { bytes32 value = map._values[key]; if (value == 0 && !contains(map, key)) { revert EnumerableMapNonexistentKey(key); } return value; } /** * @dev Return the an array containing all the keys * * 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 map grows to a point where copying to memory consumes too much gas to fit in a block. */ function keys(Bytes32ToBytes32Map storage map) internal view returns (bytes32[] memory) { return map._keys.values(); } // UintToUintMap struct UintToUintMap { Bytes32ToBytes32Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(UintToUintMap storage map, uint256 key, uint256 value) internal returns (bool) { return set(map._inner, bytes32(key), bytes32(value)); } /** * @dev Removes a value from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(UintToUintMap storage map, uint256 key) internal returns (bool) { return remove(map._inner, bytes32(key)); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(UintToUintMap storage map, uint256 key) internal view returns (bool) { return contains(map._inner, bytes32(key)); } /** * @dev Returns the number of elements in the map. O(1). */ function length(UintToUintMap storage map) internal view returns (uint256) { return length(map._inner); } /** * @dev Returns the element stored at position `index` in the map. 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(UintToUintMap storage map, uint256 index) internal view returns (uint256, uint256) { (bytes32 key, bytes32 value) = at(map._inner, index); return (uint256(key), uint256(value)); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function tryGet(UintToUintMap storage map, uint256 key) internal view returns (bool, uint256) { (bool success, bytes32 value) = tryGet(map._inner, bytes32(key)); return (success, uint256(value)); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(UintToUintMap storage map, uint256 key) internal view returns (uint256) { return uint256(get(map._inner, bytes32(key))); } /** * @dev Return the an array containing all the keys * * 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 map grows to a point where copying to memory consumes too much gas to fit in a block. */ function keys(UintToUintMap storage map) internal view returns (uint256[] memory) { bytes32[] memory store = keys(map._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintToAddressMap struct UintToAddressMap { Bytes32ToBytes32Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) { return set(map._inner, bytes32(key), bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) { return remove(map._inner, bytes32(key)); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) { return contains(map._inner, bytes32(key)); } /** * @dev Returns the number of elements in the map. O(1). */ function length(UintToAddressMap storage map) internal view returns (uint256) { return length(map._inner); } /** * @dev Returns the element stored at position `index` in the map. 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(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) { (bytes32 key, bytes32 value) = at(map._inner, index); return (uint256(key), address(uint160(uint256(value)))); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) { (bool success, bytes32 value) = tryGet(map._inner, bytes32(key)); return (success, address(uint160(uint256(value)))); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(UintToAddressMap storage map, uint256 key) internal view returns (address) { return address(uint160(uint256(get(map._inner, bytes32(key))))); } /** * @dev Return the an array containing all the keys * * 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 map grows to a point where copying to memory consumes too much gas to fit in a block. */ function keys(UintToAddressMap storage map) internal view returns (uint256[] memory) { bytes32[] memory store = keys(map._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // AddressToUintMap struct AddressToUintMap { Bytes32ToBytes32Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(AddressToUintMap storage map, address key, uint256 value) internal returns (bool) { return set(map._inner, bytes32(uint256(uint160(key))), bytes32(value)); } /** * @dev Removes a value from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(AddressToUintMap storage map, address key) internal returns (bool) { return remove(map._inner, bytes32(uint256(uint160(key)))); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(AddressToUintMap storage map, address key) internal view returns (bool) { return contains(map._inner, bytes32(uint256(uint160(key)))); } /** * @dev Returns the number of elements in the map. O(1). */ function length(AddressToUintMap storage map) internal view returns (uint256) { return length(map._inner); } /** * @dev Returns the element stored at position `index` in the map. 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(AddressToUintMap storage map, uint256 index) internal view returns (address, uint256) { (bytes32 key, bytes32 value) = at(map._inner, index); return (address(uint160(uint256(key))), uint256(value)); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function tryGet(AddressToUintMap storage map, address key) internal view returns (bool, uint256) { (bool success, bytes32 value) = tryGet(map._inner, bytes32(uint256(uint160(key)))); return (success, uint256(value)); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(AddressToUintMap storage map, address key) internal view returns (uint256) { return uint256(get(map._inner, bytes32(uint256(uint160(key))))); } /** * @dev Return the an array containing all the keys * * 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 map grows to a point where copying to memory consumes too much gas to fit in a block. */ function keys(AddressToUintMap storage map) internal view returns (address[] memory) { bytes32[] memory store = keys(map._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // Bytes32ToUintMap struct Bytes32ToUintMap { Bytes32ToBytes32Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(Bytes32ToUintMap storage map, bytes32 key, uint256 value) internal returns (bool) { return set(map._inner, key, bytes32(value)); } /** * @dev Removes a value from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(Bytes32ToUintMap storage map, bytes32 key) internal returns (bool) { return remove(map._inner, key); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(Bytes32ToUintMap storage map, bytes32 key) internal view returns (bool) { return contains(map._inner, key); } /** * @dev Returns the number of elements in the map. O(1). */ function length(Bytes32ToUintMap storage map) internal view returns (uint256) { return length(map._inner); } /** * @dev Returns the element stored at position `index` in the map. 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(Bytes32ToUintMap storage map, uint256 index) internal view returns (bytes32, uint256) { (bytes32 key, bytes32 value) = at(map._inner, index); return (key, uint256(value)); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function tryGet(Bytes32ToUintMap storage map, bytes32 key) internal view returns (bool, uint256) { (bool success, bytes32 value) = tryGet(map._inner, key); return (success, uint256(value)); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(Bytes32ToUintMap storage map, bytes32 key) internal view returns (uint256) { return uint256(get(map._inner, key)); } /** * @dev Return the an array containing all the keys * * 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 map grows to a point where copying to memory consumes too much gas to fit in a block. */ function keys(Bytes32ToUintMap storage map) internal view returns (bytes32[] memory) { bytes32[] memory store = keys(map._inner); bytes32[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
// 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) (proxy/utils/Initializable.sol) pragma solidity ^0.8.20; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Storage of the initializable contract. * * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions * when using with upgradeable contracts. * * @custom:storage-location erc7201:openzeppelin.storage.Initializable */ struct InitializableStorage { /** * @dev Indicates that the contract has been initialized. */ uint64 _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool _initializing; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00; /** * @dev The contract is already initialized. */ error InvalidInitialization(); /** * @dev The contract is not initializing. */ error NotInitializing(); /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint64 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in * production. * * Emits an {Initialized} event. */ modifier initializer() { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); // Cache values to avoid duplicated sloads bool isTopLevelCall = !$._initializing; uint64 initialized = $._initialized; // Allowed calls: // - initialSetup: the contract is not in the initializing state and no previous version was // initialized // - construction: the contract is initialized at version 1 (no reininitialization) and the // current contract is just being deployed bool initialSetup = initialized == 0 && isTopLevelCall; bool construction = initialized == 1 && address(this).code.length == 0; if (!initialSetup && !construction) { revert InvalidInitialization(); } $._initialized = 1; if (isTopLevelCall) { $._initializing = true; } _; if (isTopLevelCall) { $._initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint64 version) { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing || $._initialized >= version) { revert InvalidInitialization(); } $._initialized = version; $._initializing = true; _; $._initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { _checkInitializing(); _; } /** * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}. */ function _checkInitializing() internal view virtual { if (!_isInitializing()) { revert NotInitializing(); } } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing) { revert InvalidInitialization(); } if ($._initialized != type(uint64).max) { $._initialized = type(uint64).max; emit Initialized(type(uint64).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint64) { return _getInitializableStorage()._initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _getInitializableStorage()._initializing; } /** * @dev Returns a pointer to the storage namespace. */ // solhint-disable-next-line var-name-mixedcase function _getInitializableStorage() private pure returns (InitializableStorage storage $) { assembly { $.slot := INITIALIZABLE_STORAGE } } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.23; import "../openzeppelin/Initializable.sol"; import "../interfaces/IControllable.sol"; import "../interfaces/IController.sol"; import "../lib/SlotsLib.sol"; /// @title Implement basic functionality for any contract that require strict control /// @dev Can be used with upgradeable pattern. /// Require call __Controllable_init() in any case. /// @author belbix abstract contract Controllable is Initializable, IControllable { using SlotsLib for bytes32; /// @notice Version of the contract /// @dev Should be incremented when contract changed string public constant CONTROLLABLE_VERSION = "1.0.0"; bytes32 internal constant _CONTROLLER_SLOT = bytes32(uint256(keccak256("eip1967.controllable.controller")) - 1); bytes32 internal constant _CREATED_SLOT = bytes32(uint256(keccak256("eip1967.controllable.created")) - 1); bytes32 internal constant _CREATED_BLOCK_SLOT = bytes32(uint256(keccak256("eip1967.controllable.created_block")) - 1); bytes32 internal constant _REVISION_SLOT = bytes32(uint256(keccak256("eip1967.controllable.revision")) - 1); bytes32 internal constant _PREVIOUS_LOGIC_SLOT = bytes32(uint256(keccak256("eip1967.controllable.prev_logic")) - 1); event ContractInitialized(address controller, uint ts, uint block); event RevisionIncreased(uint value, address oldLogic); // init implementation contract constructor() initializer {} /// @notice Initialize contract after setup it as proxy implementation /// Save block.timestamp in the "created" variable /// @dev Use it only once after first logic setup /// @param controller_ Controller address function __Controllable_init(address controller_) internal onlyInitializing { _init(controller_); } function _init(address controller_) private { require(controller_ != address(0), "Zero controller"); _CONTROLLER_SLOT.set(controller_); _CREATED_SLOT.set(block.timestamp); _CREATED_BLOCK_SLOT.set(block.number); emit ContractInitialized(controller_, block.timestamp, block.number); } /// @dev Return true if given address is controller function isController(address value_) public override view returns (bool) { return value_ == controller(); } /// @notice Return true if given address is setup as governance in Controller function isGovernance(address value_) public override view returns (bool) { return IController(controller()).governance() == value_; } /// @dev Contract upgrade counter function revision() external view override returns (uint) { return _REVISION_SLOT.getUint(); } /// @dev Previous logic implementation function previousImplementation() external view override returns (address) { return _PREVIOUS_LOGIC_SLOT.getAddress(); } // ************* SETTERS/GETTERS ******************* /// @notice Return controller address saved in the contract slot function controller() public view override returns (address) { return _CONTROLLER_SLOT.getAddress(); } /// @notice Return creation timestamp /// @return Creation timestamp function created() external view override returns (uint256) { return _CREATED_SLOT.getUint(); } /// @notice Return creation block number /// @return Creation block number function createdBlock() external override view returns (uint256) { return _CREATED_BLOCK_SLOT.getUint(); } /// @dev Revision should be increased on each contract upgrade function increaseRevision(address oldLogic) external override { require(msg.sender == address(this), "Increase revision forbidden"); uint r = _REVISION_SLOT.getUint() + 1; _REVISION_SLOT.set(r); _PREVIOUS_LOGIC_SLOT.set(oldLogic); emit RevisionIncreased(r, oldLogic); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (metatx/ERC2771Context.sol) pragma solidity ^0.8.1; import "../interfaces/IAppErrors.sol"; /** * @dev Context variant with ERC2771 support. */ // based on https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/metatx/ERC2771Context.sol abstract contract ERC2771Context { // for whitelist new relayers need to add new constants and update proxies address private constant GELATO_RELAY_1_BALANCE_ERC_2771 = 0xd8253782c45a12053594b9deB72d8e8aB2Fca54c; address private constant SACRA_RELAY = 0x52CEba41Da235Af367bFC0b0cCd3314cb901bB5F; function isTrustedForwarder(address forwarder) public view virtual returns (bool){ return forwarder == GELATO_RELAY_1_BALANCE_ERC_2771 || forwarder == SACRA_RELAY; } function _msgSender() internal view virtual returns (address sender) { if (isTrustedForwarder(msg.sender)) { // The assembly code is more direct than the Solidity version using `abi.decode`. /// @solidity memory-safe-assembly assembly { sender := shr(96, calldataload(sub(calldatasize(), 20))) } return sender; } else { return msg.sender; } } function _msgData() internal view virtual returns (bytes calldata) { if (isTrustedForwarder(msg.sender)) { return msg.data[: msg.data.length - 20]; } else { return msg.data; } } /// @notice Return true if given address is not a smart contract but a wallet address. /// @dev It is not 100% guarantee after EIP-3074 implementation, use it as an additional check. /// @return true if the address is a wallet. function _isNotSmartContract() internal view returns (bool) { return isTrustedForwarder(msg.sender) || msg.sender == tx.origin; } function onlyEOA() internal view { if (!_isNotSmartContract()) { revert IAppErrors.NotEOA(msg.sender); } } }
{ "evmVersion": "istanbul", "libraries": {}, "metadata": { "bytecodeHash": "ipfs", "useLiteralContent": true }, "optimizer": { "enabled": true, "runs": 50 }, "remappings": [], "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"name":"AuctionBidClosed","type":"error"},{"inputs":[],"name":"AuctionBidNotFound","type":"error"},{"inputs":[{"internalType":"uint256","name":"positionId","type":"uint256"}],"name":"AuctionBidOpened","type":"error"},{"inputs":[],"name":"AuctionBuyerOnly","type":"error"},{"inputs":[],"name":"AuctionEnded","type":"error"},{"inputs":[],"name":"AuctionGuildWithShelterCannotBid","type":"error"},{"inputs":[],"name":"AuctionNotEnded","type":"error"},{"inputs":[],"name":"AuctionPositionClosed","type":"error"},{"inputs":[{"internalType":"uint256","name":"positionId","type":"uint256"}],"name":"AuctionPositionOpened","type":"error"},{"inputs":[],"name":"AuctionSellerCannotBid","type":"error"},{"inputs":[],"name":"AuctionSellerOnly","type":"error"},{"inputs":[],"name":"CannotApplyNotLastBid","type":"error"},{"inputs":[],"name":"CannotCloseLastBid","type":"error"},{"inputs":[],"name":"ErrorNotAllowedSender","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ErrorNotDeployer","type":"error"},{"inputs":[],"name":"ErrorPaused","type":"error"},{"inputs":[{"internalType":"uint256","name":"right","type":"uint256"}],"name":"GuildActionForbidden","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotGuildMember","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"ShelterIsNotOwnedByTheGuild","type":"error"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"name":"TooHighValue","type":"error"},{"inputs":[],"name":"TooLowAmountForNewBid","type":"error"},{"inputs":[],"name":"TooLowAmountToBid","type":"error"},{"inputs":[],"name":"WrongAuctionPosition","type":"error"},{"inputs":[],"name":"ZeroValueNotAllowed","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"bidId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"positionId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"msgSender","type":"address"}],"name":"AuctionBidOpened","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"positionId","type":"uint256"},{"indexed":false,"internalType":"address","name":"msgSender","type":"address"}],"name":"AuctionPositionClosed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"positionId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shelterId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"sellerGuildId","type":"uint256"},{"indexed":false,"internalType":"address","name":"msgSender","type":"address"},{"indexed":false,"internalType":"uint256","name":"minAuctionPrice","type":"uint256"}],"name":"AuctionPositionOpened","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"controller","type":"address"},{"indexed":false,"internalType":"uint256","name":"ts","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"block","type":"uint256"}],"name":"ContractInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"address","name":"oldLogic","type":"address"}],"name":"RevisionIncreased","type":"event"},{"inputs":[],"name":"CONTROLLABLE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"bidId","type":"uint256"}],"name":"applyAuctionBid","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"positionId","type":"uint256"}],"name":"auctionEndTs","outputs":[{"internalType":"uint256","name":"timestamp","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"positionId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"bid","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"bidCounter","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"bidId","type":"uint256"}],"name":"closeAuctionBid","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"positionId","type":"uint256"}],"name":"closePosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"controller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"created","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"createdBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"bidId_","type":"uint256"}],"name":"getBid","outputs":[{"components":[{"internalType":"bool","name":"open","type":"bool"},{"internalType":"address","name":"buyer","type":"address"},{"internalType":"uint128","name":"bidId","type":"uint128"},{"internalType":"uint128","name":"positionId","type":"uint128"},{"internalType":"uint128","name":"amount","type":"uint128"},{"internalType":"uint128","name":"buyerGuildId","type":"uint128"}],"internalType":"struct IShelterAuction.AuctionBid","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"positionId_","type":"uint256"}],"name":"getPosition","outputs":[{"components":[{"internalType":"bool","name":"open","type":"bool"},{"internalType":"address","name":"seller","type":"address"},{"internalType":"uint64","name":"shelterId","type":"uint64"},{"internalType":"uint128","name":"positionId","type":"uint128"},{"internalType":"uint128","name":"minAuctionPrice","type":"uint128"},{"internalType":"uint128","name":"sellerGuildId","type":"uint128"}],"internalType":"struct IShelterAuction.Position","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"oldLogic","type":"address"}],"name":"increaseRevision","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"controller_","type":"address"}],"name":"init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"value_","type":"address"}],"name":"isController","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"value_","type":"address"}],"name":"isGovernance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"forwarder","type":"address"}],"name":"isTrustedForwarder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"positionId","type":"uint256"}],"name":"lastAuctionBidTs","outputs":[{"internalType":"uint256","name":"timestamp","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"positionId","type":"uint256"}],"name":"nextAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shelterId","type":"uint256"},{"internalType":"uint256","name":"minAuctionPrice","type":"uint256"}],"name":"openPosition","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"openPositionByIndex","outputs":[{"internalType":"uint256","name":"positionId","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"openPositionsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shelterId_","type":"uint256"}],"name":"posByShelter","outputs":[{"internalType":"uint256","name":"positionId","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"positionId","type":"uint256"},{"internalType":"uint256","name":"bidIndex","type":"uint256"}],"name":"positionBidByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"positionId","type":"uint256"}],"name":"positionBidsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"buyerGuildId","type":"uint256"}],"name":"positionByBuyer","outputs":[{"internalType":"uint256","name":"positionId","type":"uint256"},{"internalType":"uint256","name":"bidIndex","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"sellerGuildId_","type":"uint256"}],"name":"positionBySeller","outputs":[{"internalType":"uint256","name":"positionId","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"positionCounter","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"previousImplementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"revision","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"fee_","type":"uint256"}],"name":"setFee","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b507ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff1615906001600160401b03166000811580156200005d5750825b90506000826001600160401b031660011480156200007a5750303b155b90508115801562000089575080155b15620000a85760405163f92ee8a960e01b815260040160405180910390fd5b84546001600160401b03191660011785558315620000d757845460ff60401b1916680100000000000000001785555b83156200011e57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050612deb80620001336000396000f3fe608060405234801561001057600080fd5b50600436106101bb5760003560e01c806369908303116100fa578063b17583e71161009d578063b17583e714610403578063b429afeb14610416578063b6dcc98314610429578063ddca3f431461043c578063dee1f0e414610444578063eb02c30114610457578063ec82a664146104d6578063f77c4791146104e9578063ffa1ad74146103aa57600080fd5b8063699083031461034157806369fe0e2d146103545780637cc963801461036757806381165ec61461036f578063905c1e9314610382578063936725ec146103aa5780639d0bcca0146103db578063a126d601146103f057600080fd5b80633c889e6f116101625780633c889e6f146102575780633f678f05146102cd5780634593144c146102e05780634fac6ccd146102e8578063572b6c05146102fb578063598647f81461031e57806363d5ab8d14610331578063689d84ca1461033957600080fd5b806303f69354146101c0578063106f7635146101db57806319ab453c146101f057806320bc4b501461020357806320e763b8146102165780633012b05c14610229578063325a19f11461023c578063366e300014610244575b600080fd5b6101c86104f1565b6040519081526020015b60405180910390f35b6101ee6101e9366004612a8f565b610500565b005b6101ee6101fe366004612abd565b61051c565b6101c8610211366004612ae1565b610632565b6101c8610224366004612a8f565b610647565b6101c8610237366004612ae1565b610656565b6101c8610672565b6101c8610252366004612a8f565b6106a6565b61026a610265366004612a8f565b6106b1565b604080518251151581526020808401516001600160a01b031690820152828201516001600160801b039081169282019290925260608084015183169082015260808084015183169082015260a0928301519091169181019190915260c0016101d2565b6101ee6102db366004612a8f565b6106c2565b6101c86106e0565b6101ee6102f6366004612abd565b610710565b61030e610309366004612abd565b610819565b60405190151581526020016101d2565b6101ee61032c366004612ae1565b610867565b6101c861088a565b6101c8610894565b6101c861034f366004612a8f565b61089e565b6101ee610362366004612a8f565b6108a9565b6101c86108ba565b6101c861037d366004612a8f565b6108d8565b610395610390366004612a8f565b6108e3565b604080519283526020830191909152016101d2565b6103ce604051806040016040528060058152602001640312e302e360dc1b81525081565b6040516101d29190612b03565b6103e361090f565b6040516101d29190612b52565b6101ee6103fe366004612a8f565b61093f565b6101c8610411366004612a8f565b61095d565b61030e610424366004612abd565b610970565b6101c8610437366004612a8f565b610995565b6101c86109a0565b61030e610452366004612abd565b6109aa565b61046a610465366004612a8f565b610a2f565b6040516101d291908151151581526020808301516001600160a01b0316908201526040808301516001600160401b0316908201526060808301516001600160801b039081169183019190915260808084015182169083015260a092830151169181019190915260c00190565b6101c86104e4366004612a8f565b610a40565b6103e3610a4b565b60006104fb610a7b565b905090565b61051961050b610a4b565b610513610aaf565b83610ad1565b50565b6000610526610e1b565b805490915060ff600160401b82041615906001600160401b031660008115801561054d5750825b90506000826001600160401b031660011480156105695750303b155b905081158015610577575080155b156105955760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff1916600117855583156105bf57845460ff60401b1916600160401b1785555b6105c886610e3f565b60646105d2610e50565b600360009081526020919091526040902055831561062a57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b600061063e8383610e74565b90505b92915050565b60006106418262015180610eb6565b600061063e610663610a4b565b61066b610aaf565b8585610ef6565b60006104fb6106a260017f6f55f470bdc9cb5f04223fd822021061668e4dccb43e8727b295106dc9769c8b612b92565b5490565b600061064182611250565b6106b9612a5a565b61064182611328565b6105196106cd610a4b565b6106d5610aaf565b8362015180426113b6565b60006104fb6106a260017f812a673dfca07956350df10f8a654925f561d7a0da09bdbe79e653939a14d9f1612b92565b3330146107625760405162461bcd60e51b815260206004820152601b60248201527a24b731b932b0b9b2903932bb34b9b4b7b7103337b93134b23232b760291b60448201526064015b60405180910390fd5b60006107806106a26001600080516020612d96833981519152612b92565b61078b906001612ba5565b90506107ad816107aa6001600080516020612d96833981519152612b92565b55565b6107dc826107aa60017fbfaaa2fb63266ff27c2da975f5894955056f50419af651a81f6c5060581857e4612b92565b7ff27e2ef832a4eb8ed8ec553b875eecd44764cda95b1c24170e281539e0a869c8818360405161080d929190612bb8565b60405180910390a15050565b60006001600160a01b03821673d8253782c45a12053594b9deb72d8e8ab2fca54c148061064157506001600160a01b0382167352ceba41da235af367bfc0b0ccd3314cb901bb5f1492915050565b610886610872610a4b565b61087a610aaf565b84846201518042611931565b5050565b60006104fb611f38565b60006104fb611f4b565b600061064182611f60565b6105196108b4610a4b565b82611f7e565b60006104fb6106a26001600080516020612d96833981519152612b92565b600061064182611fcc565b60008060006108f184611fea565b80516020909101516001600160801b03918216969116945092505050565b60006104fb6106a260017fbfaaa2fb63266ff27c2da975f5894955056f50419af651a81f6c5060581857e4612b92565b61051961094a610a4b565b610952610aaf565b836201518042612040565b600061064161096a610a4b565b83612224565b600061097a610a4b565b6001600160a01b0316826001600160a01b0316149050919050565b600061064182612382565b60006104fb6123a0565b6000816001600160a01b03166109be610a4b565b6001600160a01b0316635aa6e6756040518163ffffffff1660e01b8152600401602060405180830381865afa1580156109fb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a1f9190612bcf565b6001600160a01b03161492915050565b610a37612a5a565b610641826123b3565b60006106418261244c565b60006104fb6106a260017f5165972ef41194f06c5007493031d0b927c20741adcb74403b954009fd2c3618612b92565b6000610a85610e50565b600060025b6003811115610a9b57610a9b612b66565b815260200190815260200160002054905090565b6000610aba33610819565b15610acc575060131936013560601c90565b503390565b610ada83612463565b6000836001600160a01b03166325eb1c876040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b3e9190612bcf565b90506000610b4e848360036124e3565b5090506000610b5b610e50565b6000858152600291909101602052604081206001810154909250600160801b90046001600160801b031690819003610ba657604051633efb857360e11b815260040160405180910390fd5b6002820154600160801b90046001600160801b03168314610bda57604051634da94fcf60e11b815260040160405180910390fd5b815460ff16610bfc57604051637905976d60e11b815260040160405180910390fd5b6000610c06610e50565b600083815260079190910160205260408120805490925087908390610c2d90600190612b92565b81548110610c3d57610c3d612bec565b90600052602060002001541490506000610c55610e50565b6000858152600191909101602052604090209050818015610c775750805460ff165b15610c9557604051634b8cbdab60e11b815260040160405180910390fd5b845460ff19168555610ca5610e50565b600087815260069190910160205260408082208290555163f2e0023d60e01b8152600481018890526001600160a01b0389169063f2e0023d90602401602060405180830381865afa158015610cfe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d229190612bcf565b905060008b6001600160a01b031663c3dfdae66040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d889190612bcf565b600288015460405163a9059cbb60e01b81526001600160a01b0385811660048301526001600160801b03909216602482015291925082169063a9059cbb906044016020604051808303816000875af1158015610de8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e0c9190612c02565b50505050505050505050505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0090565b610e47612657565b6105198161267e565b7f597e4e55fd306bfc6bfaaa6b3e10d80a4b0fe770b166ac704f10504e76e97c0090565b6000610e7e610e50565b60070160008481526020019081526020016000208281548110610ea357610ea3612bec565b9060005260206000200154905092915050565b600080610ec1610e50565b6000858152600891909101602052604090205490508015610eeb57610ee68382612ba5565b610eee565b60005b949350505050565b6000610f0185612463565b81600003610f225760405163273e150360e21b815260040160405180910390fd5b6000856001600160a01b03166325eb1c876040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f869190612bcf565b90506000610f96868360036124e3565b5090506000610fa3610e50565b6000838152600591909101602052604090205490508015610fda5760405163cc0a2fff60e01b815260048101829052602401610759565b604051635f1c54df60e01b81526004810183905286906001600160a01b03851690635f1c54df90602401602060405180830381865afa158015611021573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110459190612c24565b1461106357604051631ca073bd60e31b815260040160405180910390fd5b856000036110845760405163273e150360e21b815260040160405180910390fd5b6000611090600161279d565b90506110a78161109e610e50565b6003019061282d565b506040518060c00160405280600115158152602001896001600160a01b03168152602001886001600160401b03168152602001826001600160801b03168152602001876001600160801b03168152602001846001600160801b031681525061110d610e50565b6000838152600191820160209081526040918290208451815492860151938601516001600160a81b0319909316901515610100600160a81b031916176101006001600160a01b03909416939093029290921767ffffffffffffffff60a81b1916600160a81b6001600160401b0390921691909102178155606083015160808401516001600160801b03918216600160801b91831691909102179282019290925560a090920151600290920180546001600160801b03191692909116919091179055806111d7610e50565b6000858152600591909101602090815260409182902092909255805183815291820189905281018490526001600160a01b0389166060820152608081018790527fa44f8017b814948f1b74137948e0765373df974f6f93314e7eae177beefdfe979060a00160405180910390a198975050505050505050565b60008061125b610e50565b6000848152600791909101602052604081208054909250908190036112af57611282610e50565b60009485526001908101602052604090942090930154600160801b90046001600160801b03169392505050565b60006112b9610e50565b6002016000846112ca600186612b92565b815481106112da576112da612bec565b600091825260208083209091015483528201929092526040019020600281015490915060649061131590606e906001600160801b0316612c3d565b61131f9190612c54565b95945050505050565b611330612a5a565b611338610e50565b600092835260029081016020908152604093849020845160c081018652815460ff81161515825261010090046001600160a01b03169281019290925260018101546001600160801b0380821696840196909652600160801b908190048616606084015292015480851660808301529190910490921660a08301525090565b6113bf85612463565b6000856001600160a01b03166325eb1c876040518163ffffffff1660e01b8152600401602060405180830381865afa1580156113ff573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114239190612bcf565b90506000611433868360036124e3565b5090506000611440610e50565b6000878152600291909101602052604081206001810154909250600160801b90046001600160801b03169081900361148b57604051633efb857360e11b815260040160405180910390fd5b815460ff166114ad57604051637905976d60e11b815260040160405180910390fd5b60006114b7610e50565b600083815260019190910160205260409020805490915060ff166114ee576040516311d0812360e01b815260040160405180910390fd5b85876114f8610e50565b600085815260089190910160205260409020546115159190612ba5565b1061153357604051636463738960e01b815260040160405180910390fd5b600061153d610e50565b60008481526007919091016020526040902080549091508990829061156490600190612b92565b8154811061157457611574612bec565b90600052602060002001541461159d57604051631c42dc1f60e21b815260040160405180910390fd5b50600280820154908401546001600160801b0391821691600160801b909104168582148015906115cd5750808614155b156115eb5760405163f20e063760e01b815260040160405180910390fd5b825460ff199081168455855416855561160f84611606610e50565b60030190612839565b50611618610e50565b60008381526005919091016020526040812055611633610e50565b6000828152600691909101602090815260408083208390558051632d4f2d5160e11b815290516001600160a01b038b1692635a9e5aa292600480820193918290030181865afa15801561168a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116ae9190612bcf565b8454604051635f623c8b60e01b8152600160a81b9091046001600160401b03166004820152602481018490529091506001600160a01b03821690635f623c8b90604401600060405180830381600087803b15801561170b57600080fd5b505af115801561171f573d6000803e3d6000fd5b50505050505060008b6001600160a01b031663c3dfdae66040518163ffffffff1660e01b8152600401602060405180830381865afa158015611765573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117899190612bcf565b60028601549091506001600160801b03166000620186a06117a86123a0565b6117b29084612c3d565b6117bc9190612c54565b9050801561183757826001600160a01b031663a9059cbb8f836040518363ffffffff1660e01b81526004016117f2929190612c76565b6020604051808303816000875af1158015611811573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118359190612c02565b505b60405163f2e0023d60e01b8152600481018590526000906001600160a01b038b169063f2e0023d90602401602060405180830381865afa15801561187f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118a39190612bcf565b90506001600160a01b03841663a9059cbb826118bf8587612b92565b6040518363ffffffff1660e01b81526004016118dc929190612c76565b6020604051808303816000875af11580156118fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061191f9190612c02565b50505050505050505050505050505050565b61193a86612463565b6000866001600160a01b03166325eb1c876040518163ffffffff1660e01b8152600401602060405180830381865afa15801561197a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061199e9190612bcf565b905060006119ae878360036124e3565b50905060006119bb610e50565b6000888152600191820160205260409020908101549091506001600160801b031687146119fb57604051638f948d0760e01b815260040160405180910390fd5b805460ff16611a1d576040516311d0812360e01b815260040160405180910390fd5b60028101546001600160801b0316829003611a4b5760405163b918ff0360e01b815260040160405180910390fd5b6000611a55610e50565b60008481526006919091016020526040902080549091506001600160801b031615611aa1578054604051636a34a9f760e01b81526001600160801b039091166004820152602401610759565b6000611aab610e50565b60070160008a81526020019081526020016000209050846001600160a01b0316635a9e5aa26040518163ffffffff1660e01b8152600401602060405180830381865afa158015611aff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b239190612bcf565b6001600160a01b0316635f1c54df856040518263ffffffff1660e01b8152600401611b5091815260200190565b602060405180830381865afa158015611b6d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b919190612c24565b15611baf57604051630a340f6960e11b815260040160405180910390fd5b80546000819003611bf4576001840154600160801b90046001600160801b0316891015611bef5760405163578b090f60e11b815260040160405180910390fd5b611ccd565b8688611bfe610e50565b60008d81526008919091016020526040902054611c1b9190612ba5565b1015611c3a5760405163283a4a6160e21b815260040160405180910390fd5b6000611c44610e50565b600201600084611c55600186612b92565b81548110611c6557611c65612bec565b60009182526020808320909101548352820192909252604001902060028101549091508a90606490611ca290606e906001600160801b0316612c3d565b611cac9190612c54565b1115611ccb5760405163b0738bcb60e01b815260040160405180910390fd5b505b6040805160c081018252600181526001600160a01b038d1660208201526000918101611cf9600261279d565b6001600160801b0390811682528d81166020808401919091528d82166040808501919091528a83166060909401939093529183015186546001810188556000888152939093209116910155905080611d4f610e50565b6040808401516001600160801b039081166000908152600293840160209081529083902085518154878401516001600160a01b031661010002610100600160a81b0319921515929092166001600160a81b0319909116171781558584015160608701518416600160801b908102918516919091176001830155608087015160a09097015184160295831695909517949093019390935580518082019091528d8316815291841690820152611e01610e50565b600088815260069190910160209081526040909120825192909101516001600160801b03908116600160801b02921691909117905587611e3f610e50565b60008d815260089190910160205260409081902091909155818101519051630a8b446b60e41b815260048101889052602481018c90526001600160801b0390911660448201526001600160a01b0388169063a8b446b090606401600060405180830381600087803b158015611eb357600080fd5b505af1158015611ec7573d6000803e3d6000fd5b50505060408083015181516001600160801b039091168152602081018e90529081018c90526001600160a01b038e1660608201527f212de920a843943385be4d0be6f5375802a6c0eb13258959f94184f8599aa1f1915060800160405180910390a150505050505050505050505050565b6000611f42610e50565b60006001610a8a565b60006104fb611f58610e50565b600301612845565b6000611f6a610e50565b600092835260070160205250604090205490565b611f878261284f565b61c350811115611fad57604051633995b34160e01b815260048101829052602401610759565b80611fb6610e50565b6003600090815260209190915260409020555050565b6000611fd6610e50565b600092835260080160205250604090205490565b6040805180820190915260008082526020820152612006610e50565b600092835260060160209081526040928390208351808501909452546001600160801b038082168552600160801b90910416908301525090565b61204985612463565b6000856001600160a01b03166325eb1c876040518163ffffffff1660e01b8152600401602060405180830381865afa158015612089573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120ad9190612bcf565b905060006120bd868360036124e3565b50905060006120ca610e50565b6000878152600191820160205260409020908101549091506001600160801b0316861461210a57604051638f948d0760e01b815260040160405180910390fd5b60028101546001600160801b03168214612137576040516303cdc39d60e01b815260040160405180910390fd5b805460ff16612159576040516311d0812360e01b815260040160405180910390fd5b6000612163610e50565b600088815260089190910160205260409020549050801580159061218f57508461218d8783612ba5565b105b156121ad5760405163283a4a6160e21b815260040160405180910390fd5b6121b987611606610e50565b506121c2610e50565b6000848152600591909101602052604080822091909155825460ff19168355517fda6994de7462b880631ad7c521a8208d0ddddecdac70aeb1b3abeaa408a2cd6e906122119089908b90612bb8565b60405180910390a1505050505050505050565b600080836001600160a01b03166325eb1c876040518163ffffffff1660e01b8152600401602060405180830381865afa158015612265573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122899190612bcf565b90506000816001600160a01b0316635a9e5aa26040518163ffffffff1660e01b8152600401602060405180830381865afa1580156122cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122ef9190612bcf565b90506001600160a01b0381161561237757604051630cf9202b60e11b815260048101859052612372906001600160a01b038316906319f2405690602401602060405180830381865afa158015612349573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061236d9190612c24565b612382565b61131f565b600095945050505050565b600061238c610e50565b600092835260050160205250604090205490565b60006123aa610e50565b60006003610a8a565b6123bb612a5a565b6123c3610e50565b600092835260019081016020908152604093849020845160c081018652815460ff81161515825261010081046001600160a01b031693820193909352600160a81b9092046001600160401b031694820194909452908301546001600160801b038082166060840152600160801b9091048116608083015260029093015490921660a08301525090565b60006106418261245a610e50565b600301906128db565b806001600160a01b03166318d928316040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124c59190612c02565b1561051957604051635e1633d360e11b815260040160405180910390fd5b600080836001600160a01b0316633b4c9891866040518263ffffffff1660e01b81526004016125129190612b52565b602060405180830381865afa15801561252f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125539190612c24565b91508160000361257657604051632f6c853960e11b815260040160405180910390fd5b6040516373cf874b60e11b81526001600160a01b0385169063e79f0e96906125a2908890600401612b52565b602060405180830381865afa1580156125bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125e39190612c24565b90506125f160006002612d73565b811615158061261d575082600c81111561260d5761260d612b66565b612618906002612d73565b811615155b61264f5782600c81111561263357612633612b66565b604051630d816ed160e01b815260040161075991815260200190565b935093915050565b61265f6128e7565b61267c57604051631afcd79f60e31b815260040160405180910390fd5b565b6001600160a01b0381166126c65760405162461bcd60e51b815260206004820152600f60248201526e2d32b9379031b7b73a3937b63632b960891b6044820152606401610759565b6126f5816107aa60017f5165972ef41194f06c5007493031d0b927c20741adcb74403b954009fd2c3618612b92565b612724426107aa60017f6f55f470bdc9cb5f04223fd822021061668e4dccb43e8727b295106dc9769c8b612b92565b612753436107aa60017f812a673dfca07956350df10f8a654925f561d7a0da09bdbe79e653939a14d9f1612b92565b604080516001600160a01b0383168152426020820152438183015290517f1a2dd071001ebf6e03174e3df5b305795a4ad5d41d8fdb9ba41dbbe2367134269181900360600190a150565b60006127a7610e50565b60008360038111156127bb576127bb612b66565b60038111156127cc576127cc612b66565b81526020019081526020016000205460016127e79190612ba5565b9050806127f2610e50565b600084600381111561280657612806612b66565b600381111561281757612817612b66565b8152602081019190915260400160002055919050565b600061063e8383612901565b600061063e8383612950565b6000610641825490565b604051631430d62960e21b81526001600160a01b038216906350c358a49061287b903390600401612b52565b602060405180830381865afa158015612898573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128bc9190612c02565b610519573360405163451cea1760e11b81526004016107599190612b52565b600061063e8383612a43565b60006128f1610e1b565b54600160401b900460ff16919050565b600081815260018301602052604081205461294857508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610641565b506000610641565b60008181526001830160205260408120548015612a39576000612974600183612b92565b855490915060009061298890600190612b92565b90508082146129ed5760008660000182815481106129a8576129a8612bec565b90600052602060002001549050808760000184815481106129cb576129cb612bec565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806129fe576129fe612d7f565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610641565b6000915050610641565b6000826000018281548110610ea357610ea3612bec565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a081019190915290565b600060208284031215612aa157600080fd5b5035919050565b6001600160a01b038116811461051957600080fd5b600060208284031215612acf57600080fd5b8135612ada81612aa8565b9392505050565b60008060408385031215612af457600080fd5b50508035926020909101359150565b60006020808352835180602085015260005b81811015612b3157858101830151858201604001528201612b15565b506000604082860101526040601f19601f8301168501019250505092915050565b6001600160a01b0391909116815260200190565b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b8181038181111561064157610641612b7c565b8082018082111561064157610641612b7c565b9182526001600160a01b0316602082015260400190565b600060208284031215612be157600080fd5b8151612ada81612aa8565b634e487b7160e01b600052603260045260246000fd5b600060208284031215612c1457600080fd5b81518015158114612ada57600080fd5b600060208284031215612c3657600080fd5b5051919050565b808202811582820484141761064157610641612b7c565b600082612c7157634e487b7160e01b600052601260045260246000fd5b500490565b6001600160a01b03929092168252602082015260400190565b600181815b80851115612cca578160001904821115612cb057612cb0612b7c565b80851615612cbd57918102915b93841c9390800290612c94565b509250929050565b600082612ce157506001610641565b81612cee57506000610641565b8160018114612d045760028114612d0e57612d2a565b6001915050610641565b60ff841115612d1f57612d1f612b7c565b50506001821b610641565b5060208310610133831016604e8410600b8410161715612d4d575081810a610641565b612d578383612c8f565b8060001904821115612d6b57612d6b612b7c565b029392505050565b600061063e8383612cd2565b634e487b7160e01b600052603160045260246000fdfe22573091f17911fb166032a3d9e0554aa73d31b7b7ddea4a4dd2995650af84bda2646970667358221220a7ed299b9e4ad00e817b5300c45a64ef9e9cbdc8b595e4183cc07c810522429064736f6c63430008170033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101bb5760003560e01c806369908303116100fa578063b17583e71161009d578063b17583e714610403578063b429afeb14610416578063b6dcc98314610429578063ddca3f431461043c578063dee1f0e414610444578063eb02c30114610457578063ec82a664146104d6578063f77c4791146104e9578063ffa1ad74146103aa57600080fd5b8063699083031461034157806369fe0e2d146103545780637cc963801461036757806381165ec61461036f578063905c1e9314610382578063936725ec146103aa5780639d0bcca0146103db578063a126d601146103f057600080fd5b80633c889e6f116101625780633c889e6f146102575780633f678f05146102cd5780634593144c146102e05780634fac6ccd146102e8578063572b6c05146102fb578063598647f81461031e57806363d5ab8d14610331578063689d84ca1461033957600080fd5b806303f69354146101c0578063106f7635146101db57806319ab453c146101f057806320bc4b501461020357806320e763b8146102165780633012b05c14610229578063325a19f11461023c578063366e300014610244575b600080fd5b6101c86104f1565b6040519081526020015b60405180910390f35b6101ee6101e9366004612a8f565b610500565b005b6101ee6101fe366004612abd565b61051c565b6101c8610211366004612ae1565b610632565b6101c8610224366004612a8f565b610647565b6101c8610237366004612ae1565b610656565b6101c8610672565b6101c8610252366004612a8f565b6106a6565b61026a610265366004612a8f565b6106b1565b604080518251151581526020808401516001600160a01b031690820152828201516001600160801b039081169282019290925260608084015183169082015260808084015183169082015260a0928301519091169181019190915260c0016101d2565b6101ee6102db366004612a8f565b6106c2565b6101c86106e0565b6101ee6102f6366004612abd565b610710565b61030e610309366004612abd565b610819565b60405190151581526020016101d2565b6101ee61032c366004612ae1565b610867565b6101c861088a565b6101c8610894565b6101c861034f366004612a8f565b61089e565b6101ee610362366004612a8f565b6108a9565b6101c86108ba565b6101c861037d366004612a8f565b6108d8565b610395610390366004612a8f565b6108e3565b604080519283526020830191909152016101d2565b6103ce604051806040016040528060058152602001640312e302e360dc1b81525081565b6040516101d29190612b03565b6103e361090f565b6040516101d29190612b52565b6101ee6103fe366004612a8f565b61093f565b6101c8610411366004612a8f565b61095d565b61030e610424366004612abd565b610970565b6101c8610437366004612a8f565b610995565b6101c86109a0565b61030e610452366004612abd565b6109aa565b61046a610465366004612a8f565b610a2f565b6040516101d291908151151581526020808301516001600160a01b0316908201526040808301516001600160401b0316908201526060808301516001600160801b039081169183019190915260808084015182169083015260a092830151169181019190915260c00190565b6101c86104e4366004612a8f565b610a40565b6103e3610a4b565b60006104fb610a7b565b905090565b61051961050b610a4b565b610513610aaf565b83610ad1565b50565b6000610526610e1b565b805490915060ff600160401b82041615906001600160401b031660008115801561054d5750825b90506000826001600160401b031660011480156105695750303b155b905081158015610577575080155b156105955760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff1916600117855583156105bf57845460ff60401b1916600160401b1785555b6105c886610e3f565b60646105d2610e50565b600360009081526020919091526040902055831561062a57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b600061063e8383610e74565b90505b92915050565b60006106418262015180610eb6565b600061063e610663610a4b565b61066b610aaf565b8585610ef6565b60006104fb6106a260017f6f55f470bdc9cb5f04223fd822021061668e4dccb43e8727b295106dc9769c8b612b92565b5490565b600061064182611250565b6106b9612a5a565b61064182611328565b6105196106cd610a4b565b6106d5610aaf565b8362015180426113b6565b60006104fb6106a260017f812a673dfca07956350df10f8a654925f561d7a0da09bdbe79e653939a14d9f1612b92565b3330146107625760405162461bcd60e51b815260206004820152601b60248201527a24b731b932b0b9b2903932bb34b9b4b7b7103337b93134b23232b760291b60448201526064015b60405180910390fd5b60006107806106a26001600080516020612d96833981519152612b92565b61078b906001612ba5565b90506107ad816107aa6001600080516020612d96833981519152612b92565b55565b6107dc826107aa60017fbfaaa2fb63266ff27c2da975f5894955056f50419af651a81f6c5060581857e4612b92565b7ff27e2ef832a4eb8ed8ec553b875eecd44764cda95b1c24170e281539e0a869c8818360405161080d929190612bb8565b60405180910390a15050565b60006001600160a01b03821673d8253782c45a12053594b9deb72d8e8ab2fca54c148061064157506001600160a01b0382167352ceba41da235af367bfc0b0ccd3314cb901bb5f1492915050565b610886610872610a4b565b61087a610aaf565b84846201518042611931565b5050565b60006104fb611f38565b60006104fb611f4b565b600061064182611f60565b6105196108b4610a4b565b82611f7e565b60006104fb6106a26001600080516020612d96833981519152612b92565b600061064182611fcc565b60008060006108f184611fea565b80516020909101516001600160801b03918216969116945092505050565b60006104fb6106a260017fbfaaa2fb63266ff27c2da975f5894955056f50419af651a81f6c5060581857e4612b92565b61051961094a610a4b565b610952610aaf565b836201518042612040565b600061064161096a610a4b565b83612224565b600061097a610a4b565b6001600160a01b0316826001600160a01b0316149050919050565b600061064182612382565b60006104fb6123a0565b6000816001600160a01b03166109be610a4b565b6001600160a01b0316635aa6e6756040518163ffffffff1660e01b8152600401602060405180830381865afa1580156109fb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a1f9190612bcf565b6001600160a01b03161492915050565b610a37612a5a565b610641826123b3565b60006106418261244c565b60006104fb6106a260017f5165972ef41194f06c5007493031d0b927c20741adcb74403b954009fd2c3618612b92565b6000610a85610e50565b600060025b6003811115610a9b57610a9b612b66565b815260200190815260200160002054905090565b6000610aba33610819565b15610acc575060131936013560601c90565b503390565b610ada83612463565b6000836001600160a01b03166325eb1c876040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b3e9190612bcf565b90506000610b4e848360036124e3565b5090506000610b5b610e50565b6000858152600291909101602052604081206001810154909250600160801b90046001600160801b031690819003610ba657604051633efb857360e11b815260040160405180910390fd5b6002820154600160801b90046001600160801b03168314610bda57604051634da94fcf60e11b815260040160405180910390fd5b815460ff16610bfc57604051637905976d60e11b815260040160405180910390fd5b6000610c06610e50565b600083815260079190910160205260408120805490925087908390610c2d90600190612b92565b81548110610c3d57610c3d612bec565b90600052602060002001541490506000610c55610e50565b6000858152600191909101602052604090209050818015610c775750805460ff165b15610c9557604051634b8cbdab60e11b815260040160405180910390fd5b845460ff19168555610ca5610e50565b600087815260069190910160205260408082208290555163f2e0023d60e01b8152600481018890526001600160a01b0389169063f2e0023d90602401602060405180830381865afa158015610cfe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d229190612bcf565b905060008b6001600160a01b031663c3dfdae66040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d889190612bcf565b600288015460405163a9059cbb60e01b81526001600160a01b0385811660048301526001600160801b03909216602482015291925082169063a9059cbb906044016020604051808303816000875af1158015610de8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e0c9190612c02565b50505050505050505050505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0090565b610e47612657565b6105198161267e565b7f597e4e55fd306bfc6bfaaa6b3e10d80a4b0fe770b166ac704f10504e76e97c0090565b6000610e7e610e50565b60070160008481526020019081526020016000208281548110610ea357610ea3612bec565b9060005260206000200154905092915050565b600080610ec1610e50565b6000858152600891909101602052604090205490508015610eeb57610ee68382612ba5565b610eee565b60005b949350505050565b6000610f0185612463565b81600003610f225760405163273e150360e21b815260040160405180910390fd5b6000856001600160a01b03166325eb1c876040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f869190612bcf565b90506000610f96868360036124e3565b5090506000610fa3610e50565b6000838152600591909101602052604090205490508015610fda5760405163cc0a2fff60e01b815260048101829052602401610759565b604051635f1c54df60e01b81526004810183905286906001600160a01b03851690635f1c54df90602401602060405180830381865afa158015611021573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110459190612c24565b1461106357604051631ca073bd60e31b815260040160405180910390fd5b856000036110845760405163273e150360e21b815260040160405180910390fd5b6000611090600161279d565b90506110a78161109e610e50565b6003019061282d565b506040518060c00160405280600115158152602001896001600160a01b03168152602001886001600160401b03168152602001826001600160801b03168152602001876001600160801b03168152602001846001600160801b031681525061110d610e50565b6000838152600191820160209081526040918290208451815492860151938601516001600160a81b0319909316901515610100600160a81b031916176101006001600160a01b03909416939093029290921767ffffffffffffffff60a81b1916600160a81b6001600160401b0390921691909102178155606083015160808401516001600160801b03918216600160801b91831691909102179282019290925560a090920151600290920180546001600160801b03191692909116919091179055806111d7610e50565b6000858152600591909101602090815260409182902092909255805183815291820189905281018490526001600160a01b0389166060820152608081018790527fa44f8017b814948f1b74137948e0765373df974f6f93314e7eae177beefdfe979060a00160405180910390a198975050505050505050565b60008061125b610e50565b6000848152600791909101602052604081208054909250908190036112af57611282610e50565b60009485526001908101602052604090942090930154600160801b90046001600160801b03169392505050565b60006112b9610e50565b6002016000846112ca600186612b92565b815481106112da576112da612bec565b600091825260208083209091015483528201929092526040019020600281015490915060649061131590606e906001600160801b0316612c3d565b61131f9190612c54565b95945050505050565b611330612a5a565b611338610e50565b600092835260029081016020908152604093849020845160c081018652815460ff81161515825261010090046001600160a01b03169281019290925260018101546001600160801b0380821696840196909652600160801b908190048616606084015292015480851660808301529190910490921660a08301525090565b6113bf85612463565b6000856001600160a01b03166325eb1c876040518163ffffffff1660e01b8152600401602060405180830381865afa1580156113ff573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114239190612bcf565b90506000611433868360036124e3565b5090506000611440610e50565b6000878152600291909101602052604081206001810154909250600160801b90046001600160801b03169081900361148b57604051633efb857360e11b815260040160405180910390fd5b815460ff166114ad57604051637905976d60e11b815260040160405180910390fd5b60006114b7610e50565b600083815260019190910160205260409020805490915060ff166114ee576040516311d0812360e01b815260040160405180910390fd5b85876114f8610e50565b600085815260089190910160205260409020546115159190612ba5565b1061153357604051636463738960e01b815260040160405180910390fd5b600061153d610e50565b60008481526007919091016020526040902080549091508990829061156490600190612b92565b8154811061157457611574612bec565b90600052602060002001541461159d57604051631c42dc1f60e21b815260040160405180910390fd5b50600280820154908401546001600160801b0391821691600160801b909104168582148015906115cd5750808614155b156115eb5760405163f20e063760e01b815260040160405180910390fd5b825460ff199081168455855416855561160f84611606610e50565b60030190612839565b50611618610e50565b60008381526005919091016020526040812055611633610e50565b6000828152600691909101602090815260408083208390558051632d4f2d5160e11b815290516001600160a01b038b1692635a9e5aa292600480820193918290030181865afa15801561168a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116ae9190612bcf565b8454604051635f623c8b60e01b8152600160a81b9091046001600160401b03166004820152602481018490529091506001600160a01b03821690635f623c8b90604401600060405180830381600087803b15801561170b57600080fd5b505af115801561171f573d6000803e3d6000fd5b50505050505060008b6001600160a01b031663c3dfdae66040518163ffffffff1660e01b8152600401602060405180830381865afa158015611765573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117899190612bcf565b60028601549091506001600160801b03166000620186a06117a86123a0565b6117b29084612c3d565b6117bc9190612c54565b9050801561183757826001600160a01b031663a9059cbb8f836040518363ffffffff1660e01b81526004016117f2929190612c76565b6020604051808303816000875af1158015611811573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118359190612c02565b505b60405163f2e0023d60e01b8152600481018590526000906001600160a01b038b169063f2e0023d90602401602060405180830381865afa15801561187f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118a39190612bcf565b90506001600160a01b03841663a9059cbb826118bf8587612b92565b6040518363ffffffff1660e01b81526004016118dc929190612c76565b6020604051808303816000875af11580156118fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061191f9190612c02565b50505050505050505050505050505050565b61193a86612463565b6000866001600160a01b03166325eb1c876040518163ffffffff1660e01b8152600401602060405180830381865afa15801561197a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061199e9190612bcf565b905060006119ae878360036124e3565b50905060006119bb610e50565b6000888152600191820160205260409020908101549091506001600160801b031687146119fb57604051638f948d0760e01b815260040160405180910390fd5b805460ff16611a1d576040516311d0812360e01b815260040160405180910390fd5b60028101546001600160801b0316829003611a4b5760405163b918ff0360e01b815260040160405180910390fd5b6000611a55610e50565b60008481526006919091016020526040902080549091506001600160801b031615611aa1578054604051636a34a9f760e01b81526001600160801b039091166004820152602401610759565b6000611aab610e50565b60070160008a81526020019081526020016000209050846001600160a01b0316635a9e5aa26040518163ffffffff1660e01b8152600401602060405180830381865afa158015611aff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b239190612bcf565b6001600160a01b0316635f1c54df856040518263ffffffff1660e01b8152600401611b5091815260200190565b602060405180830381865afa158015611b6d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b919190612c24565b15611baf57604051630a340f6960e11b815260040160405180910390fd5b80546000819003611bf4576001840154600160801b90046001600160801b0316891015611bef5760405163578b090f60e11b815260040160405180910390fd5b611ccd565b8688611bfe610e50565b60008d81526008919091016020526040902054611c1b9190612ba5565b1015611c3a5760405163283a4a6160e21b815260040160405180910390fd5b6000611c44610e50565b600201600084611c55600186612b92565b81548110611c6557611c65612bec565b60009182526020808320909101548352820192909252604001902060028101549091508a90606490611ca290606e906001600160801b0316612c3d565b611cac9190612c54565b1115611ccb5760405163b0738bcb60e01b815260040160405180910390fd5b505b6040805160c081018252600181526001600160a01b038d1660208201526000918101611cf9600261279d565b6001600160801b0390811682528d81166020808401919091528d82166040808501919091528a83166060909401939093529183015186546001810188556000888152939093209116910155905080611d4f610e50565b6040808401516001600160801b039081166000908152600293840160209081529083902085518154878401516001600160a01b031661010002610100600160a81b0319921515929092166001600160a81b0319909116171781558584015160608701518416600160801b908102918516919091176001830155608087015160a09097015184160295831695909517949093019390935580518082019091528d8316815291841690820152611e01610e50565b600088815260069190910160209081526040909120825192909101516001600160801b03908116600160801b02921691909117905587611e3f610e50565b60008d815260089190910160205260409081902091909155818101519051630a8b446b60e41b815260048101889052602481018c90526001600160801b0390911660448201526001600160a01b0388169063a8b446b090606401600060405180830381600087803b158015611eb357600080fd5b505af1158015611ec7573d6000803e3d6000fd5b50505060408083015181516001600160801b039091168152602081018e90529081018c90526001600160a01b038e1660608201527f212de920a843943385be4d0be6f5375802a6c0eb13258959f94184f8599aa1f1915060800160405180910390a150505050505050505050505050565b6000611f42610e50565b60006001610a8a565b60006104fb611f58610e50565b600301612845565b6000611f6a610e50565b600092835260070160205250604090205490565b611f878261284f565b61c350811115611fad57604051633995b34160e01b815260048101829052602401610759565b80611fb6610e50565b6003600090815260209190915260409020555050565b6000611fd6610e50565b600092835260080160205250604090205490565b6040805180820190915260008082526020820152612006610e50565b600092835260060160209081526040928390208351808501909452546001600160801b038082168552600160801b90910416908301525090565b61204985612463565b6000856001600160a01b03166325eb1c876040518163ffffffff1660e01b8152600401602060405180830381865afa158015612089573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120ad9190612bcf565b905060006120bd868360036124e3565b50905060006120ca610e50565b6000878152600191820160205260409020908101549091506001600160801b0316861461210a57604051638f948d0760e01b815260040160405180910390fd5b60028101546001600160801b03168214612137576040516303cdc39d60e01b815260040160405180910390fd5b805460ff16612159576040516311d0812360e01b815260040160405180910390fd5b6000612163610e50565b600088815260089190910160205260409020549050801580159061218f57508461218d8783612ba5565b105b156121ad5760405163283a4a6160e21b815260040160405180910390fd5b6121b987611606610e50565b506121c2610e50565b6000848152600591909101602052604080822091909155825460ff19168355517fda6994de7462b880631ad7c521a8208d0ddddecdac70aeb1b3abeaa408a2cd6e906122119089908b90612bb8565b60405180910390a1505050505050505050565b600080836001600160a01b03166325eb1c876040518163ffffffff1660e01b8152600401602060405180830381865afa158015612265573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122899190612bcf565b90506000816001600160a01b0316635a9e5aa26040518163ffffffff1660e01b8152600401602060405180830381865afa1580156122cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122ef9190612bcf565b90506001600160a01b0381161561237757604051630cf9202b60e11b815260048101859052612372906001600160a01b038316906319f2405690602401602060405180830381865afa158015612349573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061236d9190612c24565b612382565b61131f565b600095945050505050565b600061238c610e50565b600092835260050160205250604090205490565b60006123aa610e50565b60006003610a8a565b6123bb612a5a565b6123c3610e50565b600092835260019081016020908152604093849020845160c081018652815460ff81161515825261010081046001600160a01b031693820193909352600160a81b9092046001600160401b031694820194909452908301546001600160801b038082166060840152600160801b9091048116608083015260029093015490921660a08301525090565b60006106418261245a610e50565b600301906128db565b806001600160a01b03166318d928316040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124c59190612c02565b1561051957604051635e1633d360e11b815260040160405180910390fd5b600080836001600160a01b0316633b4c9891866040518263ffffffff1660e01b81526004016125129190612b52565b602060405180830381865afa15801561252f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125539190612c24565b91508160000361257657604051632f6c853960e11b815260040160405180910390fd5b6040516373cf874b60e11b81526001600160a01b0385169063e79f0e96906125a2908890600401612b52565b602060405180830381865afa1580156125bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125e39190612c24565b90506125f160006002612d73565b811615158061261d575082600c81111561260d5761260d612b66565b612618906002612d73565b811615155b61264f5782600c81111561263357612633612b66565b604051630d816ed160e01b815260040161075991815260200190565b935093915050565b61265f6128e7565b61267c57604051631afcd79f60e31b815260040160405180910390fd5b565b6001600160a01b0381166126c65760405162461bcd60e51b815260206004820152600f60248201526e2d32b9379031b7b73a3937b63632b960891b6044820152606401610759565b6126f5816107aa60017f5165972ef41194f06c5007493031d0b927c20741adcb74403b954009fd2c3618612b92565b612724426107aa60017f6f55f470bdc9cb5f04223fd822021061668e4dccb43e8727b295106dc9769c8b612b92565b612753436107aa60017f812a673dfca07956350df10f8a654925f561d7a0da09bdbe79e653939a14d9f1612b92565b604080516001600160a01b0383168152426020820152438183015290517f1a2dd071001ebf6e03174e3df5b305795a4ad5d41d8fdb9ba41dbbe2367134269181900360600190a150565b60006127a7610e50565b60008360038111156127bb576127bb612b66565b60038111156127cc576127cc612b66565b81526020019081526020016000205460016127e79190612ba5565b9050806127f2610e50565b600084600381111561280657612806612b66565b600381111561281757612817612b66565b8152602081019190915260400160002055919050565b600061063e8383612901565b600061063e8383612950565b6000610641825490565b604051631430d62960e21b81526001600160a01b038216906350c358a49061287b903390600401612b52565b602060405180830381865afa158015612898573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128bc9190612c02565b610519573360405163451cea1760e11b81526004016107599190612b52565b600061063e8383612a43565b60006128f1610e1b565b54600160401b900460ff16919050565b600081815260018301602052604081205461294857508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610641565b506000610641565b60008181526001830160205260408120548015612a39576000612974600183612b92565b855490915060009061298890600190612b92565b90508082146129ed5760008660000182815481106129a8576129a8612bec565b90600052602060002001549050808760000184815481106129cb576129cb612bec565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806129fe576129fe612d7f565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610641565b6000915050610641565b6000826000018281548110610ea357610ea3612bec565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a081019190915290565b600060208284031215612aa157600080fd5b5035919050565b6001600160a01b038116811461051957600080fd5b600060208284031215612acf57600080fd5b8135612ada81612aa8565b9392505050565b60008060408385031215612af457600080fd5b50508035926020909101359150565b60006020808352835180602085015260005b81811015612b3157858101830151858201604001528201612b15565b506000604082860101526040601f19601f8301168501019250505092915050565b6001600160a01b0391909116815260200190565b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b8181038181111561064157610641612b7c565b8082018082111561064157610641612b7c565b9182526001600160a01b0316602082015260400190565b600060208284031215612be157600080fd5b8151612ada81612aa8565b634e487b7160e01b600052603260045260246000fd5b600060208284031215612c1457600080fd5b81518015158114612ada57600080fd5b600060208284031215612c3657600080fd5b5051919050565b808202811582820484141761064157610641612b7c565b600082612c7157634e487b7160e01b600052601260045260246000fd5b500490565b6001600160a01b03929092168252602082015260400190565b600181815b80851115612cca578160001904821115612cb057612cb0612b7c565b80851615612cbd57918102915b93841c9390800290612c94565b509250929050565b600082612ce157506001610641565b81612cee57506000610641565b8160018114612d045760028114612d0e57612d2a565b6001915050610641565b60ff841115612d1f57612d1f612b7c565b50506001821b610641565b5060208310610133831016604e8410600b8410161715612d4d575081810a610641565b612d578383612c8f565b8060001904821115612d6b57612d6b612b7c565b029392505050565b600061063e8383612cd2565b634e487b7160e01b600052603160045260246000fdfe22573091f17911fb166032a3d9e0554aa73d31b7b7ddea4a4dd2995650af84bda2646970667358221220a7ed299b9e4ad00e817b5300c45a64ef9e9cbdc8b595e4183cc07c810522429064736f6c63430008170033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 31 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.