Source Code
Overview
S Balance
S Value
$0.00View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Cross-Chain Transactions
Loading...
Loading
Contract Name:
Controller
Compiler Version
v0.8.23+commit.f704f362
Optimization Enabled:
Yes with 50 runs
Other Settings:
istanbul EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1
/**
▒▓▒ ▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓███▓▓▒ ▒▒▒▒▓▓▓▒▓▓▓▓▓▓▓██▓
▒██▒▓▓▓▓█▓██████████████████▓ ▒▒▒▓███████████████▒
▒██▒▓█████████████████████▒ ▒▓██████████▓███████
▒███████████▓▒ ▒███▓▓██████▓
█████████▒ ▒▓▒▓███████▒
███████▓ ▒▒▒▒▒▓▓█▓▒ ▓█▓████████
▒▒▒▒▒ ▒▒▒▒▓▓▓█████▒ ▓█████████▓
▒▓▓▓▒▓██████▓ ▒▓▓████████▒
▒██▓▓▓███████▒ ▒▒▓███▓████
▒███▓█████▒ ▒▒█████▓██▓
██████▓ ▒▒▒▓██▓██▓█████▒
▒▒▓▓▒ ▒██▓▒▓▓████████
▓█████▓███████▓
██▓▓██████████▒
▒█████████████
███████████▓
▒▓▓▓▓▓▓▒▓ ▒█████████▒ ▒▓▓
▒▓█▒ ▒▒█▒▒ ▓██████ ▒▒▓▓▒
▒▒█▒ ▓▒ ▒████ ▒▓█▓█▓▒
▓▒██▓▒ ██ ▒▓█▓▓▓██▒
▓█▓▓▓▓▓█▓▓▓▒ ▒▒▒ ▒▒▒▓▓▓▓▒▓▒▒▓▒▓▓▓▓▓▓▓▓▒ ▒▓█▒ ▒▓▒▓█▓
▒▓█▓▓▓▓▓▓▓▓▓▓▒ ▒▒▒▓▒ ▒▒▒▓▓ ▓▓ ▓▓█▓ ▒▒▓▓ ▒▒█▒ ▒▓▒▓█▓
▒▒▓▓▓▒▓▒ ▒▓▓▓▒█▒ ▒▒▒█▒ ▒▒█▓▒▒▒▓▓▓▒ ▓██▓▓▓▓▓▓▓███▓
▒ ▒▓▓█▓ ▒▓▓▓▓█▓█▓ ▒█▓▓▒ ▓▓█▓▒▓█▓▒▒ ▓█▓ ▓███▓
▓▓▒ ▒▒▓▓█▓▒▒▓█▒ ▒▓██▓ ▓██▓▒ ▒█▓ ▓▓██ ▒▓▓▓▒▒▓█▓ ▒▓████▒
██▓▓▒▒▒▒▓▓███▓▒ ▒▓▓▓▓▒▒ ▒▓▓▓▓▓▓▓▒▒▒▓█▓▓▓▓█▓▓▒▒▓▓▓▓▓▒ ▒▓████▓▒ ▓▓███████▓▓▒
*/
pragma solidity 0.8.23;
import "../interfaces/IApplicationEvents.sol";
import "../proxy/Controllable.sol";
import "../lib/ControllerLib.sol";
contract Controller is Controllable, IController {
//region ------------------------ Constants
/// @notice Version of the contract
string public constant override VERSION = "1.0.3";
uint public constant DEPLOYER_ELIGIBILITY_PERIOD = ControllerLib.DEPLOYER_ELIGIBILITY_PERIOD;
//endregion ------------------------ Constants
//region ------------------------ Initializer
function init(address governance_) external initializer {
__Controllable_init(address(this));
ControllerLib._S().governance = governance_;
}
//endregion ------------------------ Initializer
//region ------------------------ Views
function isDeployer(address adr) public view override returns (bool) {
return ControllerLib.isDeployer(adr);
}
function governance() external view override returns (address) {
return ControllerLib.governance();
}
function futureGovernance() external view returns (address) {
return ControllerLib.futureGovernance();
}
function statController() external view override returns (address) {
return ControllerLib.statController();
}
function storyController() external view override returns (address) {
return ControllerLib.storyController();
}
function oracle() external view override returns (address) {
return ControllerLib.oracle();
}
function treasury() external view override returns (address) {
return ControllerLib.treasury();
}
function dungeonFactory() external view override returns (address) {
return ControllerLib.dungeonFactory();
}
function gameObjectController() external view override returns (address) {
return ControllerLib.gameObjectController();
}
function reinforcementController() external view override returns (address) {
return ControllerLib.reinforcementController();
}
function itemController() external view override returns (address) {
return ControllerLib.itemController();
}
function heroController() external view override returns (address) {
return ControllerLib.heroController();
}
function gameToken() external view override returns (address) {
return ControllerLib.gameToken();
}
function validTreasuryTokens(address token) external view override returns (bool) {
return ControllerLib.validTreasuryTokens(token);
}
function onPause() external view override returns (bool) {
return ControllerLib.onPause();
}
function userController() external view override returns (address) {
return ControllerLib.userController();
}
function guildController() external view override returns (address) {
return ControllerLib.guildController();
}
function pvpController() external view override returns (address) {
return ControllerLib.pvpController();
}
function rewardsPool() external view override returns (address) {
return ControllerLib.rewardsPool();
}
function itemBoxController() external view override returns (address) {
return ControllerLib.itemBoxController();
}
function gameTokenPrice() external view override returns (uint) {
return ControllerLib.gameTokenPrice();
}
function gauge() external view returns (address) {
return ControllerLib.gauge();
}
//endregion ------------------------ Views
//region ------------------------ Gov actions - setters
function changePause(bool value) external {
ControllerLib.changePause(value);
}
function offerGovernance(address newGov) external {
ControllerLib.offerGovernance(newGov);
}
function acceptGovernance() external {
ControllerLib.acceptGovernance();
}
function setStatController(address value) external {
ControllerLib.setStatController(value);
}
function setStoryController(address value) external {
ControllerLib.setStoryController(value);
}
function setGameObjectController(address value) external {
ControllerLib.setGameObjectController(value);
}
function setReinforcementController(address value) external {
ControllerLib.setReinforcementController(value);
}
function setOracle(address value) external {
ControllerLib.setOracle(value);
}
function setTreasury(address value) external {
ControllerLib.setTreasury(value);
}
function setItemController(address value) external {
ControllerLib.setItemController(value);
}
function setHeroController(address value) external {
ControllerLib.setHeroController(value);
}
function setGameToken(address value) external {
ControllerLib.setGameToken(value);
}
function setDungeonFactory(address value) external {
ControllerLib.setDungeonFactory(value);
}
function changeDeployer(address eoa, bool remove) external {
ControllerLib.changeDeployer(eoa, remove);
}
function setUserController(address value) external {
ControllerLib.setUserController(value);
}
function setGuildController(address value) external {
ControllerLib.setGuildController(value);
}
function setPvpController(address value) external {
ControllerLib.setPvpController(value);
}
function setRewardsPool(address value) external {
ControllerLib.setRewardsPool(value);
}
function setItemBoxController(address value) external {
ControllerLib.setItemBoxController(value);
}
function setGameTokenPrice(uint value) external {
ControllerLib.setGameTokenPrice(value);
}
function setGauge(address value) external {
ControllerLib.setGauge(value);
}
//endregion ------------------------ Gov actions - setters
//region ------------------------ Gov actions - others
function updateProxies(address[] memory proxies, address newLogic) external {
ControllerLib.updateProxies(proxies, newLogic);
}
function claimToGovernance(address token) external {
ControllerLib.claimToGovernance(token);
}
//endregion ------------------------ Gov actions - others
//region ------------------------ REGISTER ACTIONS
function changeTreasuryTokenStatus(address token, bool status) external {
ControllerLib.changeTreasuryTokenStatus(token, status);
}
//endregion ------------------------ REGISTER ACTIONS
//region ------------------------ User actions
/// @notice Transfer {amount} from {from}, divide it on three parts: to treasury, to governance, to burn
/// User must approve given amount to the controller.
/// @param amount Assume that this amount is approved by {from} to this contract
function process(address token, uint amount, address from) external {
ControllerLib.process(IController(address(this)), token, amount, from);
}
function percentToBurn(uint totalSupply) external pure returns (uint) {
return ControllerLib.percentToBurn(totalSupply);
}
function getProcessDetails(address token, uint amount) external view returns (uint toBurn, uint toTreasury, uint toGov, uint toRewardsPool) {
(toBurn, toTreasury, toGov, toRewardsPool) = ControllerLib.getProcessDetails(token, amount, IController(address(this)).gameToken());
}
//endregion ------------------------ User 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);
error AlreadyClaimed();
//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();
error NotPvpController();
//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 ErrorNotOwnerOrHero(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();
error TierForbidden();
error SandboxPrepaidOnly();
error SandboxNgZeroOnly();
error SandboxModeNotAllowed();
error SandboxUpgradeModeRequired();
error SandboxModeRequired();
error SandboxItemOutside();
error SandboxItemNotActive();
error SandboxItemNotRegistered();
error SandboxItemAlreadyEquipped();
error SandboxDifferentHeroesNotAllowed();
error HeroWasTransferredBetweenAccounts();
error SandboxFreeHeroNotAllowed();
//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();
error LastLifeChance();
//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();
error ItemNotFound(address item, uint itemId);
error NoFirstAugmentationInfo();
error NotAugmentationProtectiveItem(address item);
//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);
error LevelIsNotEnoughForThisBiome(uint biome, uint lvl);
//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);
error NotSkippableStory();
error StoryNotPassed();
error SkippingNotAllowed();
//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 PvpStaked();
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);
//endregion 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 TooLowGuildLevel();
/// @notice Target biome can be selected only once per epoch
error BiomeAlreadySelected();
error NoDominationRequest();
error PvpFightIsNotPrepared(uint8 biome, uint32 week, address user);
error PvpFightIsCompleted(uint8 biome, uint32 week, address user);
error TooLowMaxCountTurns();
error UserTokensVaultAlreadySet();
error DifferentBiomeInPvpFight();
error PvpFightOpponentNotFound();
error PvpHeroHasInitializedFight();
error PvpHeroNotRegistered();
error PvpWrongDay(uint day);
error PvpWrongTime(uint time);
error ItemAlreadyUsed(address item, uint itemId, address itemHero, uint itemHeroId);
/// @notice User should unregister pvp-hero from prev biome and only then register it in the new biome
error UserHasRegisteredPvpHeroInBiome(uint8 biome);
error UserHasRegisteredPvpHero();
error UserNotAllowedForPvpInCurrentEpoch(uint week);
error UnknownPvpStrategy();
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 AuctionGuildWithShelterCannotBid();
error AuctionBidExists();
//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";
import "./IPvpController.sol";
/// @notice All events of the app
interface IApplicationEvents {
//region ------------------------ Common
event SetOperator(address operator, bool remove);
event Salvage(address receiver, address token, uint amount);
//endregion ------------------------ Common
//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.ActionResultEvent result,
uint currentStage,
address heroToken,
uint heroTokenId,
uint newStage
);
event MarkSkillsUsed(address hero, uint heroId, uint8[] map);
/// @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.ActionResultEvent 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);
/// @notice Deprecated, replaced by {HeroCreatedNgpSandbox}. Don't remove - it's required by subgraph
event HeroCreatedNgp(address hero, uint heroId, string name, address owner, string refCode, uint8 tier, uint8 ngLevel);
event HeroCreatedNgpSandbox(address hero, uint heroId, string name, address owner, string refCode, uint8 tier, uint8 ngLevel, bool sandbox);
event FreeHeroCreated(address hero, uint heroId);
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);
event SandboxUpgraded(address hero, uint heroId);
event SandboxReturnAmountToTreasury(uint64 dungId, address token, uint amount);
//endregion ------------------------ HeroController
//region ------------------------ FightLib
event FightResultProcessed(
address sender,
IFightCalculator.FightInfoInternal result,
IFightCalculator.FightCall callData,
uint iteration
);
/// @param heroA Address of the fighter A. Address of the fighter B can be detected by fightId
/// @param heroIdA ID of the figher A. ID of the fighter B can be detected by fightId
event PvpFightResultProcessed(
uint48 fightId,
address sender,
IFightCalculator.FightInfoInternal result,
uint turn,
address heroA,
uint heroIdA
);
//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 PvpControllerChanged(address value);
event GameTokenPriceChanged(uint value);
event RewardsPoolChanged(address value);
event ItemBoxControllerChanged(address value);
event Process(address token, uint amount, address from, uint toBurn, uint toTreasury, uint toGov);
event GaugeChanged(address gauge);
event NotifyRewardAmount(address token, uint amount);
event UpdatePeriod(uint myrdAmount);
//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, uint64 dungeonId);
event NftRewardRegistered(address heroToken, uint heroId, address token, uint id);
event GuildNftRewardRegistered(address heroToken, uint heroId, address token, uint id, uint guildId, uint64 dungeonId);
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.EventActionInfo 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 ResetAugmentation(address item, uint itemId, uint consumedItemId, 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 SetAugmentationProtectiveItem(address keyPassItem);
event CombineItems(address msgSender, uint configId, address[] items, uint[][] itemIds, address mintedItem, uint mintedItemId);
event RegisterSandboxItem(address hero, uint heroId, address item, uint itemId, uint tsMinting);
event WithdrawItemsFromSandbox(address hero, uint heroId, address[] items, uint[] itemIds);
event ItemReturnedToSandbox(address hero, uint heroId, address item, uint itemId);
event RegisterSandboxUpgrade(address hero, uint heroId, uint tsUpgradng);
event TransferItemToHeroFromSandbox(address hero, uint heroId, address item, uint itemId);
event DestroyItemInSandbox(address item, uint itemId);
event NewItemSentToSandbox(address item, uint itemId);
event ExitFromDungeon(address hero, uint heroId);
//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 RegisterPassedDungeon(address user, uint32 epochWeek, uint counterPassedDungeons);
event RegisterPvp(address user, uint32 epochWeek, uint counterPvp);
event FameHallHeroRegistered(address hero, uint heroId, address heroOwner, uint8 openedNgLevel);
event SetMinHeroLevel(uint level);
event SetGuildStakingAdapter(address adapter);
event AddGamePoints(address user, uint finalBalanceGamePoints);
/// @param paramId See IUserController.UserControllerParam
event SetUserControllerParam(uint8 paramId, uint paramValue);
event UseGamePointsToSkipStory(address user, uint16 storyId, uint priceInGamePoints, uint finalBalanceGamePoints);
event SetStoryPassed(address user, uint16 storyId);
//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 GuildBannerChanged(uint guildId, string newBanner);
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 TransferOwnership(address prevOwner, address newOwner);
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 ------------------------ Pvp
event AddBiomeRequest(address user, uint8 biome, uint guildId, uint32 week);
event PvpHeroAdded(address user, uint guildId, address hero, uint heroId, uint week, uint8 biome);
/// @param manuallyRemoved True - removed manually by the user, false - removed automatically after the fight
event PvpHeroRemoved(address user, uint guildId, uint week, uint8 biome, address hero, uint heroId, bool manuallyRemoved);
event PreparePvpFight(uint48 fightId, uint32 week, address hero, uint heroId, uint heroGuildId, address opponentHero, uint opponentHeroId, uint opponentGuildId);
/// @notice heroId can be detected by {fightId} and {heroes}
event PvpFightCompleted(
IPvpController.PvpFightResults fightResult,
uint48 fightId,
address[2] heroes,
uint64[2] guilds,
bool[2] winners,
uint[2] prizes,
bool technicalDefeat
);
event UpdatePvpEpoch(uint8 biome, uint32 week, uint guildBiomeOwnerId);
event FirstPvpEpoch(uint8 biome, uint32 week);
event BiomeTaxPaid(address msgSender, uint8 biome, uint guildId, uint amount, uint taxPercent, uint taxAmount, uint64 dungeonId);
event BiomeTaxPaidNft(address msgSender, uint8 biome, uint guildId, address item, uint itemId, uint taxPercent, uint64 dungeonId);
event AddPvpFightItems(uint48 fightId, address[] items, uint[] itemIds);
//endregion ------------------------ Pvp
//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);
event ApplyAuctionBid(uint bidId, address msgSender);
event AuctionSetFee(uint fee);
//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
//region ------------------------ Airdrop Distributor
event AirdropDistributorSetToken(address token);
event AirdropDistributorAddTree(uint week, bytes32 merkleRoot_);
event AirdropDistributorRemoveTree(uint week);
event AirdropDistributorClaim(uint[] _weeks, uint[] amounts, address receiver);
//endregion ------------------------ Airdrop Distributor
//region ------------------------ GuildStakingManager
event SetStakingToken(address token);
event StakeTokens(address token, uint amount, uint guildId, uint total);
//endregion ------------------------ GuildStakingManager
}// 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 pvpController() external view returns (address);
function rewardsPool() external view returns (address);
function itemBoxController() external view returns (address);
function gameTokenPrice() external view returns (uint);
function process(address token, uint amount, address from) external;
function gauge() external view returns (address);
}// 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;
/// @notice NG_LEVEL of the hero that has created the given dungeon
mapping(uint64 dungeonId => uint ngLevel) dungeonNgLevel;
}
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 ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: 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: MIT
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}// 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;
}
/// @notice Additional info passed to fight
struct FightCallAdd {
address msgSender;
/// @notice Unique ID of the pvp-fight, 0 for not pvp fights
uint48 fightId;
}
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 "./IERC20.sol";
interface IGameToken is IERC20 {
function minter() external view returns (address);
function mint(address account, uint amount) external returns (bool);
function burn(uint amount) external returns (bool);
function setMinter(address minter_) external;
function pause(bool value) external;
}// 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,
STORY_ASCRA_36,
STORY_ASCRA_RARE_37,
STORY_BANFOOT_38,
STORY_BANFOOT_RARE_39,
STORY_ENFITILIA_40,
STORY_ENFITILIA_RARE_41,
ENEMY_NPC_ASCRA_42,
ENEMY_NPC_ASCRA_RARE_43,
ENEMY_NPC_BANFOOT_44,
ENEMY_NPC_BANFOOT_RARE_45,
ENEMY_NPC_ENFITILA_46,
ENEMY_NPC_ENFITILA_RARE_47,
STORY_FREE_LAND_48,
STORY_GAME_THEORY_49,
STORY_WEARY_50,
STORY_EXHAUSTED_51,
STORY_TRAPPED_52,
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;
uint32[] mintItemsMF;
int32 heal;
int32 manaRegen;
int32 lifeChancesRecovered;
int32 damage;
int32 manaConsumed;
uint32 objectId;
uint32 experience;
uint heroTokenId;
uint iteration;
uint32[] rewriteNextObject;
}
struct ActionResultEvent {
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,
DOMINATION_REQUEST_13
}
enum GuildsParams {
NONE_0,
COUNTER_GUILD_IDS_1,
BASE_FEE_2,
COUNTER_GUILD_REQUESTS_3,
REENTRANT_STATUS_4,
SHELTER_CONTROLLER_5,
SHELTER_AUCTION_6
// max 255 params because enum is uint8 by default
}
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;
/// @notice guild id => guildBanner
mapping(uint guildId => string) guildBanner;
}
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 isPeacefulRelation(uint guildId, uint guildId2) external view returns (bool);
function incPvpCounter(uint guildId, uint64 value) external;
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;
/// @notice 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 Sandbox mode for heroes, see SCR-1153
mapping(bytes32 packedHero => SandboxMode sandboxMode) sandbox;
/// @notice List of packed skill-tokens equipped on the helper at the moment of asking him for help by the hero
/// @dev Packed skill contains item address, item id and slot number (use unpackNftIdWithValue)
/// Size of the array can be 0..3
mapping(bytes32 packedHero => bytes32[] packedSkills) helperSkills;
}
/// @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
/// @dev Only post-paid hero has tier = 0
/// @dev Only free-hero has paidToken != 0 && paidAmount == 0
struct HeroInfo {
/// @notice Hero tier = [0..3].
/// 0 - the hero is post-paid, it can be changed by upgrading the hero to pre-paid
/// always 1 for sandbox-heroes
/// always 1 for free-heroes
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
/// Zero for sandbox-heroes and for free-heroes
uint72 paidAmount;
/// @notice Pay token used to pay {paidAmount}
/// Zero for sandbox-heroes
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;
/// @notice SCR-1153: create not-paid hero with limited rights
bool sandboxMode;
}
enum SandboxMode {
/// @notice The hero is created in normal (not sandbox) mode
NORMAL_MODE_0,
/// @notice The hero was created in sandbox mode and wasn't upgraded.
SANDBOX_MODE_1,
/// @notice The hero was created in sandbox mode and was upgraded to the normal mode
UPGRADED_TO_NORMAL_2
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
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);
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);
function sandboxMode(address hero, uint heroId) external view returns (uint8);
function helperSkills(address hero, uint heroId) external view returns (
address[] memory items,
uint[] memory itemIds,
uint[] memory slots
);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.23;
import "../openzeppelin/EnumerableSet.sol";
import "../openzeppelin/EnumerableMap.sol";
interface IItemBoxController {
/// @custom:storage-location erc7201:ItemBox.controller.main
struct MainState {
mapping(bytes32 packedHero => HeroData) heroData;
/// @notice Owners of all items minted in sandbox mode
mapping(bytes32 packedItem => bytes32 packedHero) heroes;
}
struct HeroData {
/// @notice Moment of upgrading sandbox-hero to normal-hero
uint tsUpgraded;
/// @notice List of all items registered for the hero
EnumerableSet.AddressSet items;
/// @notice item => (itemId => packedItemBoxItemInfo)
/// @dev Ids are never deleted from the map, so the order of ids is never changed
mapping(address item => EnumerableMap.UintToUintMap) states;
}
struct ItemBoxItemInfo {
/// @notice True if the item was withdrawn from balance
/// It can happens in follow cases:
/// 1) the hero was upgraded and the item was withdrawn on hero owner balance
/// 2) the item is used by ItemController:
/// 2.1) the item is equipped on the hero and so it's transferred to the hero balance
/// 2.2) the consumable item is used
/// 3) the item is burnt
/// @dev Status is required to avoid deletion (and so changing order) of the {items}
bool withdrawn;
/// @notice The moment of the initial item minting
uint64 timestamp;
}
enum ItemState {
/// @notice The item was never registered in the sandbox
NOT_REGISTERED_0,
/// @notice The item is not active (outdated) and cannot be used anymore
NOT_AVAILABLE_1,
/// @notice The item is active and located inside the sandbox
INSIDE_2,
/// @notice The item is either withdrawn or equipped
OUTSIDE_3
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function firstActiveItemOfHeroByIndex(address hero, uint heroId, address item) external view returns (uint itemId);
function registerItems(address hero, uint heroId, address[] memory items, uint[] memory itemIds, uint countValidItems) external;
function itemState(address hero, uint heroId, address item, uint itemId) external view returns (IItemBoxController.ItemState);
function itemHero(address item, uint itemId) external view returns (address hero, uint heroId);
function registerSandboxUpgrade(bytes32 packedHero) external;
function transferToHero(address hero, uint heroId, address item, uint itemId) external;
function destroyItem(address item, uint itemId) external;
}// 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;
/// --------------------------------- SCR-1263: Reverse-augmentation
/// @notice Item attributes values before first augmentation.
/// @dev SCR-1263: The values are required in augmentation if protective item is used and the augmentation is failed.
mapping(bytes32 packedItem => ResetAugmentationData) _resetAugmentation;
}
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 OTHER_5 Rest in the shelter: restore of hp & mp, clear temporally attributes, clear used consumables (shelter of level 3 is required)
/// @dev It's OTHER_5 in deploy script, but internally it has subtype 4, see gen_others.ts
REST_IN_SHELTER_4,
/// @notice OTHER_4 Stub item that has no logic in contracts, but it has correct (not empty) packedMetaData
/// @dev It's OTHER_4 in deploy script, but internally it has subtype 5, see gen_others.ts
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"
struct AugmentOptParams {
/// @notice Optional protective item
/// @dev SCR-1263: If the protective item specified
/// than failed augmentation doesn't destroy main item but reduces its augmentation level to the zero instead.
/// Protective item is configured in ItemControllerHelper.
address protectiveItem;
uint protectiveItemId;
}
struct ResetAugmentationData {
/// @notice Moment of the first augmentation if any
uint tsFirstAugmentation;
/// @notice Values of the item attributes before the first augmentation
/// @dev Use PackingLib.toInt32ArrayWithIds to decode attribute ids and values
bytes32[] itemAttributes;
/// @notice Values of the caster attributes before the first augmentation
/// @dev Use PackingLib.toInt32ArrayWithIds to decode attribute ids and values
bytes32[] itemCasterAttributes;
/// @notice Values of the target attributes before the first augmentation
/// @dev Use PackingLib.toInt32ArrayWithIds to decode attribute ids and values
bytes32[] itemTargetAttributes;
/// @notice packed AttackInfo: attackType8 + min32 + max32 + factors(packed core 128)
bytes32 itemAttackInfo;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
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, uint32 magicFind) 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;
function itemControllerHelper() external view returns (address);
}// 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;
interface IProxyControlled {
function upgrade(address newImplementation_) external;
function implementation() external view returns (address);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.23;
import "../openzeppelin/EnumerableSet.sol";
import "../openzeppelin/EnumerableMap.sol";
import "./IFightCalculator.sol";
interface IPvpController {
enum PvpParams {
NONE_0,
/// @notice Hero can be pvp-staked if his level is greater of equal to the given min level
MIN_HERO_LEVEL_1,
/// @notice Address of IGuildStakingAdapter, can be not initialized
GUILD_STAKING_ADAPTER_2,
/// @notice Unique ID of the pvp-fight (each pvp-fight consists from multiple turns)
FIGHT_COUNTER_3
// max 255 params because enum is uint8 by default
}
/// @custom:storage-location erc7201:pvp.controller.main
struct MainState {
/// @notice Mapping to store various params of PvpController
mapping(PvpParams param => uint value) pvpParam;
/// @notice Current states of biomes
mapping(uint8 biome => BiomeData) biomeState;
/// @notice Biomes owned by the guilds
mapping(uint guildId => uint8 biome) ownedBiome;
mapping(uint epochWeek => EpochData) epochData;
/// @dev week => item => hero+heroId
mapping(uint32 week => mapping(bytes32 itemPacked => bytes32)) usedItems;
}
struct EpochData {
/// @notice Current state of the user in the current epoch
mapping (address user => PvpUserState) pvpUserState;
/// @notice biome data for the given epoch
mapping(uint8 biome => EpochBiomeData) epochBiomeData;
/// @notice All prepared pvp-fights for the given user
/// Index of currently active fight is stored in {pvpUserState.activeFightIndex1}
mapping (address user => PvpFightData[]) fightData;
/// @notice All currently registered packed-heroes
EnumerableSet.UintSet stakedHeroes;
/// @notice Weekly request of the guild to dominate at the given biome starting from the next week
mapping(uint guildId => uint8 biome) targetBiome;
/// @notice All guilds pretend for the given biome
mapping(uint8 biome => EnumerableSet.UintSet guildIds) biomeGuilds;
}
/// @notice Current state of the user. Possible states: user has or hasn't staked a hero in pvp.
/// Each user is able to stake pvp-heroes multiple times per epoch
/// but the user is able to stake only 1 pvp-hero at any moment.
/// @dev Implementation assumes that the struct occupies single slot, the struct is read as a whole
struct PvpUserState {
/// @notice Domination biome at the moment of staking
/// @dev not 0 if the user has pvp-staked hero
uint8 biome;
/// @notice 1-based index of currently active fight in {fightData} (the fight is either prepared or in-progress).
/// 0 - there is no active fight
uint32 activeFightIndex1;
/// @notice How many times the user has staked heroes for PVP
/// @dev Max possible value is limited by MAX_NUMBER_STAKES_FOR_USER_PER_EPOCH
uint32 numHeroesStaked;
/// @notice User's guild at the moment of staking
/// 0 if user has no hero staked in pvp currently
uint64 guildId;
/// @notice Total number of pvp-fights performed since the last call of addPvpHero.
/// @dev All pvp-fights are won here because looser is auto removed.
uint8 countFights;
/// @notice Max number of pvp-fights allowed by the user per single call of addPvpHero, 0 - no limits
uint8 maxFights;
/// @notice Unique id of the current pvp-fight (the fight with activeFightIndex1)
uint48 fightId;
}
struct BiomeData {
/// @notice Biome owner - the guild that dominates in the biome at the given epoch. He has a right to get a tax
/// @dev Assume here that uint64 is enough to store any guildId. It allows us to store whole struct in a single slot
uint64 guildBiomeOwnerId;
/// @notice Current epoch (last epoch for which pvp-battle was made)
/// 0 if epoch was never started
uint32 startedEpochWeek;
/// @notice Number of consecutive epochs during which {guildBiomeOwnerId} wasn't changed
uint16 dominationCounter;
}
struct EpochBiomeData {
/// @notice List of guilds asked for domination in the biome => total points scored by the guilds in the given epoch
/// @dev guildId => count points
EnumerableMap.UintToUintMap guildPoints;
/// @notice All users free for pvp-fight
/// User is added here on registration and removed as soon as the fight for the user is initialized.
mapping(uint guildId => EnumerableSet.AddressSet) freeUsers;
/// @notice All users (from the {guilds}) provided heroes for pvp
/// @dev guildId => (user address => packedHero (hero + heroId))
mapping(uint guildId => EnumerableMap.AddressToUintMap) registeredHeroes;
/// @notice The skills and attack type selected in advance
mapping(bytes32 packedHero => bytes) pvpStrategy;
}
enum PvpFightStatus {
/// @notice No fight, the hero doesn't have selected opponent
NOT_INITIALIZED_0,
/// @notice The hero has opponent, the fight is not started
PREPARED_1,
/// @notice The fight is started but not completed
FIGHTING_2,
/// @notice The fight is completed, the hero is the winner
WINNER_3,
/// @notice The fight is completed, the hero is the looser
LOSER_4
}
/// @notice Current state of the fight
/// @dev Implementation assumes that the struct occupies single slot, the struct is read as a whole
/// @dev We don't store biome and guildId here. This info is stored in user state and can be lost after fight ending.
struct PvpFightData {
/// @notice address of user whose hero is the fight opponent
address fightOpponent;
/// @notice Current status of PVP-fight
PvpFightStatus fightStatus;
/// @notice Current value of the health (only when fightStatus is FIGHTING_2)
uint32 health;
/// @notice Current value of the mana (only when fightStatus is FIGHTING_2)
uint32 mana;
/// @notice Number of moves made (only when fightStatus is FIGHTING_2)
uint8 countTurns;
}
/// @dev Implementation assumes that the struct occupies single slot, the struct is read as a whole
struct PvpFightResults {
bool completed;
uint8 totalCountFights;
uint32 healthHero;
uint32 healthOpponent;
uint32 manaConsumedHero;
uint32 manaConsumedOpponent;
}
/// @notice Strategy how to use attack info
enum PvpBehaviourStrategyKinds {
/// @notice Use all skills, use magic attack if it's available
/// @dev {PvpStrategyDefault} is used as data in {addPvpHero}
DEFAULT_STRATEGY_0
// new strategies are able to use different structures to store data passed to {addPvpHero}
}
/// @notice The data provided by user at the staking with {DEFAULT_STRATEGY_0}
struct PvpStrategyDefault {
/// @notice Should be equal to DEFAULT_STRATEGY_0
uint behaviourStrategyKind;
IFightCalculator.AttackInfo attackInfo;
}
struct HeroData {
address hero;
uint heroId;
bytes pvpStrategy;
}
/// ------------------------------------------------------------------------------------------------------------------
/// ------------------------------------------------------------------------------------------------------------------
/// ------------------------------------------------------------------------------------------------------------------
/// @notice Update epoch if necessary and return actual biome owner and tax
/// @return guildId Owner of the biome
/// @return taxPercent Tax percent , [0...100_000], decimals 3
function refreshBiomeTax(uint8 biome) external returns (uint guildId, uint taxPercent);
function isHeroStakedCurrently(address hero, uint heroId) external view returns (bool staked);
function onGuildDeletion(uint guildId) external;
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.23;
import "./IStatController.sol";
import "../openzeppelin/EnumerableMap.sol";
/// @notice Terms
/// Reinforcement v1: helper is selected randomly in askHero, fixed part of rewards (tokens and NFT) is sent to the helper.
/// Guild reinforcement: helper is selected from guild heroes. Rewards are sent to guild bank.
/// Reinforcement v2: helper is selected manually in askHeroV2, helper receives fixed amount.
interface IReinforcementController {
enum ConfigParams {
/// @notice Packed MinMaxBoardV2
V2_MIN_MAX_BOARD_0
}
/// @custom:storage-location erc7201:reinforcement.controller.main
struct MainState {
// ------------------------ Reinforcement v1
/// @dev minLvl8 + minLifeChances8
bytes32 config;
/// @dev hero token + hero id => heroInfo(biome8 + score128 + fee8 + stakeTs64)
mapping(bytes32 => bytes32) _stakedHeroes;
/// @dev biome => helperAdr+id
mapping(uint => EnumerableSet.Bytes32Set) _internalIdsByBiomes;
/// @dev biome => score // The field is deprecated and not updated any more
mapping(uint => uint) maxScore;
/// @dev heroAdr+id => itemAdr+id
mapping(bytes32 => bytes32[]) _heroNftRewards;
/// @dev heroAdr+id => tokenAdr and amount map
mapping(bytes32 => EnumerableMap.AddressToUintMap) _heroTokenRewards;
// ------------------------ Guild reinforcement
/// @notice All staked guild heroes for the given guild
/// @dev helper (hero token + hero id) => guild
mapping(bytes32 packedHero => uint guildId) stakedGuildHeroes;
/// @notice All guild heroes that are currently in use by guild reinforcement
/// It's allowed to withdraw a hero before reinforcement releasing,
/// so it's possible to have !0 in {guildBusyHelpers} and 0 in {stakedGuildHeroes} simultaneously.
/// @dev helper (hero token + hero id) => guildId (guild at the moment of askGuildReinforcement)
mapping(bytes32 packedHero => uint guildId) busyGuildHelpers;
/// @notice All (free and busy) staked guild heroes per guild.
/// guild => (packed helper => guild where the helper is busy currently)
/// @dev There is a chance that guilds are different here
/// i.e. hero can be:
/// 1) added to G1 2) staked in G1 3) asked for help 4) withdrawn 5) G1=>G2 6) staked in G2
/// In such case guildHelpers[G2][hero] = G1, guildHelpers[G1][hero] = 0
/// After releasing guildHelpers[G2][hero] = 0
mapping(uint guildId => EnumerableMap.Bytes32ToUintMap) guildHelpers;
/// @notice Moment of withdrawing the hero from staking. Next staking is possible in 1 day since withdrawing
mapping(bytes32 packedHero => uint lastWithdrawTimestamp) lastGuildHeroWithdrawTs;
// ------------------------ Reinforcement v2
/// @notice Map to store various config params
mapping(ConfigParams paramId => uint) configParams;
mapping(bytes32 packedHero => HeroInfoV2) stakedHeroesV2;
/// @notice biome => set of packedHero. All staked heroes (they can be busy of free currently)
mapping(uint biome => EnumerableSet.Bytes32Set) heroesByBiomeV2;
mapping(uint biome => LastWindowsV2) stat24hV2;
}
/// @notice Deprecated. Reinforcement v1
struct HeroInfo {
uint8 biome;
uint score; // stored in 128 but easy to use 256
/// @notice To helper ratio
uint8 fee;
uint64 stakeTs;
}
struct HeroInfoV2 {
uint8 biome;
uint64 stakeTs;
/// @notice Amount of game token that is paid to the helper at the moment of the call {askHeroV2}
uint128 rewardAmount;
}
/// @notice Statistic of askHeroV2 calls per last 24 hours at the moment of the last call
struct LastWindowsV2 {
/// @notice 24 hours are divided on 8 intervals, each interval is 3 hour
/// Current basket has index {basketIndex}
/// {baskets[current basket]} contains "old" value.
/// New value for the current basket is collected in {basketValue}.
/// The value for the current basket is calculated as weighted average of old and new values.
/// New value replaces the old value at the moment of changing current basket index.
uint24[8] baskets;
/// @notice New value (hits counter) for current basket
uint24 basketValue;
/// @notice Abs. index of the current basket (abs. hour / 3)
uint48 basketIndex;
}
/// @dev 1 slot
struct ConfigReinforcementV2 {
/// @notice if Number-of-askHeroV2-calls is below given value then burn fee has min value
uint32 minNumberHits;
/// @notice if Number-of-askHeroV2-calls is above given value then burn fee has max value
uint32 maxNumberHits;
/// @notice Lowest fee = amountForDungeon / given value, i.e. 100 => amountForDungeon/100 as lower fee
uint32 lowDivider;
/// @notice Highest fee = amountForDungeon / given value, i.e. 2 => amountForDungeon/2 as highest fee
uint32 highDivider;
/// @notice Limit for min level of the staked hero
/// In practice we need following limitation: (stats.level < 5 || (stats.level - 5) / 5 < biome)
/// so, levelLimit should be equal 5
/// In tests we need to be able to disable such limitation, so levelLimit = 0 allow to disable that constraint
uint8 levelLimit;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function toHelperRatio(address heroToken, uint heroId) external view returns (uint);
function isStaked(address heroToken, uint heroId) external view returns (bool);
function registerTokenReward(address heroToken, uint heroId, address token, uint amount, uint64 dungeonId) external;
function registerNftReward(address heroToken, uint heroId, address token, uint tokenId, uint64 dungeonId) external;
function askHeroV2(address hero, uint heroId, address helper, uint helperId) external returns (int32[] memory attributes);
function askGuildHero(address hero, uint heroId, address helper, uint helperId) external returns (int32[] memory attributes);
/// @notice Return the guild in which the hero is currently asked for guild reinforcement
function busyGuildHelperOf(address heroToken, uint heroId) external view returns (uint guildId);
function releaseGuildHero(address helperHeroToken, uint helperHeroTokenId) external;
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.23;
interface IRewardsPool {
/// @custom:storage-location erc7201:rewards.pool.main
struct MainState {
mapping(address token => uint baseAmountValue) baseAmounts;
}
function balanceOfToken(address token) external view returns (uint);
function rewardAmount(address token, uint maxBiome, uint maxNgLevel, uint biome, uint heroNgLevel) external view returns (uint);
function sendReward(address token, uint rewardAmount_, address receiver) external;
function lostProfitPercent(uint maxBiome, uint maxNgLevel, uint heroNgLevel) external view returns (uint percent);
}// 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 a better 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 EventActionInfo {
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/IItemController.sol";
import "../interfaces/IStatController.sol";
import "../lib/ControllerContextLib.sol";
import "../openzeppelin/EnumerableSet.sol";
import "./IController.sol";
import "./IHeroController.sol";
import "./IOracle.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;
/// @notice True if the story is allowed to be skipped, see SCR-1248
EnumerableSet.UintSet skippableStory;
}
/// @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;
IOracle oracle;
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);
function skippableStory(uint16 storyId) external view returns (bool);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.23;
import "./IItemController.sol";
interface ITreasury {
function balanceOfToken(address token) external view returns (uint);
function sendToDungeon(address dungeon, address token, uint amount) external;
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.23;
import "../openzeppelin/EnumerableSet.sol";
interface IUserController {
//region ------------------------ Data types
enum LootBoxKind {
/// @notice small loot box - reward for the daily activity
DAILY_0,
/// @notice large loot box - reward for the weekly activity (daily activity is passed each ot of the 7 days)
WEEKLY_1,
END_SLOT
}
/// @dev registerPassedDungeon assumes that the whole struct takes single slot only, not more
struct UserActivity {
/// @notice A day for which the daily activity is calculated (see counterXXX below)
/// The number of days since 1970-01-01
uint32 epochDay;
/// @notice A week for which total count of daily activities were calculated
/// The number of weeks since (1970-01-01 Thursday) - 3 days = (1969-12-29 Monday)
uint32 epochWeek;
/// @notice Count of dungeons passed during the day
uint32 counterPassedDungeons;
/// @notice Count of PvP during the day
uint32 counterPvp;
/// @notice Count of daily activities completed per the week
uint16 dailyActivities;
/// @notice Daily activity is completed and small loot box is added to the earned loot boxes
bool dailyLootBoxReceived;
/// @notice Weekly activity is completed and large loot box is added to the earned loot boxes
bool weeklyLootBoxReceived;
}
struct EarnedLootBoxes {
/// @notice Count of loot boxes earned by daily activity
uint32 dailyCounter;
/// @notice Count of loot boxes earned by weekly activity
uint32 weeklyCounter;
}
struct LootBoxConfig {
address[] mintItems;
uint32[] mintItemsChances;
uint maxDropItems;
}
enum UserControllerParam {
/// @notice Price of story skipping in game points
PRICE_STORY_SKIPPING_1
}
/// @custom:storage-location erc7201:user.controller.main
struct MainState {
/// @notice Amount of sacra required to rename user account
uint feeRenaming;
/// @dev user EOA => account name
mapping(address => string) userAccountName;
/// @dev name => user EOA, needs for checking uniq names
mapping(string => address) nameToUserAccount;
/// @notice user => daily activity info
mapping(address => UserActivity) userActivity;
/// @notice user => earned loot boxes
mapping(address => EarnedLootBoxes) counterLootBoxes;
/// @notice Configs of loot boxes of various kinds
mapping(LootBoxKind => LootBoxConfig) lootBoxConfig;
/// @dev Deprecated, controller is used instead.
address userTokensVault;
/// @dev user EOA => account avatar
mapping(address => string) userAvatar;
// @notice Hall of Fame: ngLevel [1...99] => who opened the NG_LEVEL first
mapping(uint8 ngLevel => FameHallData) fameHall;
/// @notice Points earned for passing dungeons
mapping(address user => uint gamePoints) gamePoints;
/// @notice List of objects (currently only stories) passed by the given account
/// @dev hashes of the stories are as encodePacked("STORY_{ID}")
mapping(address user => EnumerableSet.Bytes32Set hashes) passedObjects;
/// @notice Values of various params, see {UserControllerParam}
mapping(UserControllerParam paramId => uint value) userControllerParams;
}
struct FameHallData {
// ------------ slot 1
/// @notice The hero who opened given the NG_LEVEL first
address hero;
uint64 heroId;
// ------------ slot 2
/// @notice The owner of the hero
address heroOwner;
/// @notice Timestamp of the moment of the opening given NG_LEVEL
uint64 tsOpen;
}
//endregion ------------------------ Data types
/// @notice Register daily activity - a dungeon was passed
/// @param user Owner of the hero who has passed the dungeon
function registerPassedDungeon(address user) external;
/// @notice Register daily activity - PvP was made
/// @param user Owner of the hero who has taken participation in the PvP
function registerPvP(address user, bool isWinner) external;
function registerFameHallHero(address hero, uint heroId, uint8 openedNgLevel) external;
function useGamePointsToSkipStore(address user, uint16 storyId) external;
function setStoryPassed(address user, uint16 storyId) external;
function isStoryPassed(address user, uint16 storyId) external view returns (bool);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.23;
/// @notice Restored from 0x889677E6d07D22a53dac907d204ecBB08E38B529 (sonic)
interface IXMyrdGauge {
function CONTROLLABLE_VERSION() external view returns (string memory);
function MULTI_POOL_VERSION() external view returns (string memory);
function REWARDS_PERIOD() external view returns (uint256);
function VERSION() external view returns (string memory);
function activePeriod() external view returns (uint256);
function addStakingToken(address) external pure;
function balanceOf(address, address) external view returns (uint256);
function controller() external view returns (address);
function created() external view returns (uint256);
function createdBlock() external view returns (uint256);
function defaultRewardToken() external view returns (address);
function derivedBalance(address stakingToken, address account) external view returns (uint256);
function derivedBalances(address, address) external view returns (uint256);
function derivedSupply(address) external view returns (uint256);
function duration() external view returns (uint256);
function earned(address stakingToken, address rewardToken, address account) external view returns (uint256);
function getAllRewards(address account) external;
function getPeriod() external view returns (uint256);
function getReward(address account, address[] memory tokens) external;
function handleBalanceChange(address account) external;
function increaseRevision(address oldLogic) external;
function init(address controller_, address xMyrd_, address myrd_ ) external;
function isController(address value_) external view returns (bool);
function isGovernance(address value_) external view returns (bool);
function isRewardToken(address, address) external view returns (bool);
function isStakeToken(address token) external view returns (bool);
function lastTimeRewardApplicable(address stakingToken, address rewardToken) external view returns (uint256);
function lastUpdateTime(address, address) external view returns (uint256);
function left(address stakingToken, address rewardToken) external view returns (uint256);
function notifyRewardAmount(address token, uint256 amount) external;
function periodFinish(address, address) external view returns (uint256);
function previousImplementation() external view returns (address);
function registerRewardToken(address stakeToken, address rewardToken) external;
function removeRewardToken(address stakeToken, address rewardToken) external;
function revision() external view returns (uint256);
function rewardPerToken(address stakingToken, address rewardToken) external view returns (uint256);
function rewardPerTokenStored(address, address) external view returns (uint256);
function rewardRate(address, address) external view returns (uint256);
function rewardTokens(address, uint256) external view returns (address);
function rewardTokensLength(address token) external view returns (uint256);
function rewards(address, address, address) external view returns (uint256);
function rewardsRedirect(address) external view returns (address);
function setRewardsRedirect(address account, address recipient) external;
function totalSupply(address) external view returns (uint256);
function updatePeriod(uint256 amount_) external;
function userRewardPerTokenPaid(address, address, address) external view returns (uint256);
function xMyrd() external view returns (address);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.23;
import "../interfaces/IERC20.sol";
import "../interfaces/IERC721.sol";
/// @notice Common internal utils, shared constants
library AppLib {
/// @notice Biome owner has the right to receive 1% tax on any income in the biome. Decimals 3.
/// The final value of tax is in the range [1..10]%, it depends on total liquidity staked by the guild
uint internal constant BIOME_TAX_PERCENT_MIN = 1_000; // 1%
/// @notice Max possible value of biome owner tax percent, decimals 3.
uint internal constant BIOME_TAX_PERCENT_MAX = 10_000; // 10%
/// @notice Make infinite approve of {token} to {spender} if the approved amount is less than {amount}
/// @dev Should NOT be used for third-party pools
function approveIfNeeded(address token, uint amount, address spender) internal {
if (IERC20(token).allowance(address(this), spender) < amount) {
IERC20(token).approve(spender, type(uint).max);
}
}
/// @dev Remove from array the item with given id and move the last item on it place
/// Use with mapping for keeping indexes in correct ordering
function removeIndexed(
uint256[] storage array,
mapping(uint256 => uint256) storage indexes,
uint256 id
) internal {
uint256 lastId = array[array.length - 1];
uint256 index = indexes[id];
indexes[lastId] = index;
indexes[id] = type(uint256).max;
array[index] = lastId;
array.pop();
}
/// @notice Return a-b OR zero if a < b
function sub0(uint32 a, uint32 b) internal pure returns (uint32) {
return a > b ? a - b : 0;
}
/// @notice Adjust the dungeon completion reward based on the hero's NG level
function _getAdjustedReward(uint amount, uint heroNgLevel) internal pure returns (uint) {
uint rewardPercent = heroNgLevel == 0
? 40
: heroNgLevel == 1
? 60
: heroNgLevel == 2
? 80
: 100;
return amount * rewardPercent / 100;
}
function _ownerOf(address hero, uint heroId) internal view returns (address) {
return IERC721(hero).ownerOf(heroId);
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.23;
import "../interfaces/IController.sol";
import "../interfaces/IOracle.sol";
import "../interfaces/IStatController.sol";
import "../interfaces/IStoryController.sol";
import "../interfaces/ITreasury.sol";
import "../interfaces/IDungeonFactory.sol";
import "../interfaces/IReinforcementController.sol";
import "../interfaces/IGameToken.sol";
import "../interfaces/IGOC.sol";
import "../interfaces/IItemController.sol";
import "../interfaces/IHeroController.sol";
import "../interfaces/IUserController.sol";
import "../interfaces/IGuildController.sol";
import "../interfaces/IRewardsPool.sol";
import "../interfaces/IPvpController.sol";
import "../interfaces/IItemBoxController.sol";
/// @notice Provide context-struct with all controller addresses and routines for lazy init
/// Usage:
/// Create an instance of the structure
/// cc = ControllerContextLib.init(controller);
/// access controller directly
/// cc.controller.xxx();
/// access other contracts indirectly
/// sc = ControllerContextLib.statController(cc);
library ControllerContextLib {
//region ----------------- Data types
enum CacheIndex {
STAT_CONTROLLER_0,
STORY_CONTROLLER_1,
ORACLE_2,
TREASURY_3,
DUNGEON_FACTORY_4,
GOC_5,
REINFORCEMENT_CONTROLLER_6,
ITEM_CONTROLLER_7,
HERO_CONTROLLER_8,
GAME_TOKEN_9,
USER_CONTROLLER_10,
GUILD_CONTROLLER_11,
PVP_CONTROLLER_12,
REWARDS_POOL_13,
ITEM_BOX_CONTROLLER_14
}
uint constant private CACHE_SIZE = 15;
struct ControllerContext {
/// @notice Direct access to the controller
IController controller;
/// @notice All lazy-initialized addresses in order of {CacheIndex}
address[CACHE_SIZE] cache;
}
//endregion ----------------- Data types
//region ----------------- Initialization and _lazyInit
function init(IController controller) internal pure returns (ControllerContext memory cc) {
cc.controller = controller;
return cc;
}
function _lazyInit(
ControllerContext memory cc,
CacheIndex index,
function () external view returns(address) getter
) internal view returns (address) {
address a = cc.cache[uint(index)];
if (a != address(0)) return a;
cc.cache[uint(index)] = getter();
return cc.cache[uint(index)];
}
//endregion ----------------- Initialization and _lazyInit
//region ----------------- Access with lazy initialization
function statController(ControllerContext memory cc) internal view returns (IStatController) {
return IStatController(_lazyInit(cc, CacheIndex.STAT_CONTROLLER_0, cc.controller.statController));
}
function storyController(ControllerContext memory cc) internal view returns (IStoryController) {
return IStoryController(_lazyInit(cc, CacheIndex.STORY_CONTROLLER_1, cc.controller.storyController));
}
function oracle(ControllerContext memory cc) internal view returns (IOracle) {
return IOracle(_lazyInit(cc, CacheIndex.ORACLE_2, cc.controller.oracle));
}
function treasury(ControllerContext memory cc) internal view returns (ITreasury) {
return ITreasury(_lazyInit(cc, CacheIndex.TREASURY_3, cc.controller.treasury));
}
function dungeonFactory(ControllerContext memory cc) internal view returns (IDungeonFactory) {
return IDungeonFactory(_lazyInit(cc, CacheIndex.DUNGEON_FACTORY_4, cc.controller.dungeonFactory));
}
function gameObjectController(ControllerContext memory cc) internal view returns (IGOC) {
return IGOC(_lazyInit(cc, CacheIndex.GOC_5, cc.controller.gameObjectController));
}
function reinforcementController(ControllerContext memory cc) internal view returns (IReinforcementController) {
return IReinforcementController(_lazyInit(cc, CacheIndex.REINFORCEMENT_CONTROLLER_6, cc.controller.reinforcementController));
}
function itemController(ControllerContext memory cc) internal view returns (IItemController) {
return IItemController(_lazyInit(cc, CacheIndex.ITEM_CONTROLLER_7, cc.controller.itemController));
}
function heroController(ControllerContext memory cc) internal view returns (IHeroController) {
return IHeroController(_lazyInit(cc, CacheIndex.HERO_CONTROLLER_8, cc.controller.heroController));
}
function gameToken(ControllerContext memory cc) internal view returns (IGameToken) {
return IGameToken(_lazyInit(cc, CacheIndex.GAME_TOKEN_9, cc.controller.gameToken));
}
function userController(ControllerContext memory cc) internal view returns (IUserController) {
return IUserController(_lazyInit(cc, CacheIndex.USER_CONTROLLER_10, cc.controller.userController));
}
function guildController(ControllerContext memory cc) internal view returns (IGuildController) {
return IGuildController(_lazyInit(cc, CacheIndex.GUILD_CONTROLLER_11, cc.controller.guildController));
}
function pvpController(ControllerContext memory cc) internal view returns (IPvpController) {
return IPvpController(_lazyInit(cc, CacheIndex.PVP_CONTROLLER_12, cc.controller.pvpController));
}
function rewardsPool(ControllerContext memory cc) internal view returns (IRewardsPool) {
return IRewardsPool(_lazyInit(cc, CacheIndex.REWARDS_POOL_13, cc.controller.rewardsPool));
}
function itemBoxController(ControllerContext memory cc) internal view returns (IItemBoxController) {
return IItemBoxController(_lazyInit(cc, CacheIndex.ITEM_BOX_CONTROLLER_14, cc.controller.itemBoxController));
}
//endregion ----------------- Access with lazy initialization
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.23;
import "../interfaces/IAppErrors.sol";
import "../interfaces/IApplicationEvents.sol";
import "../interfaces/IERC20.sol";
import "../interfaces/IGameToken.sol";
import "../interfaces/IProxyControlled.sol";
import "../interfaces/IXmyrdGauge.sol";
import "../openzeppelin/Math.sol";
import "./AppLib.sol";
library ControllerLib {
//region ------------------------ Constants
/// @dev keccak256(abi.encode(uint256(keccak256("controller.main")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant CONTROLLER_STORAGE_LOCATION = 0x4d96152d518acf5697a667aeb82f27b3218b679995afa077296a84fdcb65bb00;
uint internal constant DEPLOYER_ELIGIBILITY_PERIOD = 7 days;
uint internal constant DEFAULT_TOKEN_PRICE = 10e18;
uint private constant _BURN_DENOMINATOR = 100e18;
uint private constant _TOTAL_SUPPLY_BASE = 10_000_000e18;
uint public constant HERO_PAYMENT_PART_BOSS_REWARDS_POOL = 80_000;
uint public constant HERO_PAYMENT_PART_TREASURY_LAST_BIOME = 10_000;
uint public constant HERO_PAYMENT_DENOMINATOR = 100_000;
//endregion ------------------------ Constants
//region ------------------------ Data types
/// @custom:storage-location erc7201:controller.main
struct MainState {
address governance;
address futureGovernance;
address statController;
address storyController;
address oracle;
address treasury;
address dungeonFactory;
address gameObjectController;
address reinforcementController;
address itemController;
address heroController;
address gameToken;
mapping(address => bool) validTreasuryTokens;
/// @dev EOA => eligibility time. We assume that deployer is fresh EOA and will be changed every deploy cycle for security reasons.
mapping(address => uint) deployers;
/// @dev In emergency case governance can pause all game
bool onPause;
address userController;
address guildController;
// some general relative price for the game token (how much game tokens need for 1 USD), 18 decimals, 10e18 by default
uint gameTokenPrice;
address rewardsPool;
address pvpController;
address itemBoxController;
address gaugeXMyrd;
}
//endregion ------------------------ Data types
//region ------------------------ Restrictions
function onlyGovernance() internal view {
if (!_isGovernance(msg.sender)) revert IAppErrors.NotGovernance(msg.sender);
}
function onlyDeployer() internal view {
if (!isDeployer(msg.sender)) revert IAppErrors.ErrorNotDeployer(msg.sender);
}
function onlyContractsAllowedToProcess(IController controller) internal view {
if (
controller.heroController() != msg.sender
&& controller.userController() != msg.sender
&& controller.guildController() != msg.sender
&& controller.reinforcementController() != msg.sender
&& controller.itemController() != msg.sender
&& controller.storyController() != msg.sender
) {
revert IAppErrors.ErrorNotAllowedSender();
}
}
//endregion ------------------------ Restrictions
//region ------------------------ Views
function _S() internal pure returns (MainState storage s) {
assembly {
s.slot := CONTROLLER_STORAGE_LOCATION
}
return s;
}
function isDeployer(address adr) internal view returns (bool) {
uint t = _S().deployers[adr];
return (t != 0 && block.timestamp < t) || _isGovernance(adr);
}
function governance() internal view returns (address) {return _S().governance;}
function futureGovernance() internal view returns (address) {return _S().futureGovernance;}
function statController() internal view returns (address) {return _S().statController;}
function storyController() internal view returns (address) {return _S().storyController;}
function oracle() internal view returns (address) {return _S().oracle;}
function treasury() internal view returns (address) {return _S().treasury;}
function dungeonFactory() internal view returns (address) {return _S().dungeonFactory;}
function gameObjectController() internal view returns (address) {return _S().gameObjectController;}
function reinforcementController() internal view returns (address) {return _S().reinforcementController;}
function itemController() internal view returns (address) {return _S().itemController;}
function heroController() internal view returns (address) {return _S().heroController;}
function gameToken() internal view returns (address) {return _S().gameToken;}
function rewardsPool() internal view returns (address) {return _S().rewardsPool;}
function validTreasuryTokens(address token) internal view returns (bool) {
return _S().validTreasuryTokens[token];
}
function onPause() internal view returns (bool) {return _S().onPause;}
function userController() internal view returns (address) {return _S().userController;}
function guildController() internal view returns (address) {return _S().guildController;}
function pvpController() internal view returns (address) {return _S().pvpController;}
function itemBoxController() internal view returns (address) {return _S().itemBoxController;}
function gameTokenPrice() internal view returns (uint p) {
p = _S().gameTokenPrice;
if (p == 0) {
p = DEFAULT_TOKEN_PRICE;
}
return p;
}
function gauge() internal view returns (address) {
return _S().gaugeXMyrd;
}
//endregion ------------------------ Views
//region ------------------------ Gov actions - setters
function changePause(bool value) internal {
onlyDeployer();
_S().onPause = value;
}
function offerGovernance(address newGov) internal {
onlyGovernance();
_S().futureGovernance = newGov;
emit IApplicationEvents.OfferGovernance(newGov);
}
function acceptGovernance() internal {
if (_S().futureGovernance != msg.sender) revert IAppErrors.NotFutureGovernance(msg.sender);
_S().governance = msg.sender;
delete _S().futureGovernance;
emit IApplicationEvents.GovernanceAccepted(msg.sender);
}
function setStatController(address value) internal {
onlyGovernance();
if (value == address(0)) revert IAppErrors.ZeroAddress();
_S().statController = value;
emit IApplicationEvents.StatControllerChanged(value);
}
function setStoryController(address value) internal {
onlyGovernance();
if (value == address(0)) revert IAppErrors.ZeroAddress();
_S().storyController = value;
emit IApplicationEvents.StoryControllerChanged(value);
}
function setGameObjectController(address value) internal {
onlyGovernance();
if (value == address(0)) revert IAppErrors.ZeroAddress();
_S().gameObjectController = value;
emit IApplicationEvents.GameObjectControllerChanged(value);
}
function setReinforcementController(address value) internal {
onlyGovernance();
if (value == address(0)) revert IAppErrors.ZeroAddress();
_S().reinforcementController = value;
emit IApplicationEvents.ReinforcementControllerChanged(value);
}
function setOracle(address value) internal {
onlyGovernance();
if (value == address(0)) revert IAppErrors.ZeroAddress();
_S().oracle = value;
emit IApplicationEvents.OracleChanged(value);
}
function setTreasury(address value) internal {
onlyGovernance();
if (value == address(0)) revert IAppErrors.ZeroAddress();
_S().treasury = value;
emit IApplicationEvents.TreasuryChanged(value);
}
function setItemController(address value) internal {
onlyGovernance();
if (value == address(0)) revert IAppErrors.ZeroAddress();
_S().itemController = value;
emit IApplicationEvents.ItemControllerChanged(value);
}
function setHeroController(address value) internal {
onlyGovernance();
if (value == address(0)) revert IAppErrors.ZeroAddress();
_S().heroController = value;
emit IApplicationEvents.HeroControllerChanged(value);
}
function setGameToken(address value) internal {
onlyGovernance();
if (value == address(0)) revert IAppErrors.ZeroAddress();
_S().gameToken = value;
emit IApplicationEvents.GameTokenChanged(value);
}
function setDungeonFactory(address value) internal {
onlyGovernance();
if (value == address(0)) revert IAppErrors.ZeroAddress();
_S().dungeonFactory = value;
emit IApplicationEvents.DungeonFactoryChanged(value);
}
function changeDeployer(address eoa, bool remove) internal {
onlyGovernance();
if (remove) {
delete _S().deployers[eoa];
} else {
_S().deployers[eoa] = block.timestamp + DEPLOYER_ELIGIBILITY_PERIOD;
}
}
function setUserController(address value) internal {
onlyGovernance();
if (value == address(0)) revert IAppErrors.ZeroAddress();
_S().userController = value;
emit IApplicationEvents.UserControllerChanged(value);
}
function setGuildController(address value) internal {
onlyGovernance();
if (value == address(0)) revert IAppErrors.ZeroAddress();
_S().guildController = value;
emit IApplicationEvents.GuildControllerChanged(value);
}
function setPvpController(address value) internal {
onlyGovernance();
if (value == address(0)) revert IAppErrors.ZeroAddress();
_S().pvpController = value;
emit IApplicationEvents.PvpControllerChanged(value);
}
function setRewardsPool(address value) internal {
onlyGovernance();
if (value == address(0)) revert IAppErrors.ZeroAddress();
_S().rewardsPool = value;
emit IApplicationEvents.RewardsPoolChanged(value);
}
function setGameTokenPrice(uint value) internal {
onlyGovernance();
if (value == 0) revert IAppErrors.ZeroAmount();
_S().gameTokenPrice = value;
emit IApplicationEvents.GameTokenPriceChanged(value);
}
function setItemBoxController(address value) internal {
onlyGovernance();
if (value == address(0)) revert IAppErrors.ZeroAddress();
_S().itemBoxController = value;
emit IApplicationEvents.ItemBoxControllerChanged(value);
}
function setGauge(address value) internal {
onlyGovernance();
// zero values are allowed
_S().gaugeXMyrd = value;
emit IApplicationEvents.GaugeChanged(value);
}
//endregion ------------------------ Gov actions - setters
//region ------------------------ Gov actions - others
function updateProxies(address[] memory proxies, address newLogic) internal {
onlyDeployer();
for (uint i; i < proxies.length; i++) {
IProxyControlled(proxies[i]).upgrade(newLogic);
emit IApplicationEvents.ProxyUpdated(proxies[i], newLogic);
}
}
function claimToGovernance(address token) internal {
onlyGovernance();
uint amount = IERC20(token).balanceOf(address(this));
if (amount != 0) {
IERC20(token).transfer(_S().governance, amount);
emit IApplicationEvents.Claimed(token, amount);
}
}
//endregion ------------------------ Gov actions - others
//region ------------------------ User actions
/// @notice Transfer {amount} from {from}, divide it on three parts: to treasury, to governance, to burn
/// User must approve given amount to the controller.
/// @param amount Assume that this amount is approved by {from} to this contract
function process(IController controller, address token, uint amount, address from) internal {
onlyContractsAllowedToProcess(controller);
(uint toBurn, uint toTreasury, uint toGov, uint toRewardsPool) = getProcessDetails(token, amount, controller.gameToken());
IERC20(token).transferFrom(from, address(this), amount);
if (toRewardsPool != 0) {
IERC20(token).transfer(controller.rewardsPool(), toRewardsPool);
}
if (toTreasury != 0) {
IERC20(token).transfer(controller.treasury(), toTreasury);
}
if (toBurn != 0) {
IGameToken(token).burn(toBurn);
}
// send all available token balance to XMyrd gauge
_sendTokensToGauge(token);
emit IApplicationEvents.Process(token, amount, from, toBurn, toTreasury, toGov);
}
function percentToBurn(uint totalSupply) internal pure returns (uint) {
return Math.min(totalSupply * _BURN_DENOMINATOR / _TOTAL_SUPPLY_BASE, _BURN_DENOMINATOR);
}
function getProcessDetails(address token, uint amount, address gameToken_) internal pure returns (
uint toBurn,
uint toTreasury,
uint toGov,
uint toRewardsPool
) {
if (token == gameToken_) {
// since SIP-005 we stop burn SACRA
// toBurn = amount * percentToBurn(IERC20(token).totalSupply()) / _BURN_DENOMINATOR;
toTreasury = (amount - toBurn) / 2;
toGov = amount - toBurn - toTreasury;
} else {
toRewardsPool = amount * HERO_PAYMENT_PART_BOSS_REWARDS_POOL / HERO_PAYMENT_DENOMINATOR;
toTreasury = amount * HERO_PAYMENT_PART_TREASURY_LAST_BIOME / HERO_PAYMENT_DENOMINATOR;
toGov = amount - toRewardsPool - toTreasury;
}
return (toBurn, toTreasury, toGov, toRewardsPool);
}
//endregion ------------------------ User actions
//region ------------------------ REGISTER ACTIONS
function changeTreasuryTokenStatus(address token, bool status) internal {
onlyGovernance();
_S().validTreasuryTokens[token] = status;
emit IApplicationEvents.TokenStatusChanged(token, status);
}
//endregion ------------------------ REGISTER ACTIONS
//region ------------------------ Internal logic
function _isGovernance(address _value) internal view returns (bool) {
return IController(address(this)).governance() == _value;
}
/// @notice Send all available amount of the token to xMyrd gauge and call updatePeriod to rebase
function _sendTokensToGauge(address token) internal {
IXMyrdGauge _gauge = IXMyrdGauge(_S().gaugeXMyrd);
if (address(_gauge) != address(0)) {
address myrd = _gauge.defaultRewardToken();
if (token == myrd) {
// --------------- special logic for MYRD: send rewards through updatePeriod(amount)
// todo fix left value calculation
if (_gauge.activePeriod() < _gauge.getPeriod()) {
uint balance = IERC20(token).balanceOf(address(this));
if (balance != 0) {
AppLib.approveIfNeeded(token, balance, address(_gauge));
}
// we should update period even with zero balance to call rebase
try _gauge.updatePeriod(balance) {
emit IApplicationEvents.UpdatePeriod(balance);
} catch {}
}
} else {
// --------------- any other tokens except MYRD: use notifyRewardAmount(amount) + updatePeriod(0)
uint balance = IERC20(token).balanceOf(address(this));
if (balance > _gauge.left(_gauge.xMyrd(), token) && balance / 7 days > 0) {
AppLib.approveIfNeeded(token, balance, address(_gauge));
try _gauge.notifyRewardAmount(token, balance) {
emit IApplicationEvents.NotifyRewardAmount(token, balance);
} catch {}
} else {
// keep tokens on balance of the controller
// zero-balance case is also here
}
// call updatePeriod if it's allowed
// todo fix left value calculation
if (_gauge.activePeriod() < _gauge.getPeriod()) {
try _gauge.updatePeriod(0) {
emit IApplicationEvents.UpdatePeriod(0);
} catch {}
}
}
}
}
//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: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @dev Muldiv operation overflow.
*/
error MathOverflowedMulDiv();
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Returns the addition of two unsigned integers, with an success flag (no overflow).
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an success flag (no overflow).
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an success flag (no overflow).
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a success flag (no division by zero).
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
return a / b;
}
// The following calculation ensures accurate ceiling division without overflow.
// Since a is non-zero, (a - 1) / b will not overflow.
// The largest possible result occurs when (a - 1) / b is type(uint256).max,
// but the largest value we can obtain is type(uint256).max - 1, which happens
// when a = type(uint256).max and b = 1.
unchecked {
return a == 0 ? 0 : (a - 1) / b + 1;
}
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
* Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0 = x * y; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
if (denominator <= prod1) {
revert MathOverflowedMulDiv();
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
uint256 twos = denominator & (0 - denominator);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
// works in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}// SPDX-License-Identifier: 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);
}
}{
"evmVersion": "istanbul",
"optimizer": {
"enabled": true,
"runs": 50
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"metadata": {
"useLiteralContent": true
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"name":"ErrorNotAllowedSender","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ErrorNotDeployer","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"NotFutureGovernance","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"NotGovernance","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"inputs":[],"name":"ZeroAmount","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Claimed","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":"address","name":"value","type":"address"}],"name":"DungeonFactoryChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"value","type":"address"}],"name":"GameObjectControllerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"value","type":"address"}],"name":"GameTokenChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"GameTokenPriceChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"gauge","type":"address"}],"name":"GaugeChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"gov","type":"address"}],"name":"GovernanceAccepted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"value","type":"address"}],"name":"GuildControllerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"value","type":"address"}],"name":"HeroControllerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"value","type":"address"}],"name":"ItemBoxControllerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"value","type":"address"}],"name":"ItemControllerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"NotifyRewardAmount","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newGov","type":"address"}],"name":"OfferGovernance","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"value","type":"address"}],"name":"OracleChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"toBurn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"toTreasury","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"toGov","type":"uint256"}],"name":"Process","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"proxy","type":"address"},{"indexed":false,"internalType":"address","name":"logic","type":"address"}],"name":"ProxyUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"value","type":"address"}],"name":"PvpControllerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"value","type":"address"}],"name":"ReinforcementControllerChanged","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"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"value","type":"address"}],"name":"RewardsPoolChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"value","type":"address"}],"name":"StatControllerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"value","type":"address"}],"name":"StoryControllerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"bool","name":"status","type":"bool"}],"name":"TokenStatusChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"value","type":"address"}],"name":"TreasuryChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"myrdAmount","type":"uint256"}],"name":"UpdatePeriod","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"value","type":"address"}],"name":"UserControllerChanged","type":"event"},{"inputs":[],"name":"CONTROLLABLE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEPLOYER_ELIGIBILITY_PERIOD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptGovernance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"eoa","type":"address"},{"internalType":"bool","name":"remove","type":"bool"}],"name":"changeDeployer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"value","type":"bool"}],"name":"changePause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"bool","name":"status","type":"bool"}],"name":"changeTreasuryTokenStatus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"claimToGovernance","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":"dungeonFactory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"futureGovernance","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gameObjectController","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gameToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gameTokenPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gauge","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"getProcessDetails","outputs":[{"internalType":"uint256","name":"toBurn","type":"uint256"},{"internalType":"uint256","name":"toTreasury","type":"uint256"},{"internalType":"uint256","name":"toGov","type":"uint256"},{"internalType":"uint256","name":"toRewardsPool","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"governance","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"guildController","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"heroController","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"oldLogic","type":"address"}],"name":"increaseRevision","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"governance_","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":"adr","type":"address"}],"name":"isDeployer","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":[],"name":"itemBoxController","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"itemController","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newGov","type":"address"}],"name":"offerGovernance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"onPause","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oracle","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"totalSupply","type":"uint256"}],"name":"percentToBurn","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"previousImplementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"from","type":"address"}],"name":"process","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pvpController","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"reinforcementController","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"revision","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardsPool","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"value","type":"address"}],"name":"setDungeonFactory","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"value","type":"address"}],"name":"setGameObjectController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"value","type":"address"}],"name":"setGameToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"name":"setGameTokenPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"value","type":"address"}],"name":"setGauge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"value","type":"address"}],"name":"setGuildController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"value","type":"address"}],"name":"setHeroController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"value","type":"address"}],"name":"setItemBoxController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"value","type":"address"}],"name":"setItemController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"value","type":"address"}],"name":"setOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"value","type":"address"}],"name":"setPvpController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"value","type":"address"}],"name":"setReinforcementController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"value","type":"address"}],"name":"setRewardsPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"value","type":"address"}],"name":"setStatController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"value","type":"address"}],"name":"setStoryController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"value","type":"address"}],"name":"setTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"value","type":"address"}],"name":"setUserController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"statController","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"storyController","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"proxies","type":"address[]"},{"internalType":"address","name":"newLogic","type":"address"}],"name":"updateProxies","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"userController","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"validTreasuryTokens","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]Contract Creation Code
60806040523480156200001157600080fd5b507ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff1615906001600160401b03166000811580156200005d5750825b90506000826001600160401b031660011480156200007a5750303b155b90508115801562000089575080155b15620000a85760405163f92ee8a960e01b815260040160405180910390fd5b84546001600160401b03191660011785558315620000d757845460ff60401b1916680100000000000000001785555b83156200011e57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505061315380620001336000396000f3fe608060405234801561001057600080fd5b50600436106102fe5760003560e01c806361d027b3116101a45780639d0bcca0116100fa578063d11d18611161009d578063d11d186114610653578063dee1f0e41461065d578063e4ce087114610670578063f0f4426014610683578063f2c7b2eb14610696578063f6914cfa146106a9578063f77c4791146106bc578063ffa1ad74146106c457600080fd5b80639d0bcca0146105f2578063a27218ac146105fa578063a6f19c8414610602578063b1bc41951461060a578063b429afeb14610612578063bcb384fa14610625578063c3dfdae614610638578063c81529c61461064057600080fd5b806361d027b3146104d957806368321eb7146104e1578063683fedf7146105145780637262bb2d1461051c5780637405bab81461052f5780637adbf973146105425780637c000293146105555780637c66b452146105685780637cc963801461057b5780637dc0d1d0146105835780638070c5031461058b57806380d29e6614610593578063822f804c146105a657806389dd9f13146105b9578063936725ec146105c157600080fd5b8063359a7d8f11610259578063359a7d8f146103e8578063361e4b27146103fb57806337cac68a1461040e5780633c8f1bbe146104215780634453bd89146104345780634576dc52146104475780634593144c1461045a578063490fb76a146104625780634fac6ccd1461046a57806350c358a41461047d578063524a562f1461049057806355a68ed3146104985780635aa6e675146104ab5780635d4fead3146104b3578063605918ae146104c657600080fd5b80628e9691146103035780630139009f14610321578063016dff5d146103295780630359fea91461033157806308ac0fd71461033957806311b0aebe1461034e5780631534e0501461036f57806318d928311461038257806319ab453c1461039a5780631ec47600146103ad578063238efcbc146103c057806325eb1c87146103c85780632f91ede9146103d057806331423c26146103d8578063325a19f1146103e0575b600080fd5b61030b6106e8565b6040516103189190612d6f565b60405180910390f35b61030b6106f7565b61030b610701565b61030b61070b565b61034c610347366004612da8565b610715565b005b61036161035c366004612dc5565b610721565b604051908152602001610318565b61034c61037d366004612da8565b610732565b61038a61073b565b6040519015158152602001610318565b61034c6103a8366004612da8565b610745565b61034c6103bb366004612da8565b610868565b61034c610871565b61030b61087b565b61030b610885565b61030b61088f565b610361610899565b61034c6103f6366004612da8565b6108cd565b61034c610409366004612da8565b6108d6565b61034c61041c366004612da8565b6108df565b61034c61042f366004612dde565b6108e8565b61034c610442366004612da8565b6108f9565b61034c610455366004612e36565b610902565b610361610910565b61030b610940565b61034c610478366004612da8565b61094a565b61038a61048b366004612da8565b610a5c565b61030b610a67565b61034c6104a6366004612da8565b610a71565b61030b610a7a565b61034c6104c1366004612f1b565b610a84565b61034c6104d4366004612da8565b610a8d565b61030b610a96565b6104f46104ef366004612f38565b610aa0565b604080519485526020850193909352918301526060820152608001610318565b61030b610b22565b61034c61052a366004612f64565b610b2c565b61034c61053d366004612da8565b610b36565b61034c610550366004612da8565b610b3f565b61034c610563366004612da8565b610b48565b61038a610576366004612da8565b610b51565b610361610b5c565b61030b610b7a565b61030b610b84565b61034c6105a1366004612da8565b610b8e565b61034c6105b4366004612da8565b610b97565b61030b610ba0565b6105e5604051806040016040528060058152602001640312e302e360dc1b81525081565b6040516103189190612f9d565b61030b610baa565b61030b610bda565b61030b610be4565b610361610bee565b61038a610620366004612da8565b610bf8565b61034c610633366004612da8565b610c1d565b61030b610c26565b61034c61064e366004612da8565b610c30565b61036162093a8081565b61038a61066b366004612da8565b610c39565b61034c61067e366004612da8565b610cbe565b61034c610691366004612da8565b610cc7565b61034c6106a4366004612dc5565b610cd0565b61034c6106b7366004612f64565b610cd9565b61030b610ce3565b6105e560405180604001604052806005815260200164312e302e3360d81b81525081565b60006106f2610d13565b905090565b60006106f2610d2f565b60006106f2610d4b565b60006106f2610d67565b61071e81610d83565b50565b600061072c82610e17565b92915050565b61071e81610e54565b60006106f2610edd565b600061074f610ef3565b805490915060ff600160401b820416159067ffffffffffffffff166000811580156107775750825b905060008267ffffffffffffffff1660011480156107945750303b155b9050811580156107a2575080155b156107c05760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff1916600117855583156107ea57845460ff60401b1916600160401b1785555b6107f330610f17565b856107fc610f28565b80546001600160a01b0319166001600160a01b0392909216919091179055831561086057845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b61071e81610f4c565b610879610fae565b565b60006106f261105e565b60006106f261107a565b60006106f2611096565b60006106f26108c960017f6f55f470bdc9cb5f04223fd822021061668e4dccb43e8727b295106dc9769c8b613002565b5490565b61071e816110b2565b61071e81611140565b61071e816111c9565b6108f430848484611252565b505050565b61071e816115c3565b61090c828261164c565b5050565b60006106f26108c960017f812a673dfca07956350df10f8a654925f561d7a0da09bdbe79e653939a14d9f1613002565b60006106f2611731565b33301461099c5760405162461bcd60e51b815260206004820152601b60248201527a24b731b932b0b9b2903932bb34b9b4b7b7103337b93134b23232b760291b60448201526064015b60405180910390fd5b60006109ba6108c960016000805160206130fe833981519152613002565b6109c5906001613015565b90506109e7816109e460016000805160206130fe833981519152613002565b55565b610a16826109e460017fbfaaa2fb63266ff27c2da975f5894955056f50419af651a81f6c5060581857e4613002565b604080518281526001600160a01b03841660208201527ff27e2ef832a4eb8ed8ec553b875eecd44764cda95b1c24170e281539e0a869c891015b60405180910390a15050565b600061072c82611752565b60006106f26117a0565b61071e816117bc565b60006106f261181e565b61071e81611837565b61071e8161185d565b60006106f26118e6565b600080600080610b128686306001600160a01b031663c3dfdae66040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ae9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b0d9190613028565b611902565b9299919850965090945092505050565b60006106f26119af565b61090c82826119cb565b61071e81611a38565b61071e81611ac1565b61071e81611b4a565b600061072c82611bd3565b60006106f26108c960016000805160206130fe833981519152613002565b60006106f2611c02565b60006106f2611c1e565b61071e81611c3a565b61071e81611cc3565b60006106f2611d4c565b60006106f26108c960017fbfaaa2fb63266ff27c2da975f5894955056f50419af651a81f6c5060581857e4613002565b60006106f2611d68565b60006106f2611d84565b60006106f2611da0565b6000610c02610ce3565b6001600160a01b0316826001600160a01b0316149050919050565b61071e81611dc6565b60006106f2611eff565b61071e81611f1b565b6000816001600160a01b0316610c4d610ce3565b6001600160a01b0316635aa6e6756040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c8a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cae9190613028565b6001600160a01b03161492915050565b61071e81611fa4565b61071e8161202d565b61071e816120b6565b61090c828261211c565b60006106f26108c960017f5165972ef41194f06c5007493031d0b927c20741adcb74403b954009fd2c3618613002565b6000610d1d610f28565b600201546001600160a01b0316919050565b6000610d39610f28565b601301546001600160a01b0316919050565b6000610d55610f28565b600a01546001600160a01b0316919050565b6000610d71610f28565b601101546001600160a01b0316919050565b610d8b612194565b6001600160a01b038116610db25760405163d92e233d60e01b815260040160405180910390fd5b80610dbb610f28565b60060180546001600160a01b0319166001600160a01b03929092169190911790556040517f5d77c617926cd1f4106de1bae23b2eb1a9d6e84911f701858a0b1d831e92816590610e0c908390612d6f565b60405180910390a150565b600061072c6a084595161401484a000000610e3b68056bc75e2d6310000085613045565b610e45919061305c565b68056bc75e2d631000006121bc565b610e5c612194565b6001600160a01b038116610e835760405163d92e233d60e01b815260040160405180910390fd5b80610e8c610f28565b60130180546001600160a01b0319166001600160a01b03929092169190911790556040517fcaa89af641ab6d1a458e39f225a12c0d1137f317d718b8713054a445bd2cde6790610e0c908390612d6f565b6000610ee7610f28565b600e015460ff16919050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0090565b610f1f6121d2565b61071e816121f7565b7f4d96152d518acf5697a667aeb82f27b3218b679995afa077296a84fdcb65bb0090565b610f54612194565b80610f5d610f28565b60010180546001600160a01b0319166001600160a01b03929092169190911790556040517f93a15bbe6d7cb67fff86738ed92efd14e9fe04e7d30042086570034a2f2eb3c290610e0c908390612d6f565b33610fb7610f28565b600101546001600160a01b031614610fe4573360405163ba18f1e160e01b81526004016109939190612d6f565b33610fed610f28565b80546001600160a01b0319166001600160a01b0392909216919091179055611013610f28565b60010180546001600160a01b03191690556040517fb1476cf38ac36ee528f1ad1ae81bdb46de8807d42475e16078426bce6001396190611054903390612d6f565b60405180910390a1565b6000611068610f28565b600f01546001600160a01b0316919050565b6000611084610f28565b600801546001600160a01b0316919050565b60006110a0610f28565b600901546001600160a01b0316919050565b6110ba612194565b6001600160a01b0381166110e15760405163d92e233d60e01b815260040160405180910390fd5b806110ea610f28565b600e0160016101000a8154816001600160a01b0302191690836001600160a01b031602179055507fd86fc86ebea7a7d81c1a9fa7e0977cdafcfccf0cc35295a095231a7b28274e4981604051610e0c9190612d6f565b611148612194565b6001600160a01b03811661116f5760405163d92e233d60e01b815260040160405180910390fd5b80611178610f28565b60030180546001600160a01b0319166001600160a01b03929092169190911790556040517fecbc0f0d903f1b9964d257a8043a5ecdf9c55a8e3d0060fb920b40c4009a257d90610e0c908390612d6f565b6111d1612194565b6001600160a01b0381166111f85760405163d92e233d60e01b815260040160405180910390fd5b80611201610f28565b60120180546001600160a01b0319166001600160a01b03929092169190911790556040517fe34dace06c75fb12cb36ab5627f4ad085768e0e550b787566c647aa0cd052b0690610e0c908390612d6f565b61125b84612314565b6000806000806112a487878a6001600160a01b031663c3dfdae66040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ae9573d6000803e3d6000fd5b6040516323b872dd60e01b81526001600160a01b038a81166004830152306024830152604482018c90529498509296509094509250908816906323b872dd906064016020604051808303816000875af1158015611305573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611329919061307e565b50801561140457866001600160a01b031663a9059cbb896001600160a01b0316630359fea96040518163ffffffff1660e01b8152600401602060405180830381865afa15801561137d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113a19190613028565b836040518363ffffffff1660e01b81526004016113bf92919061309b565b6020604051808303816000875af11580156113de573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611402919061307e565b505b82156114de57866001600160a01b031663a9059cbb896001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611457573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061147b9190613028565b856040518363ffffffff1660e01b815260040161149992919061309b565b6020604051808303816000875af11580156114b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114dc919061307e565b505b831561155157604051630852cd8d60e31b8152600481018590526001600160a01b038816906342966c68906024016020604051808303816000875af115801561152b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061154f919061307e565b505b61155a87612624565b604080516001600160a01b03898116825260208201899052871681830152606081018690526080810185905260a0810184905290517f1fd334c200f7b34cefbcb9762981e99dea5bdff9c149c5e4a279a1f55e8c97729181900360c00190a15050505050505050565b6115cb612194565b6001600160a01b0381166115f25760405163d92e233d60e01b815260040160405180910390fd5b806115fb610f28565b600f0180546001600160a01b0319166001600160a01b03929092169190911790556040517f0d1f076dd618d44fc1ed0ae909dcb5a875262080a1fb3386f155e47003323ed790610e0c908390612d6f565b611654612bf9565b60005b82518110156108f457828181518110611672576116726130b4565b60200260200101516001600160a01b0316630900f010836040518263ffffffff1660e01b81526004016116a59190612d6f565b600060405180830381600087803b1580156116bf57600080fd5b505af11580156116d3573d6000803e3d6000fd5b505050507fd32d24edea94f55e932d9a008afc425a8561462d1b1f57bc6e508e9a6b9509e183828151811061170a5761170a6130b4565b6020026020010151836040516117219291906130ca565b60405180910390a1600101611657565b600061173b610f28565b600e015461010090046001600160a01b0316919050565b60008061175d610f28565b6001600160a01b0384166000908152600d9190910160205260409020549050801580159061178a57508042105b80611799575061179983612c21565b9392505050565b60006117aa610f28565b600301546001600160a01b0316919050565b6117c4612194565b806117cd610f28565b60140180546001600160a01b0319166001600160a01b03929092169190911790556040517f1d609dbce8c46093a144a3723e81b905c328eb5034d986a74301fb4764ded28190610e0c908390612d6f565b6000611828610f28565b546001600160a01b0316919050565b61183f612bf9565b80611848610f28565b600e01805460ff191691151591909117905550565b611865612194565b6001600160a01b03811661188c5760405163d92e233d60e01b815260040160405180910390fd5b80611895610f28565b60020180546001600160a01b0319166001600160a01b03929092169190911790556040517f573b0be2ffc8c66825968c4e3b38a0af5edb18ce20f9a516e0f8a04867d2638990610e0c908390612d6f565b60006118f0610f28565b600501546001600160a01b0316919050565b600080600080846001600160a01b0316876001600160a01b03160361195557600261192d8588613002565b611937919061305c565b9250826119448588613002565b61194e9190613002565b91506119a6565b620186a06119666201388088613045565b611970919061305c565b9050620186a061198261271088613045565b61198c919061305c565b9250826119998288613002565b6119a39190613002565b91505b93509350935093565b60006119b9610f28565b600601546001600160a01b0316919050565b6119d3612194565b8015611a02576119e1610f28565b6001600160a01b0383166000908152600d9190910160205260408120555050565b611a0f62093a8042613015565b611a17610f28565b6001600160a01b0384166000908152600d9190910160205260409020555050565b611a40612194565b6001600160a01b038116611a675760405163d92e233d60e01b815260040160405180910390fd5b80611a70610f28565b60090180546001600160a01b0319166001600160a01b03929092169190911790556040517fedcd6ea89a41d21f1bafa9a7cc32e754079d18642839a1a48c938447d2a740eb90610e0c908390612d6f565b611ac9612194565b6001600160a01b038116611af05760405163d92e233d60e01b815260040160405180910390fd5b80611af9610f28565b60040180546001600160a01b0319166001600160a01b03929092169190911790556040517f0e05ae75e8b926552cf6fcd744d19f422561e3ced1e426868730852702dbe41890610e0c908390612d6f565b611b52612194565b6001600160a01b038116611b795760405163d92e233d60e01b815260040160405180910390fd5b80611b82610f28565b60110180546001600160a01b0319166001600160a01b03929092169190911790556040517f657bb19de5473f7be7de9ccbcfa6d9aabcb3cfd199aef85e949a1d8570c290ab90610e0c908390612d6f565b6000611bdd610f28565b6001600160a01b039092166000908152600c9290920160205250604090205460ff1690565b6000611c0c610f28565b600401546001600160a01b0316919050565b6000611c28610f28565b600101546001600160a01b0316919050565b611c42612194565b6001600160a01b038116611c695760405163d92e233d60e01b815260040160405180910390fd5b80611c72610f28565b600b0180546001600160a01b0319166001600160a01b03929092169190911790556040517f035bee136adcafe288762d810fef741bc236d20bb1b469acb4c23e5357f0856790610e0c908390612d6f565b611ccb612194565b6001600160a01b038116611cf25760405163d92e233d60e01b815260040160405180910390fd5b80611cfb610f28565b60070180546001600160a01b0319166001600160a01b03929092169190911790556040517ffa195fffb4bf4e5339e2e98fb090f0d634c64261640c07c1ee6ee43d5f23516190610e0c908390612d6f565b6000611d56610f28565b600701546001600160a01b0316919050565b6000611d72610f28565b601201546001600160a01b0316919050565b6000611d8e610f28565b601401546001600160a01b0316919050565b6000611daa610f28565b60100154905080600003611dc35750678ac7230489e800005b90565b611dce612194565b6040516370a0823160e01b81526000906001600160a01b038316906370a0823190611dfd903090600401612d6f565b602060405180830381865afa158015611e1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e3e91906130e4565b9050801561090c57816001600160a01b031663a9059cbb611e5d610f28565b546040516001600160e01b031960e084901b168152611e8a916001600160a01b031690859060040161309b565b6020604051808303816000875af1158015611ea9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ecd919061307e565b507fd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a8282604051610a5092919061309b565b6000611f09610f28565b600b01546001600160a01b0316919050565b611f23612194565b6001600160a01b038116611f4a5760405163d92e233d60e01b815260040160405180910390fd5b80611f53610f28565b600a0180546001600160a01b0319166001600160a01b03929092169190911790556040517fd1e9a4ae1231531a757f1e31a2ff8a1db9d359a194436efe40bccb972cde86f090610e0c908390612d6f565b611fac612194565b6001600160a01b038116611fd35760405163d92e233d60e01b815260040160405180910390fd5b80611fdc610f28565b60080180546001600160a01b0319166001600160a01b03929092169190911790556040517f29fdde0e067ae34f44ca706fd84ea4b9dabb69557e7e935d379c932ba023b2be90610e0c908390612d6f565b612035612194565b6001600160a01b03811661205c5760405163d92e233d60e01b815260040160405180910390fd5b80612065610f28565b60050180546001600160a01b0319166001600160a01b03929092169190911790556040517fc714d22a2f08b695f81e7c707058db484aa5b4d6b4c9fd64beb10fe85832f60890610e0c908390612d6f565b6120be612194565b806000036120df57604051631f2a200560e01b815260040160405180910390fd5b806120e8610f28565b601001556040518181527f867c590cfc1b2ba6732d5d876a96733ad5cde9c836a978d6107517c00cf3f44590602001610e0c565b612124612194565b8061212d610f28565b6001600160a01b0384166000818152600c929092016020908152604092839020805460ff1916941515949094179093558151908152831515928101929092527f0de9c5667496fd561ff9dfa59efdc1c76f7dbf3844adae3d14a3a14d563321b19101610a50565b61219d33612c21565b610879573360405163988d1f0360e01b81526004016109939190612d6f565b60008183106121cb5781611799565b5090919050565b6121da612c6b565b61087957604051631afcd79f60e31b815260040160405180910390fd5b6001600160a01b03811661223f5760405162461bcd60e51b815260206004820152600f60248201526e2d32b9379031b7b73a3937b63632b960891b6044820152606401610993565b61226e816109e460017f5165972ef41194f06c5007493031d0b927c20741adcb74403b954009fd2c3618613002565b61229d426109e460017f6f55f470bdc9cb5f04223fd822021061668e4dccb43e8727b295106dc9769c8b613002565b6122cc436109e460017f812a673dfca07956350df10f8a654925f561d7a0da09bdbe79e653939a14d9f1613002565b604080516001600160a01b038316815242602082015243918101919091527f1a2dd071001ebf6e03174e3df5b305795a4ad5d41d8fdb9ba41dbbe23671342690606001610e0c565b336001600160a01b0316816001600160a01b031663016dff5d6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561235c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123809190613028565b6001600160a01b03161415801561240a5750336001600160a01b0316816001600160a01b031663490fb76a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156123da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123fe9190613028565b6001600160a01b031614155b80156124895750336001600160a01b0316816001600160a01b03166325eb1c876040518163ffffffff1660e01b8152600401602060405180830381865afa158015612459573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061247d9190613028565b6001600160a01b031614155b80156125085750336001600160a01b0316816001600160a01b0316632f91ede96040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124fc9190613028565b6001600160a01b031614155b80156125875750336001600160a01b0316816001600160a01b03166331423c266040518163ffffffff1660e01b8152600401602060405180830381865afa158015612557573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061257b9190613028565b6001600160a01b031614155b80156126065750336001600160a01b0316816001600160a01b031663524a562f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156125d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125fa9190613028565b6001600160a01b031614155b1561071e5760405163f20e063760e01b815260040160405180910390fd5b600061262e610f28565b601401546001600160a01b03169050801561090c576000816001600160a01b031663ff3a4ac06040518163ffffffff1660e01b8152600401602060405180830381865afa158015612683573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126a79190613028565b9050806001600160a01b0316836001600160a01b0316036128a257816001600160a01b0316631ed241956040518163ffffffff1660e01b8152600401602060405180830381865afa158015612700573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061272491906130e4565b826001600160a01b0316630a441f7b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612762573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061278691906130e4565b10156108f4576040516370a0823160e01b81526000906001600160a01b038516906370a08231906127bb903090600401612d6f565b602060405180830381865afa1580156127d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127fc91906130e4565b9050801561280f5761280f848285612c85565b60405163e270d1df60e01b8152600481018290526001600160a01b0384169063e270d1df90602401600060405180830381600087803b15801561285157600080fd5b505af1925050508015612862575060015b1561289c576040518181527fd1c043d38a3243c01780647a1340049807cd98af891021c89c32c99a8e0c59e7906020015b60405180910390a15b50505050565b6040516370a0823160e01b81526000906001600160a01b038516906370a08231906128d1903090600401612d6f565b602060405180830381865afa1580156128ee573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061291291906130e4565b9050826001600160a01b0316636180c3f9846001600160a01b03166379d83f8e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612961573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129859190613028565b866040518363ffffffff1660e01b81526004016129a39291906130ca565b602060405180830381865afa1580156129c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129e491906130e4565b811180156129fe575060006129fc62093a808361305c565b115b15612aa657612a0e848285612c85565b60405163b66503cf60e01b81526001600160a01b0384169063b66503cf90612a3c908790859060040161309b565b600060405180830381600087803b158015612a5657600080fd5b505af1925050508015612a67575060015b15612aa6577ff6b60b7da8e0f883e399412005b6205515604a993e7e3f0c3b199b9cb07d6ae68482604051612a9d92919061309b565b60405180910390a15b826001600160a01b0316631ed241956040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ae4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b0891906130e4565b836001600160a01b0316630a441f7b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b46573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b6a91906130e4565b101561289c5760405163e270d1df60e01b8152600060048201526001600160a01b0384169063e270d1df90602401600060405180830381600087803b158015612bb257600080fd5b505af1925050508015612bc3575060015b1561289c57604051600081527fd1c043d38a3243c01780647a1340049807cd98af891021c89c32c99a8e0c59e790602001612893565b612c0233611752565b610879573360405163451cea1760e11b81526004016109939190612d6f565b6000816001600160a01b0316306001600160a01b0316635aa6e6756040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c8a573d6000803e3d6000fd5b6000612c75610ef3565b54600160401b900460ff16919050565b604051636eb1769f60e11b815282906001600160a01b0385169063dd62ed3e90612cb590309086906004016130ca565b602060405180830381865afa158015612cd2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cf691906130e4565b10156108f45760405163095ea7b360e01b81526001600160a01b0384169063095ea7b390612d2c9084906000199060040161309b565b6020604051808303816000875af1158015612d4b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061289c919061307e565b6001600160a01b0391909116815260200190565b6001600160a01b038116811461071e57600080fd5b8035612da381612d83565b919050565b600060208284031215612dba57600080fd5b813561179981612d83565b600060208284031215612dd757600080fd5b5035919050565b600080600060608486031215612df357600080fd5b8335612dfe81612d83565b9250602084013591506040840135612e1581612d83565b809150509250925092565b634e487b7160e01b600052604160045260246000fd5b60008060408385031215612e4957600080fd5b823567ffffffffffffffff80821115612e6157600080fd5b818501915085601f830112612e7557600080fd5b8135602082821115612e8957612e89612e20565b8160051b604051601f19603f83011681018181108682111715612eae57612eae612e20565b604052928352818301935084810182019289841115612ecc57600080fd5b948201945b83861015612ef157612ee286612d98565b85529482019493820193612ed1565b9650612f009050878201612d98565b9450505050509250929050565b801515811461071e57600080fd5b600060208284031215612f2d57600080fd5b813561179981612f0d565b60008060408385031215612f4b57600080fd5b8235612f5681612d83565b946020939093013593505050565b60008060408385031215612f7757600080fd5b8235612f8281612d83565b91506020830135612f9281612f0d565b809150509250929050565b60006020808352835180602085015260005b81811015612fcb57858101830151858201604001528201612faf565b506000604082860101526040601f19601f8301168501019250505092915050565b634e487b7160e01b600052601160045260246000fd5b8181038181111561072c5761072c612fec565b8082018082111561072c5761072c612fec565b60006020828403121561303a57600080fd5b815161179981612d83565b808202811582820484141761072c5761072c612fec565b60008261307957634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561309057600080fd5b815161179981612f0d565b6001600160a01b03929092168252602082015260400190565b634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831681529116602082015260400190565b6000602082840312156130f657600080fd5b505191905056fe22573091f17911fb166032a3d9e0554aa73d31b7b7ddea4a4dd2995650af84bda2646970667358221220b0d0360bf4ecefccd5606caec889b71d89f0504dd40497f2592c36b15f2a7c3c64736f6c63430008170033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106102fe5760003560e01c806361d027b3116101a45780639d0bcca0116100fa578063d11d18611161009d578063d11d186114610653578063dee1f0e41461065d578063e4ce087114610670578063f0f4426014610683578063f2c7b2eb14610696578063f6914cfa146106a9578063f77c4791146106bc578063ffa1ad74146106c457600080fd5b80639d0bcca0146105f2578063a27218ac146105fa578063a6f19c8414610602578063b1bc41951461060a578063b429afeb14610612578063bcb384fa14610625578063c3dfdae614610638578063c81529c61461064057600080fd5b806361d027b3146104d957806368321eb7146104e1578063683fedf7146105145780637262bb2d1461051c5780637405bab81461052f5780637adbf973146105425780637c000293146105555780637c66b452146105685780637cc963801461057b5780637dc0d1d0146105835780638070c5031461058b57806380d29e6614610593578063822f804c146105a657806389dd9f13146105b9578063936725ec146105c157600080fd5b8063359a7d8f11610259578063359a7d8f146103e8578063361e4b27146103fb57806337cac68a1461040e5780633c8f1bbe146104215780634453bd89146104345780634576dc52146104475780634593144c1461045a578063490fb76a146104625780634fac6ccd1461046a57806350c358a41461047d578063524a562f1461049057806355a68ed3146104985780635aa6e675146104ab5780635d4fead3146104b3578063605918ae146104c657600080fd5b80628e9691146103035780630139009f14610321578063016dff5d146103295780630359fea91461033157806308ac0fd71461033957806311b0aebe1461034e5780631534e0501461036f57806318d928311461038257806319ab453c1461039a5780631ec47600146103ad578063238efcbc146103c057806325eb1c87146103c85780632f91ede9146103d057806331423c26146103d8578063325a19f1146103e0575b600080fd5b61030b6106e8565b6040516103189190612d6f565b60405180910390f35b61030b6106f7565b61030b610701565b61030b61070b565b61034c610347366004612da8565b610715565b005b61036161035c366004612dc5565b610721565b604051908152602001610318565b61034c61037d366004612da8565b610732565b61038a61073b565b6040519015158152602001610318565b61034c6103a8366004612da8565b610745565b61034c6103bb366004612da8565b610868565b61034c610871565b61030b61087b565b61030b610885565b61030b61088f565b610361610899565b61034c6103f6366004612da8565b6108cd565b61034c610409366004612da8565b6108d6565b61034c61041c366004612da8565b6108df565b61034c61042f366004612dde565b6108e8565b61034c610442366004612da8565b6108f9565b61034c610455366004612e36565b610902565b610361610910565b61030b610940565b61034c610478366004612da8565b61094a565b61038a61048b366004612da8565b610a5c565b61030b610a67565b61034c6104a6366004612da8565b610a71565b61030b610a7a565b61034c6104c1366004612f1b565b610a84565b61034c6104d4366004612da8565b610a8d565b61030b610a96565b6104f46104ef366004612f38565b610aa0565b604080519485526020850193909352918301526060820152608001610318565b61030b610b22565b61034c61052a366004612f64565b610b2c565b61034c61053d366004612da8565b610b36565b61034c610550366004612da8565b610b3f565b61034c610563366004612da8565b610b48565b61038a610576366004612da8565b610b51565b610361610b5c565b61030b610b7a565b61030b610b84565b61034c6105a1366004612da8565b610b8e565b61034c6105b4366004612da8565b610b97565b61030b610ba0565b6105e5604051806040016040528060058152602001640312e302e360dc1b81525081565b6040516103189190612f9d565b61030b610baa565b61030b610bda565b61030b610be4565b610361610bee565b61038a610620366004612da8565b610bf8565b61034c610633366004612da8565b610c1d565b61030b610c26565b61034c61064e366004612da8565b610c30565b61036162093a8081565b61038a61066b366004612da8565b610c39565b61034c61067e366004612da8565b610cbe565b61034c610691366004612da8565b610cc7565b61034c6106a4366004612dc5565b610cd0565b61034c6106b7366004612f64565b610cd9565b61030b610ce3565b6105e560405180604001604052806005815260200164312e302e3360d81b81525081565b60006106f2610d13565b905090565b60006106f2610d2f565b60006106f2610d4b565b60006106f2610d67565b61071e81610d83565b50565b600061072c82610e17565b92915050565b61071e81610e54565b60006106f2610edd565b600061074f610ef3565b805490915060ff600160401b820416159067ffffffffffffffff166000811580156107775750825b905060008267ffffffffffffffff1660011480156107945750303b155b9050811580156107a2575080155b156107c05760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff1916600117855583156107ea57845460ff60401b1916600160401b1785555b6107f330610f17565b856107fc610f28565b80546001600160a01b0319166001600160a01b0392909216919091179055831561086057845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b61071e81610f4c565b610879610fae565b565b60006106f261105e565b60006106f261107a565b60006106f2611096565b60006106f26108c960017f6f55f470bdc9cb5f04223fd822021061668e4dccb43e8727b295106dc9769c8b613002565b5490565b61071e816110b2565b61071e81611140565b61071e816111c9565b6108f430848484611252565b505050565b61071e816115c3565b61090c828261164c565b5050565b60006106f26108c960017f812a673dfca07956350df10f8a654925f561d7a0da09bdbe79e653939a14d9f1613002565b60006106f2611731565b33301461099c5760405162461bcd60e51b815260206004820152601b60248201527a24b731b932b0b9b2903932bb34b9b4b7b7103337b93134b23232b760291b60448201526064015b60405180910390fd5b60006109ba6108c960016000805160206130fe833981519152613002565b6109c5906001613015565b90506109e7816109e460016000805160206130fe833981519152613002565b55565b610a16826109e460017fbfaaa2fb63266ff27c2da975f5894955056f50419af651a81f6c5060581857e4613002565b604080518281526001600160a01b03841660208201527ff27e2ef832a4eb8ed8ec553b875eecd44764cda95b1c24170e281539e0a869c891015b60405180910390a15050565b600061072c82611752565b60006106f26117a0565b61071e816117bc565b60006106f261181e565b61071e81611837565b61071e8161185d565b60006106f26118e6565b600080600080610b128686306001600160a01b031663c3dfdae66040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ae9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b0d9190613028565b611902565b9299919850965090945092505050565b60006106f26119af565b61090c82826119cb565b61071e81611a38565b61071e81611ac1565b61071e81611b4a565b600061072c82611bd3565b60006106f26108c960016000805160206130fe833981519152613002565b60006106f2611c02565b60006106f2611c1e565b61071e81611c3a565b61071e81611cc3565b60006106f2611d4c565b60006106f26108c960017fbfaaa2fb63266ff27c2da975f5894955056f50419af651a81f6c5060581857e4613002565b60006106f2611d68565b60006106f2611d84565b60006106f2611da0565b6000610c02610ce3565b6001600160a01b0316826001600160a01b0316149050919050565b61071e81611dc6565b60006106f2611eff565b61071e81611f1b565b6000816001600160a01b0316610c4d610ce3565b6001600160a01b0316635aa6e6756040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c8a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cae9190613028565b6001600160a01b03161492915050565b61071e81611fa4565b61071e8161202d565b61071e816120b6565b61090c828261211c565b60006106f26108c960017f5165972ef41194f06c5007493031d0b927c20741adcb74403b954009fd2c3618613002565b6000610d1d610f28565b600201546001600160a01b0316919050565b6000610d39610f28565b601301546001600160a01b0316919050565b6000610d55610f28565b600a01546001600160a01b0316919050565b6000610d71610f28565b601101546001600160a01b0316919050565b610d8b612194565b6001600160a01b038116610db25760405163d92e233d60e01b815260040160405180910390fd5b80610dbb610f28565b60060180546001600160a01b0319166001600160a01b03929092169190911790556040517f5d77c617926cd1f4106de1bae23b2eb1a9d6e84911f701858a0b1d831e92816590610e0c908390612d6f565b60405180910390a150565b600061072c6a084595161401484a000000610e3b68056bc75e2d6310000085613045565b610e45919061305c565b68056bc75e2d631000006121bc565b610e5c612194565b6001600160a01b038116610e835760405163d92e233d60e01b815260040160405180910390fd5b80610e8c610f28565b60130180546001600160a01b0319166001600160a01b03929092169190911790556040517fcaa89af641ab6d1a458e39f225a12c0d1137f317d718b8713054a445bd2cde6790610e0c908390612d6f565b6000610ee7610f28565b600e015460ff16919050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0090565b610f1f6121d2565b61071e816121f7565b7f4d96152d518acf5697a667aeb82f27b3218b679995afa077296a84fdcb65bb0090565b610f54612194565b80610f5d610f28565b60010180546001600160a01b0319166001600160a01b03929092169190911790556040517f93a15bbe6d7cb67fff86738ed92efd14e9fe04e7d30042086570034a2f2eb3c290610e0c908390612d6f565b33610fb7610f28565b600101546001600160a01b031614610fe4573360405163ba18f1e160e01b81526004016109939190612d6f565b33610fed610f28565b80546001600160a01b0319166001600160a01b0392909216919091179055611013610f28565b60010180546001600160a01b03191690556040517fb1476cf38ac36ee528f1ad1ae81bdb46de8807d42475e16078426bce6001396190611054903390612d6f565b60405180910390a1565b6000611068610f28565b600f01546001600160a01b0316919050565b6000611084610f28565b600801546001600160a01b0316919050565b60006110a0610f28565b600901546001600160a01b0316919050565b6110ba612194565b6001600160a01b0381166110e15760405163d92e233d60e01b815260040160405180910390fd5b806110ea610f28565b600e0160016101000a8154816001600160a01b0302191690836001600160a01b031602179055507fd86fc86ebea7a7d81c1a9fa7e0977cdafcfccf0cc35295a095231a7b28274e4981604051610e0c9190612d6f565b611148612194565b6001600160a01b03811661116f5760405163d92e233d60e01b815260040160405180910390fd5b80611178610f28565b60030180546001600160a01b0319166001600160a01b03929092169190911790556040517fecbc0f0d903f1b9964d257a8043a5ecdf9c55a8e3d0060fb920b40c4009a257d90610e0c908390612d6f565b6111d1612194565b6001600160a01b0381166111f85760405163d92e233d60e01b815260040160405180910390fd5b80611201610f28565b60120180546001600160a01b0319166001600160a01b03929092169190911790556040517fe34dace06c75fb12cb36ab5627f4ad085768e0e550b787566c647aa0cd052b0690610e0c908390612d6f565b61125b84612314565b6000806000806112a487878a6001600160a01b031663c3dfdae66040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ae9573d6000803e3d6000fd5b6040516323b872dd60e01b81526001600160a01b038a81166004830152306024830152604482018c90529498509296509094509250908816906323b872dd906064016020604051808303816000875af1158015611305573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611329919061307e565b50801561140457866001600160a01b031663a9059cbb896001600160a01b0316630359fea96040518163ffffffff1660e01b8152600401602060405180830381865afa15801561137d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113a19190613028565b836040518363ffffffff1660e01b81526004016113bf92919061309b565b6020604051808303816000875af11580156113de573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611402919061307e565b505b82156114de57866001600160a01b031663a9059cbb896001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611457573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061147b9190613028565b856040518363ffffffff1660e01b815260040161149992919061309b565b6020604051808303816000875af11580156114b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114dc919061307e565b505b831561155157604051630852cd8d60e31b8152600481018590526001600160a01b038816906342966c68906024016020604051808303816000875af115801561152b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061154f919061307e565b505b61155a87612624565b604080516001600160a01b03898116825260208201899052871681830152606081018690526080810185905260a0810184905290517f1fd334c200f7b34cefbcb9762981e99dea5bdff9c149c5e4a279a1f55e8c97729181900360c00190a15050505050505050565b6115cb612194565b6001600160a01b0381166115f25760405163d92e233d60e01b815260040160405180910390fd5b806115fb610f28565b600f0180546001600160a01b0319166001600160a01b03929092169190911790556040517f0d1f076dd618d44fc1ed0ae909dcb5a875262080a1fb3386f155e47003323ed790610e0c908390612d6f565b611654612bf9565b60005b82518110156108f457828181518110611672576116726130b4565b60200260200101516001600160a01b0316630900f010836040518263ffffffff1660e01b81526004016116a59190612d6f565b600060405180830381600087803b1580156116bf57600080fd5b505af11580156116d3573d6000803e3d6000fd5b505050507fd32d24edea94f55e932d9a008afc425a8561462d1b1f57bc6e508e9a6b9509e183828151811061170a5761170a6130b4565b6020026020010151836040516117219291906130ca565b60405180910390a1600101611657565b600061173b610f28565b600e015461010090046001600160a01b0316919050565b60008061175d610f28565b6001600160a01b0384166000908152600d9190910160205260409020549050801580159061178a57508042105b80611799575061179983612c21565b9392505050565b60006117aa610f28565b600301546001600160a01b0316919050565b6117c4612194565b806117cd610f28565b60140180546001600160a01b0319166001600160a01b03929092169190911790556040517f1d609dbce8c46093a144a3723e81b905c328eb5034d986a74301fb4764ded28190610e0c908390612d6f565b6000611828610f28565b546001600160a01b0316919050565b61183f612bf9565b80611848610f28565b600e01805460ff191691151591909117905550565b611865612194565b6001600160a01b03811661188c5760405163d92e233d60e01b815260040160405180910390fd5b80611895610f28565b60020180546001600160a01b0319166001600160a01b03929092169190911790556040517f573b0be2ffc8c66825968c4e3b38a0af5edb18ce20f9a516e0f8a04867d2638990610e0c908390612d6f565b60006118f0610f28565b600501546001600160a01b0316919050565b600080600080846001600160a01b0316876001600160a01b03160361195557600261192d8588613002565b611937919061305c565b9250826119448588613002565b61194e9190613002565b91506119a6565b620186a06119666201388088613045565b611970919061305c565b9050620186a061198261271088613045565b61198c919061305c565b9250826119998288613002565b6119a39190613002565b91505b93509350935093565b60006119b9610f28565b600601546001600160a01b0316919050565b6119d3612194565b8015611a02576119e1610f28565b6001600160a01b0383166000908152600d9190910160205260408120555050565b611a0f62093a8042613015565b611a17610f28565b6001600160a01b0384166000908152600d9190910160205260409020555050565b611a40612194565b6001600160a01b038116611a675760405163d92e233d60e01b815260040160405180910390fd5b80611a70610f28565b60090180546001600160a01b0319166001600160a01b03929092169190911790556040517fedcd6ea89a41d21f1bafa9a7cc32e754079d18642839a1a48c938447d2a740eb90610e0c908390612d6f565b611ac9612194565b6001600160a01b038116611af05760405163d92e233d60e01b815260040160405180910390fd5b80611af9610f28565b60040180546001600160a01b0319166001600160a01b03929092169190911790556040517f0e05ae75e8b926552cf6fcd744d19f422561e3ced1e426868730852702dbe41890610e0c908390612d6f565b611b52612194565b6001600160a01b038116611b795760405163d92e233d60e01b815260040160405180910390fd5b80611b82610f28565b60110180546001600160a01b0319166001600160a01b03929092169190911790556040517f657bb19de5473f7be7de9ccbcfa6d9aabcb3cfd199aef85e949a1d8570c290ab90610e0c908390612d6f565b6000611bdd610f28565b6001600160a01b039092166000908152600c9290920160205250604090205460ff1690565b6000611c0c610f28565b600401546001600160a01b0316919050565b6000611c28610f28565b600101546001600160a01b0316919050565b611c42612194565b6001600160a01b038116611c695760405163d92e233d60e01b815260040160405180910390fd5b80611c72610f28565b600b0180546001600160a01b0319166001600160a01b03929092169190911790556040517f035bee136adcafe288762d810fef741bc236d20bb1b469acb4c23e5357f0856790610e0c908390612d6f565b611ccb612194565b6001600160a01b038116611cf25760405163d92e233d60e01b815260040160405180910390fd5b80611cfb610f28565b60070180546001600160a01b0319166001600160a01b03929092169190911790556040517ffa195fffb4bf4e5339e2e98fb090f0d634c64261640c07c1ee6ee43d5f23516190610e0c908390612d6f565b6000611d56610f28565b600701546001600160a01b0316919050565b6000611d72610f28565b601201546001600160a01b0316919050565b6000611d8e610f28565b601401546001600160a01b0316919050565b6000611daa610f28565b60100154905080600003611dc35750678ac7230489e800005b90565b611dce612194565b6040516370a0823160e01b81526000906001600160a01b038316906370a0823190611dfd903090600401612d6f565b602060405180830381865afa158015611e1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e3e91906130e4565b9050801561090c57816001600160a01b031663a9059cbb611e5d610f28565b546040516001600160e01b031960e084901b168152611e8a916001600160a01b031690859060040161309b565b6020604051808303816000875af1158015611ea9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ecd919061307e565b507fd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a8282604051610a5092919061309b565b6000611f09610f28565b600b01546001600160a01b0316919050565b611f23612194565b6001600160a01b038116611f4a5760405163d92e233d60e01b815260040160405180910390fd5b80611f53610f28565b600a0180546001600160a01b0319166001600160a01b03929092169190911790556040517fd1e9a4ae1231531a757f1e31a2ff8a1db9d359a194436efe40bccb972cde86f090610e0c908390612d6f565b611fac612194565b6001600160a01b038116611fd35760405163d92e233d60e01b815260040160405180910390fd5b80611fdc610f28565b60080180546001600160a01b0319166001600160a01b03929092169190911790556040517f29fdde0e067ae34f44ca706fd84ea4b9dabb69557e7e935d379c932ba023b2be90610e0c908390612d6f565b612035612194565b6001600160a01b03811661205c5760405163d92e233d60e01b815260040160405180910390fd5b80612065610f28565b60050180546001600160a01b0319166001600160a01b03929092169190911790556040517fc714d22a2f08b695f81e7c707058db484aa5b4d6b4c9fd64beb10fe85832f60890610e0c908390612d6f565b6120be612194565b806000036120df57604051631f2a200560e01b815260040160405180910390fd5b806120e8610f28565b601001556040518181527f867c590cfc1b2ba6732d5d876a96733ad5cde9c836a978d6107517c00cf3f44590602001610e0c565b612124612194565b8061212d610f28565b6001600160a01b0384166000818152600c929092016020908152604092839020805460ff1916941515949094179093558151908152831515928101929092527f0de9c5667496fd561ff9dfa59efdc1c76f7dbf3844adae3d14a3a14d563321b19101610a50565b61219d33612c21565b610879573360405163988d1f0360e01b81526004016109939190612d6f565b60008183106121cb5781611799565b5090919050565b6121da612c6b565b61087957604051631afcd79f60e31b815260040160405180910390fd5b6001600160a01b03811661223f5760405162461bcd60e51b815260206004820152600f60248201526e2d32b9379031b7b73a3937b63632b960891b6044820152606401610993565b61226e816109e460017f5165972ef41194f06c5007493031d0b927c20741adcb74403b954009fd2c3618613002565b61229d426109e460017f6f55f470bdc9cb5f04223fd822021061668e4dccb43e8727b295106dc9769c8b613002565b6122cc436109e460017f812a673dfca07956350df10f8a654925f561d7a0da09bdbe79e653939a14d9f1613002565b604080516001600160a01b038316815242602082015243918101919091527f1a2dd071001ebf6e03174e3df5b305795a4ad5d41d8fdb9ba41dbbe23671342690606001610e0c565b336001600160a01b0316816001600160a01b031663016dff5d6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561235c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123809190613028565b6001600160a01b03161415801561240a5750336001600160a01b0316816001600160a01b031663490fb76a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156123da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123fe9190613028565b6001600160a01b031614155b80156124895750336001600160a01b0316816001600160a01b03166325eb1c876040518163ffffffff1660e01b8152600401602060405180830381865afa158015612459573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061247d9190613028565b6001600160a01b031614155b80156125085750336001600160a01b0316816001600160a01b0316632f91ede96040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124fc9190613028565b6001600160a01b031614155b80156125875750336001600160a01b0316816001600160a01b03166331423c266040518163ffffffff1660e01b8152600401602060405180830381865afa158015612557573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061257b9190613028565b6001600160a01b031614155b80156126065750336001600160a01b0316816001600160a01b031663524a562f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156125d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125fa9190613028565b6001600160a01b031614155b1561071e5760405163f20e063760e01b815260040160405180910390fd5b600061262e610f28565b601401546001600160a01b03169050801561090c576000816001600160a01b031663ff3a4ac06040518163ffffffff1660e01b8152600401602060405180830381865afa158015612683573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126a79190613028565b9050806001600160a01b0316836001600160a01b0316036128a257816001600160a01b0316631ed241956040518163ffffffff1660e01b8152600401602060405180830381865afa158015612700573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061272491906130e4565b826001600160a01b0316630a441f7b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612762573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061278691906130e4565b10156108f4576040516370a0823160e01b81526000906001600160a01b038516906370a08231906127bb903090600401612d6f565b602060405180830381865afa1580156127d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127fc91906130e4565b9050801561280f5761280f848285612c85565b60405163e270d1df60e01b8152600481018290526001600160a01b0384169063e270d1df90602401600060405180830381600087803b15801561285157600080fd5b505af1925050508015612862575060015b1561289c576040518181527fd1c043d38a3243c01780647a1340049807cd98af891021c89c32c99a8e0c59e7906020015b60405180910390a15b50505050565b6040516370a0823160e01b81526000906001600160a01b038516906370a08231906128d1903090600401612d6f565b602060405180830381865afa1580156128ee573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061291291906130e4565b9050826001600160a01b0316636180c3f9846001600160a01b03166379d83f8e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612961573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129859190613028565b866040518363ffffffff1660e01b81526004016129a39291906130ca565b602060405180830381865afa1580156129c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129e491906130e4565b811180156129fe575060006129fc62093a808361305c565b115b15612aa657612a0e848285612c85565b60405163b66503cf60e01b81526001600160a01b0384169063b66503cf90612a3c908790859060040161309b565b600060405180830381600087803b158015612a5657600080fd5b505af1925050508015612a67575060015b15612aa6577ff6b60b7da8e0f883e399412005b6205515604a993e7e3f0c3b199b9cb07d6ae68482604051612a9d92919061309b565b60405180910390a15b826001600160a01b0316631ed241956040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ae4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b0891906130e4565b836001600160a01b0316630a441f7b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b46573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b6a91906130e4565b101561289c5760405163e270d1df60e01b8152600060048201526001600160a01b0384169063e270d1df90602401600060405180830381600087803b158015612bb257600080fd5b505af1925050508015612bc3575060015b1561289c57604051600081527fd1c043d38a3243c01780647a1340049807cd98af891021c89c32c99a8e0c59e790602001612893565b612c0233611752565b610879573360405163451cea1760e11b81526004016109939190612d6f565b6000816001600160a01b0316306001600160a01b0316635aa6e6756040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c8a573d6000803e3d6000fd5b6000612c75610ef3565b54600160401b900460ff16919050565b604051636eb1769f60e11b815282906001600160a01b0385169063dd62ed3e90612cb590309086906004016130ca565b602060405180830381865afa158015612cd2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cf691906130e4565b10156108f45760405163095ea7b360e01b81526001600160a01b0384169063095ea7b390612d2c9084906000199060040161309b565b6020604051808303816000875af1158015612d4b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061289c919061307e565b6001600160a01b0391909116815260200190565b6001600160a01b038116811461071e57600080fd5b8035612da381612d83565b919050565b600060208284031215612dba57600080fd5b813561179981612d83565b600060208284031215612dd757600080fd5b5035919050565b600080600060608486031215612df357600080fd5b8335612dfe81612d83565b9250602084013591506040840135612e1581612d83565b809150509250925092565b634e487b7160e01b600052604160045260246000fd5b60008060408385031215612e4957600080fd5b823567ffffffffffffffff80821115612e6157600080fd5b818501915085601f830112612e7557600080fd5b8135602082821115612e8957612e89612e20565b8160051b604051601f19603f83011681018181108682111715612eae57612eae612e20565b604052928352818301935084810182019289841115612ecc57600080fd5b948201945b83861015612ef157612ee286612d98565b85529482019493820193612ed1565b9650612f009050878201612d98565b9450505050509250929050565b801515811461071e57600080fd5b600060208284031215612f2d57600080fd5b813561179981612f0d565b60008060408385031215612f4b57600080fd5b8235612f5681612d83565b946020939093013593505050565b60008060408385031215612f7757600080fd5b8235612f8281612d83565b91506020830135612f9281612f0d565b809150509250929050565b60006020808352835180602085015260005b81811015612fcb57858101830151858201604001528201612faf565b506000604082860101526040601f19601f8301168501019250505092915050565b634e487b7160e01b600052601160045260246000fd5b8181038181111561072c5761072c612fec565b8082018082111561072c5761072c612fec565b60006020828403121561303a57600080fd5b815161179981612d83565b808202811582820484141761072c5761072c612fec565b60008261307957634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561309057600080fd5b815161179981612f0d565b6001600160a01b03929092168252602082015260400190565b634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831681529116602082015260400190565b6000602082840312156130f657600080fd5b505191905056fe22573091f17911fb166032a3d9e0554aa73d31b7b7ddea4a4dd2995650af84bda2646970667358221220b0d0360bf4ecefccd5606caec889b71d89f0504dd40497f2592c36b15f2a7c3c64736f6c63430008170033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in S
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
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.