Contract 0x0e22b5f3e11944578b37ed04f5312dfc246f443c 3

 
Txn Hash Method
Block
From
To
Value
0x046fd80d70413f19bc8c6d09d4587abc8e9899d429924eca478df005f3d3987bBonk Commit132302362024-04-16 6:43:393 secs ago0xda746dbe66ab5af87173810020b3e4844f400bc9 IN  Fren Pet: Diamond0 ETH0.0000030032930.018772723
0x4650e05477fd38ee8ad241696652348f30cf5fc96f8c3dd8dcd5c027b1744760Bonk Reveal132302362024-04-16 6:43:393 secs ago0x8817a23d3d626d01bcd9e6a347dbac2dcae76148 IN  Fren Pet: Diamond0 ETH0.0000021228250.018866723
0x96dce7472d79fb139420b6b2fbefdf11824fd5fd7aaaa53fac95845e0f11d3dcBonk Reveal132302362024-04-16 6:43:393 secs ago0x2037b9890a4f3b0b7a292bd7159ad32e2c9ae7b7 IN  Fren Pet: Diamond0 ETH0.0000021785740.019766723
0x601338c499abd755e41b916de066eecfcb891eff8c7f0389dbcc3154ffc2507dBonk Commit132302342024-04-16 6:43:357 secs ago0x510cf2d6116c88b1eab51d84f71eebfbf071e5ef IN  Fren Pet: Diamond0 ETH0.0000030094420.018819541
0x95173eb190a89135b2c8b5c2351e28143017f9a890e4ca203c4734ad1619427aBonk Commit132302322024-04-16 6:43:3111 secs ago0x80a78d7f52e688eb38e20d390070e55abbacfd82 IN  Fren Pet: Diamond0 ETH0.0000030172230.018865325
0xef9c7312385c75e1258defcf5c69612ee7f024eaa8813ca43fc67fe228b6fc7aBonk Commit132302302024-04-16 6:43:2715 secs ago0x2037b9890a4f3b0b7a292bd7159ad32e2c9ae7b7 IN  Fren Pet: Diamond0 ETH0.000003176990.019886795
0x509b93d322e38c68360f24c12e84b300b24a2937ce875baaf37634acf72f92dcBonk Commit132302292024-04-16 6:43:2517 secs ago0xf93e6345cfec0142d0adaae3284d4167f811d075 IN  Fren Pet: Diamond0 ETH0.0000035243180.0221
0xc0dbfcfd1d0ca91682b9f6d093545a1a9c3c325b2691ae403cc1285ecfe884180x35408eea132302282024-04-16 6:43:2319 secs ago0xc9989ed90340756c0be7af862184f06e7a5475f6 IN  Fren Pet: Diamond0 ETH0.0000014808170.018914416
0x9f05e01cc122c9d67ffe676d4ab8787aa8fa26dfeedfd483be76a41cd3248f7cBonk Reveal132302282024-04-16 6:43:2319 secs ago0x0bc454f5fccccad173d1de64912e1f47e46f2e35 IN  Fren Pet: Diamond0 ETH0.0000020948750.019008416
0x25f84cc7a16c2908bfc6afd1dd76ee9022829390fc507f59829ff001a1bbae68Mint132302272024-04-16 6:43:2121 secs ago0xde90a186c04cecfe67beee9a9f9ecccaf54e86a7 IN  Fren Pet: Diamond0 ETH0.0000036351570.019027228
0xf4b840ff7e216387264f4e815c2e44804028b48bf3d7880baaad9fde10359353Wheel Reveal132302262024-04-16 6:43:1923 secs ago0x96abf70bca92b7622981881d5de2001bf20c4248 IN  Fren Pet: Diamond0 ETH0.0000019885760.018940201
0xdf747e7a1b950a65e1704e974394bcdd18cb853b037b4c88d2a473b7e497c936Bonk Reveal132302262024-04-16 6:43:1923 secs ago0x22daf9f4f902fa08e7037deb79079a825f1f93bc IN  Fren Pet: Diamond0 ETH0.0000009645050.018940201
0xd3cc8506c5d555c85c27f1557581f09a57e0735e4658b25500bfa3271ce066daBonk Reveal132302262024-04-16 6:43:1923 secs ago0x651195094cb3d42c985f67a874975e6763874f1b IN  Fren Pet: Diamond0 ETH0.0000020978560.019034201
0xd37a482aeb2805cd2ec03d1afcf2e92d4b21d499846c061354fb1bdeda8a4de9Bonk Reveal132302262024-04-16 6:43:1923 secs ago0xbcfe7e3be6facff89580e5d0bee5ef45738818d0 IN  Fren Pet: Diamond0 ETH0.000001013670.019934201
0x6caf9be1ff2f6203f920d28ea2bf233e6d096bb51d50f306fd66c8011579e25e0x0f6f3564132302252024-04-16 6:43:1725 secs ago0xc9989ed90340756c0be7af862184f06e7a5475f6 IN  Fren Pet: Diamond0 ETH0.000002167190.018958328
0x0d4bab39fc02eb2f52bec34adc15e63a7bafa57ca23aed0c47d4b3484d83b250Bonk Commit132302252024-04-16 6:43:1725 secs ago0x0bc454f5fccccad173d1de64912e1f47e46f2e35 IN  Fren Pet: Diamond0 ETH0.0000030458250.019052328
0x5ab3929feba819b3b0e867ca5346e4fed97d69d64bfc76af5e0d9552264e9129Bonk Commit132302242024-04-16 6:43:1527 secs ago0x8817a23d3d626d01bcd9e6a347dbac2dcae76148 IN  Fren Pet: Diamond0 ETH0.0000030467340.019053562
0xcd8ba0dfaba650c976aab7bebf73ad9c4b88380fd1d4305f9cf57da31256e74c0x35408eea132302242024-04-16 6:43:1527 secs ago0x4fddb2ec825c2c40c744c361401bcc3a47eb70bd IN  Fren Pet: Diamond0 ETH0.000001817060.019053562
0x0094f6f3b0dc11b401507fc5c8d1a468cb4d2fcffc1e14770f173e4a66e4a471Bonk Reveal132302242024-04-16 6:43:1527 secs ago0x0242c808f8fb04ecf6e53cb321f6030acdc298aa IN  Fren Pet: Diamond0 ETH0.0000021980310.019953562
0xea3acf4a55ed3a2fc70327c81dac99464fcabe4ccc2b6451b647d1ba855236eaWheel Commit132302232024-04-16 6:43:1329 secs ago0x96abf70bca92b7622981881d5de2001bf20c4248 IN  Fren Pet: Diamond0 ETH0.0000019765380.018966286
0x40d81e3d40a0272b01f7650ea050cc787856048e65a2ada82955c5c5a72ae5230x35408eea132302212024-04-16 6:43:0933 secs ago0xdbda4f94a1c7db5b2831c4bf4c354287a687f9ef IN  Fren Pet: Diamond0 ETH0.0000014875180.018987651
0x13183fbf184a1c151137cb562db3dd8ec484dd89dcc11c753c68f7e9307ec5cfBonk Reveal132302212024-04-16 6:43:0933 secs ago0x5b92d2b38ab372bff63f55113b98253adff62a74 IN  Fren Pet: Diamond0 ETH0.0000024430410.0222
0x000aadf5efd07e1acb1a2ff3c74cea43558d53d39b0b86dc88e168054adaf9c7Bonk Commit132302192024-04-16 6:43:0537 secs ago0xbcfe7e3be6facff89580e5d0bee5ef45738818d0 IN  Fren Pet: Diamond0 ETH0.0000031934040.019970756
0xc8b71f8890754082728b63fb8c3961904725df9aebfe3cf8669abd279920a38c0x0f6f3564132302182024-04-16 6:43:0339 secs ago0xdbda4f94a1c7db5b2831c4bf4c354287a687f9ef IN  Fren Pet: Diamond0 ETH0.0000021704150.018962821
0x36ca0306870969b705cf6f9cecf24921638c2c77367b1b171f2c632f1b5c4808Bonk Commit132302182024-04-16 6:43:0339 secs ago0x651195094cb3d42c985f67a874975e6763874f1b IN  Fren Pet: Diamond0 ETH0.0000030500780.019056821
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0xe2196f63c8a56be05c66a78d6fd15b703855bd314acbdcf83bc4598a68660674132290002024-04-16 6:02:2741 mins ago Fren Pet: Diamond0x2932668e66ce10944471f79d59a2f9481a372a8e0.000017987610847338 ETH
0x4369066111938532e6996ee17f99ff1758590b9dcd41d85a7a354204d0ab72e6132278192024-04-16 5:23:051 hr 20 mins ago 0x54c4dd8c2e124c65f55e1e096ab1fb6543e1206c Fren Pet: Diamond0.363094996647895954 ETH
0xb5e6368f8d961bbc30660e95c63ee2ca0fd50bfb7e508412d1585c6765166d38132277772024-04-16 5:21:411 hr 22 mins ago 0x54c4dd8c2e124c65f55e1e096ab1fb6543e1206c Fren Pet: Diamond0.194712330034401491 ETH
0x0b5e55ceeab3dfce13ee480d3ae2b5113110ed688df14083f55d2af020558ed9132273902024-04-16 5:08:471 hr 34 mins ago Fren Pet: Diamond0x70cb1ec418175695900aa891cad1b40e367680950.033288055387765855 ETH
0x14e9fca3464d86a9f81243eadad8097c94d3506581a67d843c7842cefc1f02b5132271882024-04-16 5:02:031 hr 41 mins ago 0x54c4dd8c2e124c65f55e1e096ab1fb6543e1206c Fren Pet: Diamond0.110902916611208285 ETH
0x889fe700af5a45e8d5ac2e815f187dcdfbb4665c3ee4246db4fd47a9c61fc5e2132261782024-04-16 4:28:232 hrs 15 mins ago 0x54c4dd8c2e124c65f55e1e096ab1fb6543e1206c Fren Pet: Diamond0.147383734111199436 ETH
0xe5fde9b3e8c121ff17b1f7991fa2635bd09d613df3930b3221b43a1619c7bb37132261302024-04-16 4:26:472 hrs 16 mins ago 0x54c4dd8c2e124c65f55e1e096ab1fb6543e1206c Fren Pet: Diamond0.094710927750434814 ETH
0x365ab371b59a0cefbc0d27bbff6491ea45bdc349b4638308d8c3aecb3ff0fa64132251962024-04-16 3:55:392 hrs 48 mins ago Fren Pet: Diamond0x0564f04eab85b2971943db41a4aa4046beb9c0d00.161717485772961022 ETH
0xc33a22f32efa6a7361ba212b034006b1eec350d14428c459536a98c131396550132248722024-04-16 3:44:512 hrs 58 mins ago Fren Pet: Diamond0xbf648796ffe450d3f47cbf7cd2b74f8c204dca290.000710696259985696 ETH
0x995459df3aaf14dd6ae548ad8387eb37e1aaaba85f394c1b4cd39fdcbab0a182132240982024-04-16 3:19:033 hrs 24 mins ago Fren Pet: Diamond0xbf648796ffe450d3f47cbf7cd2b74f8c204dca290.01186071334022762 ETH
0xca355e7666c0b87fb17b11c82e8ac5f8090ac40af6e341dd3c9515bc5732e952132236562024-04-16 3:04:193 hrs 39 mins ago 0x54c4dd8c2e124c65f55e1e096ab1fb6543e1206c Fren Pet: Diamond0.114874032864150898 ETH
0x83482ed544ddff424be29654d9d901e1cf3c292616742dcd9fcd170f08c4e53c132236512024-04-16 3:04:093 hrs 39 mins ago Fren Pet: Diamond0x2448b441708b87adc926a143c63cc177d58e1b2b0.011229036223460362 ETH
0x8da49818183fc521618ba97d9406609e7e16b5bddd8783ba3150d4ad3f9da83e132230622024-04-16 2:44:313 hrs 59 mins ago Fren Pet: Diamond0xcdcea7684eaca52a6d909baf7e75c21639a07cef0.000029348507114013 ETH
0xa14a843f74e7a96cf9cddcb36944d3370567f1b0f1ab6ad318ef4286a6106536132222252024-04-16 2:16:374 hrs 27 mins ago 0x54c4dd8c2e124c65f55e1e096ab1fb6543e1206c Fren Pet: Diamond0.170109760071041313 ETH
0x6365d469f71f85b46033476c5b03752f9694106d5b64022cf8e9dee0b35956ef132218072024-04-16 2:02:414 hrs 41 mins ago 0x54c4dd8c2e124c65f55e1e096ab1fb6543e1206c Fren Pet: Diamond0.082609571799022473 ETH
0x633215eb93b7b39804a550e2dc51e90d1690bc7917b5cdbee09306abb24efccb132211982024-04-16 1:42:235 hrs 1 min ago Fren Pet: Diamond0x2d18f5559fb508c5209bd8938bbae01043db65680.013679430800950566 ETH
0x3601e9dc5ff434caa804f467053bee585e69f5aa1d1319b608c386171fb3cf61132200192024-04-16 1:03:055 hrs 40 mins ago Fren Pet: Diamond0xaa0ef59d22cc5ccf4bbcd26a944a4ac252969d750.016044722232016024 ETH
0xaf60ea56e08a696a38dcbdaadbfcdfda33472a08c346c2947c70278405a4143f132197882024-04-16 0:55:235 hrs 48 mins ago Fren Pet: Diamond0x6161bd51bc804c5cd69cf9e657ec2aa52ab4df310.000292514761769437 ETH
0xbf6eff3b99acd04110a302c8f5e778429aa2def346cd112779b03fcc26ae0a6b132197502024-04-16 0:54:075 hrs 49 mins ago Fren Pet: Diamond0x6161bd51bc804c5cd69cf9e657ec2aa52ab4df310.000002830524835273 ETH
0xa765f4a0b7b6bbabded646b5861bbfc42bc9be89ef5bc31afdbee45bf8d9eea6132197332024-04-16 0:53:335 hrs 50 mins ago Fren Pet: Diamond0x6161bd51bc804c5cd69cf9e657ec2aa52ab4df310.000002830524835273 ETH
0x4fb3c5cfbc02bf450a94580da67fd81f5678ef443a5c2488b2ecb4f03c47e3e3132197152024-04-16 0:52:575 hrs 50 mins ago Fren Pet: Diamond0x8b87a6b8a8f21e7b76359249856d9e15c42df1290.001462573808847186 ETH
0xdd01030f9db7eb60e493e9c2ab519e664863db767e762a45aa98bcccb492cec1132191982024-04-16 0:35:436 hrs 7 mins ago 0x54c4dd8c2e124c65f55e1e096ab1fb6543e1206c Fren Pet: Diamond0.087941832300874685 ETH
0xd9ce917f85be5e3a1d379018c5cfcc84a2a4d1ab4718f68889df8a9f059bcab4132188762024-04-16 0:24:596 hrs 18 mins ago Fren Pet: Diamond0xa52513d8ad0fc0133e4f2d0e4694564c757ef5530.002079654454959456 ETH
0x499a7125cfe707e1afa73f9f365269b1b13469e9cd9df993378112aa0197d136132188712024-04-16 0:24:496 hrs 18 mins ago Fren Pet: Diamond0x923e274a3c1031a6d5d0c7c86760d3f0be0ed4b40.002133602290587523 ETH
0x22ddc9cf1a390439ae4f6af0f6af27dc58e8793f9af48dfdb59feb5b06f253a4132188672024-04-16 0:24:416 hrs 19 mins ago Fren Pet: Diamond0x781ed8ef61233b102a68b899ccaba2e3287d0a6c0.002950470157229044 ETH
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Diamond

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
File 1 of 11 : Diamond.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

/******************************************************************************\
* Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen)
* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535
*
* Implementation of a diamond.
/******************************************************************************/

// import {AppStorage} from "./libraries/LibAppStorage.sol";

import {LibDiamond} from "./libraries/LibDiamond.sol";
import {AppStorage, LibAppStorage} from "./libraries/LibAppStorage.sol";

import {IDiamondCut} from "./interfaces/IDiamondCut.sol";
import {IDiamondLoupe} from "./interfaces/IDiamondLoupe.sol";
// import {IERC173} from "./interfaces/IERC173.sol";
//import { IERC165} from "./interfaces/IERC165.sol";
import {FixedPointMathLib} from "solmate/utils/FixedPointMathLib.sol";

// When no function exists for function called
error FunctionNotFound(bytes4 _functionSelector);

// This is used in diamond constructor
// more arguments are added to this struct
// this avoids stack too deep errors
struct DiamondArgs {
    address owner;
    address init;
    bytes initCalldata;
}

contract Diamond {
    using FixedPointMathLib for uint256;

    constructor(
        IDiamondCut.FacetCut[] memory _diamondCut,
        DiamondArgs memory _args
    ) payable {
        LibDiamond.setContractOwner(_args.owner);
        LibDiamond.diamondCut(_diamondCut, _args.init, _args.initCalldata);

        // Code can be added here to perform actions and set state variables.
    }

    // Find facet for function that is called and execute the
    // function if a facet is found and return any value.
    fallback() external payable {
        LibDiamond.DiamondStorage storage ds;
        bytes32 position = LibDiamond.DIAMOND_STORAGE_POSITION;
        // get diamond storage
        assembly {
            ds.slot := position
        }
        // get facet from function selector
        address facet = ds
            .facetAddressAndSelectorPosition[msg.sig]
            .facetAddress;
        if (facet == address(0)) {
            revert FunctionNotFound(msg.sig);
        }
        // Execute external function from facet using delegatecall and return any value.
        assembly {
            // copy function selector and any arguments
            calldatacopy(0, 0, calldatasize())
            // execute function call using the facet
            let result := delegatecall(gas(), facet, 0, calldatasize(), 0, 0)
            // get any return value
            returndatacopy(0, 0, returndatasize())
            // return any return value or error back to the caller
            switch result
            case 0 {
                revert(0, returndatasize())
            }
            default {
                return(0, returndatasize())
            }
        }
    }

    receive() external payable {
        AppStorage storage s = LibAppStorage.appStorage();
        s.ethAccPerShare += msg.value.mulDivDown(s.PRECISION, s.totalScores);
    }
}

File 2 of 11 : LibDiamond.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

/******************************************************************************\
* Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen)
* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535
/******************************************************************************/
import {IDiamond} from "../interfaces/IDiamond.sol";
import {IDiamondCut} from "../interfaces/IDiamondCut.sol";

// Remember to add the loupe functions from DiamondLoupeFacet to the diamond.
// The loupe functions are required by the EIP2535 Diamonds standard

error NoSelectorsGivenToAdd();
error NotContractOwner(address _user, address _contractOwner);
error NoSelectorsProvidedForFacetForCut(address _facetAddress);
error CannotAddSelectorsToZeroAddress(bytes4[] _selectors);
error NoBytecodeAtAddress(address _contractAddress, string _message);
error IncorrectFacetCutAction(uint8 _action);
error CannotAddFunctionToDiamondThatAlreadyExists(bytes4 _selector);
error CannotReplaceFunctionsFromFacetWithZeroAddress(bytes4[] _selectors);
error CannotReplaceImmutableFunction(bytes4 _selector);
error CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet(
    bytes4 _selector
);
error CannotReplaceFunctionThatDoesNotExists(bytes4 _selector);
error RemoveFacetAddressMustBeZeroAddress(address _facetAddress);
error CannotRemoveFunctionThatDoesNotExist(bytes4 _selector);
error CannotRemoveImmutableFunction(bytes4 _selector);
error InitializationFunctionReverted(
    address _initializationContractAddress,
    bytes _calldata
);

library LibDiamond {
    bytes32 constant DIAMOND_STORAGE_POSITION =
        keccak256("diamond.standard.diamond.storage");

    struct FacetAddressAndSelectorPosition {
        address facetAddress;
        uint16 selectorPosition;
    }

    struct DiamondStorage {
        // function selector => facet address and selector position in selectors array
        mapping(bytes4 => FacetAddressAndSelectorPosition) facetAddressAndSelectorPosition;
        bytes4[] selectors;
        mapping(bytes4 => bool) supportedInterfaces;
        // owner of the contract
        address contractOwner;
    }

    function diamondStorage()
        internal
        pure
        returns (DiamondStorage storage ds)
    {
        bytes32 position = DIAMOND_STORAGE_POSITION;
        assembly {
            ds.slot := position
        }
    }

    event OwnershipTransferred(
        address indexed previousOwner,
        address indexed newOwner
    );

    function setContractOwner(address _newOwner) internal {
        DiamondStorage storage ds = diamondStorage();
        address previousOwner = ds.contractOwner;
        ds.contractOwner = _newOwner;
        emit OwnershipTransferred(previousOwner, _newOwner);
    }

    function contractOwner() internal view returns (address contractOwner_) {
        contractOwner_ = diamondStorage().contractOwner;
    }

    function enforceIsContractOwner() internal view {
        if (msg.sender != diamondStorage().contractOwner) {
            revert NotContractOwner(msg.sender, diamondStorage().contractOwner);
        }
    }

    event DiamondCut(
        IDiamondCut.FacetCut[] _diamondCut,
        address _init,
        bytes _calldata
    );

    // Internal function version of diamondCut
    function diamondCut(
        IDiamondCut.FacetCut[] memory _diamondCut,
        address _init,
        bytes memory _calldata
    ) internal {
        for (
            uint256 facetIndex;
            facetIndex < _diamondCut.length;
            facetIndex++
        ) {
            bytes4[] memory functionSelectors = _diamondCut[facetIndex]
                .functionSelectors;
            address facetAddress = _diamondCut[facetIndex].facetAddress;
            if (functionSelectors.length == 0) {
                revert NoSelectorsProvidedForFacetForCut(facetAddress);
            }
            IDiamondCut.FacetCutAction action = _diamondCut[facetIndex].action;
            if (action == IDiamond.FacetCutAction.Add) {
                addFunctions(facetAddress, functionSelectors);
            } else if (action == IDiamond.FacetCutAction.Replace) {
                replaceFunctions(facetAddress, functionSelectors);
            } else if (action == IDiamond.FacetCutAction.Remove) {
                removeFunctions(facetAddress, functionSelectors);
            } else {
                revert IncorrectFacetCutAction(uint8(action));
            }
        }
        emit DiamondCut(_diamondCut, _init, _calldata);
        initializeDiamondCut(_init, _calldata);
    }

    function addFunctions(
        address _facetAddress,
        bytes4[] memory _functionSelectors
    ) internal {
        if (_facetAddress == address(0)) {
            revert CannotAddSelectorsToZeroAddress(_functionSelectors);
        }
        DiamondStorage storage ds = diamondStorage();
        uint16 selectorCount = uint16(ds.selectors.length);
        enforceHasContractCode(
            _facetAddress,
            "LibDiamondCut: Add facet has no code"
        );
        for (
            uint256 selectorIndex;
            selectorIndex < _functionSelectors.length;
            selectorIndex++
        ) {
            bytes4 selector = _functionSelectors[selectorIndex];
            address oldFacetAddress = ds
                .facetAddressAndSelectorPosition[selector]
                .facetAddress;
            if (oldFacetAddress != address(0)) {
                revert CannotAddFunctionToDiamondThatAlreadyExists(selector);
            }
            ds.facetAddressAndSelectorPosition[
                selector
            ] = FacetAddressAndSelectorPosition(_facetAddress, selectorCount);
            ds.selectors.push(selector);
            selectorCount++;
        }
    }

    function replaceFunctions(
        address _facetAddress,
        bytes4[] memory _functionSelectors
    ) internal {
        DiamondStorage storage ds = diamondStorage();
        if (_facetAddress == address(0)) {
            revert CannotReplaceFunctionsFromFacetWithZeroAddress(
                _functionSelectors
            );
        }
        enforceHasContractCode(
            _facetAddress,
            "LibDiamondCut: Replace facet has no code"
        );
        for (
            uint256 selectorIndex;
            selectorIndex < _functionSelectors.length;
            selectorIndex++
        ) {
            bytes4 selector = _functionSelectors[selectorIndex];
            address oldFacetAddress = ds
                .facetAddressAndSelectorPosition[selector]
                .facetAddress;
            // can't replace immutable functions -- functions defined directly in the diamond in this case
            if (oldFacetAddress == address(this)) {
                revert CannotReplaceImmutableFunction(selector);
            }
            if (oldFacetAddress == _facetAddress) {
                revert CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet(
                    selector
                );
            }
            if (oldFacetAddress == address(0)) {
                revert CannotReplaceFunctionThatDoesNotExists(selector);
            }
            // replace old facet address
            ds
                .facetAddressAndSelectorPosition[selector]
                .facetAddress = _facetAddress;
        }
    }

    function removeFunctions(
        address _facetAddress,
        bytes4[] memory _functionSelectors
    ) internal {
        DiamondStorage storage ds = diamondStorage();
        uint256 selectorCount = ds.selectors.length;
        if (_facetAddress != address(0)) {
            revert RemoveFacetAddressMustBeZeroAddress(_facetAddress);
        }
        for (
            uint256 selectorIndex;
            selectorIndex < _functionSelectors.length;
            selectorIndex++
        ) {
            bytes4 selector = _functionSelectors[selectorIndex];
            FacetAddressAndSelectorPosition
                memory oldFacetAddressAndSelectorPosition = ds
                    .facetAddressAndSelectorPosition[selector];
            if (oldFacetAddressAndSelectorPosition.facetAddress == address(0)) {
                revert CannotRemoveFunctionThatDoesNotExist(selector);
            }

            // can't remove immutable functions -- functions defined directly in the diamond
            if (
                oldFacetAddressAndSelectorPosition.facetAddress == address(this)
            ) {
                revert CannotRemoveImmutableFunction(selector);
            }
            // replace selector with last selector
            selectorCount--;
            if (
                oldFacetAddressAndSelectorPosition.selectorPosition !=
                selectorCount
            ) {
                bytes4 lastSelector = ds.selectors[selectorCount];
                ds.selectors[
                    oldFacetAddressAndSelectorPosition.selectorPosition
                ] = lastSelector;
                ds
                    .facetAddressAndSelectorPosition[lastSelector]
                    .selectorPosition = oldFacetAddressAndSelectorPosition
                    .selectorPosition;
            }
            // delete last selector
            ds.selectors.pop();
            delete ds.facetAddressAndSelectorPosition[selector];
        }
    }

    function initializeDiamondCut(
        address _init,
        bytes memory _calldata
    ) internal {
        if (_init == address(0)) {
            return;
        }
        enforceHasContractCode(
            _init,
            "LibDiamondCut: _init address has no code"
        );
        (bool success, bytes memory error) = _init.delegatecall(_calldata);
        if (!success) {
            if (error.length > 0) {
                // bubble up error
                /// @solidity memory-safe-assembly
                assembly {
                    let returndata_size := mload(error)
                    revert(add(32, error), returndata_size)
                }
            } else {
                revert InitializationFunctionReverted(_init, _calldata);
            }
        }
    }

    function enforceHasContractCode(
        address _contract,
        string memory _errorMessage
    ) internal view {
        uint256 contractSize;
        assembly {
            contractSize := extcodesize(_contract)
        }
        if (contractSize == 0) {
            revert NoBytecodeAtAddress(_contract, _errorMessage);
        }
    }
}

File 3 of 11 : LibAppStorage.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

import {LibDiamond} from "./LibDiamond.sol";

import {EnumerableMap} from "openzeppelin/utils/structs/EnumerableMap.sol";
import {IERC20Extended} from "../interfaces/IERC20Extended.sol";
import {IERC721Extended} from "../interfaces/IERC721Extended.sol";

// using EnumerableMap for EnumerableMap.UintToAddressMap;

// Declare a set state variable
// EnumerableMap.UintToAddressMap private myMap;

struct AppStorage {
    bool diamondInitialized;
    IERC20Extended token;
    IERC721Extended nft;
    address DIAMOND_ADDRESS; // facet where getters are stored, need to add a setter too in game manager facet
    // dutch auction
    uint256 duration;
    uint256 minPrice;
    uint256 startingPrice;
    uint256 startAt;
    uint256 discountRate;
    mapping(uint256 => uint256[]) petDna;
    // shop and items
    mapping(uint256 => uint256) itemPrice; //shop item id to price name this diff than items later
    mapping(uint256 => uint256) itemPoints;
    mapping(uint256 => string) itemName;
    mapping(uint256 => uint256) itemTimeExtension;
    mapping(uint256 => uint256) itemDelta; //item delta for pricing and selling
    mapping(uint256 => uint256) itemEquipExpires; //when long after consumed it expires
    mapping(uint256 => bool) itemIsSellable;
    mapping(uint256 => mapping(uint256 => uint256)) petItemExpires; // pet=>item=>expires time
    mapping(uint256 => uint256) itemSupply; //supply of items
    mapping(uint256 => EnumerableMap.UintToUintMap) itemsOwned; // items pet currently owns
    uint256 PRECISION;
    uint256 _tokenIds;
    uint256 _itemIds;
    uint256 la;
    uint256 lb;
    // pet properties
    mapping(uint256 => string) petName;
    mapping(uint256 => uint256) timeUntilStarving;
    mapping(uint256 => uint256) petScore;
    mapping(uint256 => uint256) timePetBorn;
    mapping(uint256 => uint256) lastAttackUsed;
    mapping(uint256 => uint256) lastAttacked;
    mapping(uint256 => uint256) stars;
    // vritual staking
    mapping(uint256 => uint256) ethOwed;
    mapping(uint256 => uint256) petRewardDebt;
    uint256 ethAccPerShare;
    uint256 totalScores;
    // migration
    mapping(uint256 => bool) petMigrated; //if pet migrated from v1 to this v2
    uint256 hasTheDiamond; //add this to the contractor instead
    mapping(uint256 => uint256) itemBought; //total bought to keep track of supply
}

library LibAppStorage {
    bytes32 internal constant DIAMOND_APP_STORAGE_POSITION =
        keccak256("diamond.app.storage");

    function appStorage() internal pure returns (AppStorage storage ds) {
        bytes32 position = DIAMOND_APP_STORAGE_POSITION;
        assembly {
            ds.slot := position
        }
    }

    // function diamondStorage() internal pure returns (AppStorage storage ds) {
    //     assembly {
    //         ds.slot := 0
    //     }
    // }

    // function abs(int256 x) internal pure returns (uint256) {
    //     return uint256(x >= 0 ? x : -x);
    // }
}

contract Modifiers {
    modifier onlyOwner() {
        LibDiamond.enforceIsContractOwner();
        _;
    }

    modifier isApproved(uint256 id) {
        AppStorage storage s = LibAppStorage.appStorage();

        require(
            s.nft.ownerOf(id) == msg.sender ||
                s.nft.getApproved(id) == msg.sender,
            "Not approved"
        );
        _;
    }
}

File 4 of 11 : IDiamondCut.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

/******************************************************************************\
* Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen)
* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535
/******************************************************************************/

import {IDiamond} from "./IDiamond.sol";

interface IDiamondCut is IDiamond {
    /// @notice Add/replace/remove any number of functions and optionally execute
    ///         a function with delegatecall
    /// @param _diamondCut Contains the facet addresses and function selectors
    /// @param _init The address of the contract or facet to execute _calldata
    /// @param _calldata A function call, including function selector and arguments
    ///                  _calldata is executed with delegatecall on _init
    function diamondCut(
        FacetCut[] calldata _diamondCut,
        address _init,
        bytes calldata _calldata
    ) external;
}

File 5 of 11 : IDiamondLoupe.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

/******************************************************************************\
* Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen)
* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535
/******************************************************************************/

// A loupe is a small magnifying glass used to look at diamonds.
// These functions look at diamonds
interface IDiamondLoupe {
    /// These functions are expected to be called frequently
    /// by tools.

    struct Facet {
        address facetAddress;
        bytes4[] functionSelectors;
    }

    /// @notice Gets all facet addresses and their four byte function selectors.
    /// @return facets_ Facet
    function facets() external view returns (Facet[] memory facets_);

    /// @notice Gets all the function selectors supported by a specific facet.
    /// @param _facet The facet address.
    /// @return facetFunctionSelectors_
    function facetFunctionSelectors(
        address _facet
    ) external view returns (bytes4[] memory facetFunctionSelectors_);

    /// @notice Get all the facet addresses used by a diamond.
    /// @return facetAddresses_
    function facetAddresses()
        external
        view
        returns (address[] memory facetAddresses_);

    /// @notice Gets the facet that supports the given selector.
    /// @dev If facet is not found return address(0).
    /// @param _functionSelector The function selector.
    /// @return facetAddress_ The facet address.
    function facetAddress(
        bytes4 _functionSelector
    ) external view returns (address facetAddress_);
}

File 6 of 11 : FixedPointMathLib.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

/// @notice Arithmetic library with operations for fixed-point numbers.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/FixedPointMathLib.sol)
/// @author Inspired by USM (https://github.com/usmfum/USM/blob/master/contracts/WadMath.sol)
library FixedPointMathLib {
    /*//////////////////////////////////////////////////////////////
                    SIMPLIFIED FIXED POINT OPERATIONS
    //////////////////////////////////////////////////////////////*/

    uint256 internal constant MAX_UINT256 = 2**256 - 1;

    uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s.

    function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) {
        return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down.
    }

    function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) {
        return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up.
    }

    function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) {
        return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down.
    }

    function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) {
        return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up.
    }

    /*//////////////////////////////////////////////////////////////
                    LOW LEVEL FIXED POINT OPERATIONS
    //////////////////////////////////////////////////////////////*/

    function mulDivDown(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            // Equivalent to require(denominator != 0 && (y == 0 || x <= type(uint256).max / y))
            if iszero(mul(denominator, iszero(mul(y, gt(x, div(MAX_UINT256, y)))))) {
                revert(0, 0)
            }

            // Divide x * y by the denominator.
            z := div(mul(x, y), denominator)
        }
    }

    function mulDivUp(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            // Equivalent to require(denominator != 0 && (y == 0 || x <= type(uint256).max / y))
            if iszero(mul(denominator, iszero(mul(y, gt(x, div(MAX_UINT256, y)))))) {
                revert(0, 0)
            }

            // If x * y modulo the denominator is strictly greater than 0,
            // 1 is added to round up the division of x * y by the denominator.
            z := add(gt(mod(mul(x, y), denominator), 0), div(mul(x, y), denominator))
        }
    }

    function rpow(
        uint256 x,
        uint256 n,
        uint256 scalar
    ) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            switch x
            case 0 {
                switch n
                case 0 {
                    // 0 ** 0 = 1
                    z := scalar
                }
                default {
                    // 0 ** n = 0
                    z := 0
                }
            }
            default {
                switch mod(n, 2)
                case 0 {
                    // If n is even, store scalar in z for now.
                    z := scalar
                }
                default {
                    // If n is odd, store x in z for now.
                    z := x
                }

                // Shifting right by 1 is like dividing by 2.
                let half := shr(1, scalar)

                for {
                    // Shift n right by 1 before looping to halve it.
                    n := shr(1, n)
                } n {
                    // Shift n right by 1 each iteration to halve it.
                    n := shr(1, n)
                } {
                    // Revert immediately if x ** 2 would overflow.
                    // Equivalent to iszero(eq(div(xx, x), x)) here.
                    if shr(128, x) {
                        revert(0, 0)
                    }

                    // Store x squared.
                    let xx := mul(x, x)

                    // Round to the nearest number.
                    let xxRound := add(xx, half)

                    // Revert if xx + half overflowed.
                    if lt(xxRound, xx) {
                        revert(0, 0)
                    }

                    // Set x to scaled xxRound.
                    x := div(xxRound, scalar)

                    // If n is even:
                    if mod(n, 2) {
                        // Compute z * x.
                        let zx := mul(z, x)

                        // If z * x overflowed:
                        if iszero(eq(div(zx, x), z)) {
                            // Revert if x is non-zero.
                            if iszero(iszero(x)) {
                                revert(0, 0)
                            }
                        }

                        // Round to the nearest number.
                        let zxRound := add(zx, half)

                        // Revert if zx + half overflowed.
                        if lt(zxRound, zx) {
                            revert(0, 0)
                        }

                        // Return properly scaled zxRound.
                        z := div(zxRound, scalar)
                    }
                }
            }
        }
    }

    /*//////////////////////////////////////////////////////////////
                        GENERAL NUMBER UTILITIES
    //////////////////////////////////////////////////////////////*/

    function sqrt(uint256 x) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            let y := x // We start y at x, which will help us make our initial estimate.

            z := 181 // The "correct" value is 1, but this saves a multiplication later.

            // This segment is to get a reasonable initial estimate for the Babylonian method. With a bad
            // start, the correct # of bits increases ~linearly each iteration instead of ~quadratically.

            // We check y >= 2^(k + 8) but shift right by k bits
            // each branch to ensure that if x >= 256, then y >= 256.
            if iszero(lt(y, 0x10000000000000000000000000000000000)) {
                y := shr(128, y)
                z := shl(64, z)
            }
            if iszero(lt(y, 0x1000000000000000000)) {
                y := shr(64, y)
                z := shl(32, z)
            }
            if iszero(lt(y, 0x10000000000)) {
                y := shr(32, y)
                z := shl(16, z)
            }
            if iszero(lt(y, 0x1000000)) {
                y := shr(16, y)
                z := shl(8, z)
            }

            // Goal was to get z*z*y within a small factor of x. More iterations could
            // get y in a tighter range. Currently, we will have y in [256, 256*2^16).
            // We ensured y >= 256 so that the relative difference between y and y+1 is small.
            // That's not possible if x < 256 but we can just verify those cases exhaustively.

            // Now, z*z*y <= x < z*z*(y+1), and y <= 2^(16+8), and either y >= 256, or x < 256.
            // Correctness can be checked exhaustively for x < 256, so we assume y >= 256.
            // Then z*sqrt(y) is within sqrt(257)/sqrt(256) of sqrt(x), or about 20bps.

            // For s in the range [1/256, 256], the estimate f(s) = (181/1024) * (s+1) is in the range
            // (1/2.84 * sqrt(s), 2.84 * sqrt(s)), with largest error when s = 1 and when s = 256 or 1/256.

            // Since y is in [256, 256*2^16), let a = y/65536, so that a is in [1/256, 256). Then we can estimate
            // sqrt(y) using sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2^18.

            // There is no overflow risk here since y < 2^136 after the first branch above.
            z := shr(18, mul(z, add(y, 65536))) // A mul() is saved from starting z at 181.

            // Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough.
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))

            // If x+1 is a perfect square, the Babylonian method cycles between
            // floor(sqrt(x)) and ceil(sqrt(x)). This statement ensures we return floor.
            // See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division
            // Since the ceil is rare, we save gas on the assignment and repeat division in the rare case.
            // If you don't care whether the floor or ceil square root is returned, you can remove this statement.
            z := sub(z, lt(div(x, z), z))
        }
    }

    function unsafeMod(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            // Mod x by y. Note this will return
            // 0 instead of reverting if y is zero.
            z := mod(x, y)
        }
    }

    function unsafeDiv(uint256 x, uint256 y) internal pure returns (uint256 r) {
        /// @solidity memory-safe-assembly
        assembly {
            // Divide x by y. Note this will return
            // 0 instead of reverting if y is zero.
            r := div(x, y)
        }
    }

    function unsafeDivUp(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            // Add 1 to x * y if x % y > 0. Note this will
            // return 0 instead of reverting if y is zero.
            z := add(gt(mod(x, y), 0), div(x, y))
        }
    }
}

File 7 of 11 : IDiamond.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

/******************************************************************************\
* Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen)
* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535
/******************************************************************************/

interface IDiamond {
    enum FacetCutAction {
        Add,
        Replace,
        Remove
    }
    // Add=0, Replace=1, Remove=2

    struct FacetCut {
        address facetAddress;
        FacetCutAction action;
        bytes4[] functionSelectors;
    }

    event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata);
}

File 8 of 11 : EnumerableMap.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableMap.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableMap.js.

pragma solidity ^0.8.0;

import "./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 Uint256ToAddressMap) are just wrappers around
    // the underlying Map.
    // This means that we can only create new EnumerableMaps for types that fit
    // in bytes32.

    struct Bytes32ToBytes32Map {
        // Storage of keys
        EnumerableSet.Bytes32Set _keys;
        mapping(bytes32 => 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];
        require(value != 0 || contains(map, key), "EnumerableMap: nonexistent key");
        return value;
    }

    /**
     * @dev Same as {get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryGet}.
     */
    function get(
        Bytes32ToBytes32Map storage map,
        bytes32 key,
        string memory errorMessage
    ) internal view returns (bytes32) {
        bytes32 value = map._values[key];
        require(value != 0 || contains(map, key), errorMessage);
        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 Same as {get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryGet}.
     */
    function get(UintToUintMap storage map, uint256 key, string memory errorMessage) internal view returns (uint256) {
        return uint256(get(map._inner, bytes32(key), errorMessage));
    }

    /**
     * @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 Same as {get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryGet}.
     */
    function get(
        UintToAddressMap storage map,
        uint256 key,
        string memory errorMessage
    ) internal view returns (address) {
        return address(uint160(uint256(get(map._inner, bytes32(key), errorMessage))));
    }

    /**
     * @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 Same as {get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryGet}.
     */
    function get(
        AddressToUintMap storage map,
        address key,
        string memory errorMessage
    ) internal view returns (uint256) {
        return uint256(get(map._inner, bytes32(uint256(uint160(key))), errorMessage));
    }

    /**
     * @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 Same as {get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryGet}.
     */
    function get(
        Bytes32ToUintMap storage map,
        bytes32 key,
        string memory errorMessage
    ) internal view returns (uint256) {
        return uint256(get(map._inner, key, errorMessage));
    }

    /**
     * @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;
    }
}

File 9 of 11 : IERC20Extended.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

interface IERC20Extended {
    function balanceOf(
        address tokenOwner
    ) external view returns (uint256 balance);

    function totalSupply() external view returns (uint256 supply);

    function transfer(
        address to,
        uint256 tokens
    ) external returns (bool success);

    function transferFrom(
        address from,
        address to,
        uint256 tokens
    ) external returns (bool success);

    function burn(uint256 amount) external;

    function burnFrom(address account, uint256 amount) external;
}

File 10 of 11 : IERC721Extended.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

interface IERC721Extended {
    event Transfer(
        address indexed from,
        address indexed to,
        uint256 indexed tokenId
    );

    event Approval(
        address indexed owner,
        address indexed approved,
        uint256 indexed tokenId
    );

    event ApprovalForAll(
        address indexed owner,
        address indexed operator,
        bool approved
    );

    function balanceOf(address owner) external view returns (uint256 balance);

    function ownerOf(uint256 tokenId) external view returns (address owner);

    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external;

    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    function transferFrom(address from, address to, uint256 tokenId) external;

    function approve(address to, uint256 tokenId) external;

    function setApprovalForAll(address operator, bool approved) external;

    function getApproved(
        uint256 tokenId
    ) external view returns (address operator);

    function isApprovedForAll(
        address owner,
        address operator
    ) external view returns (bool);

    function burn(uint256 id) external;

    function burnInGame(uint256 id) external;

    function mint(address to) external;
}

File 11 of 11 : EnumerableSet.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.

pragma solidity ^0.8.0;

/**
 * @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 of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping(bytes32 => uint256) _indexes;
    }

    /**
     * @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._indexes[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 read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 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 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            if (lastIndex != toDeleteIndex) {
                bytes32 lastValue = set._values[lastIndex];

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastValue;
                // Update the index for the moved value
                set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[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._indexes[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;
    }
}

Settings
{
  "remappings": [
    "openzeppelin/=lib/openzeppelin-contracts/contracts/",
    "solmate/=lib/solmate/src/",
    "prb-math/=lib/prb-math/src/",
    "@openzeppelin/=lib/openzeppelin-contracts/",
    "@chainlink/=lib/chainlink/",
    "@prb/test/=lib/prb-math/lib/prb-test/src/",
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "forge-std/=lib/forge-std/src/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "prb-test/=lib/prb-math/lib/prb-test/src/",
    "solidity-stringutils/=lib/solidity-stringutils/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "paris",
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"components":[{"internalType":"address","name":"facetAddress","type":"address"},{"internalType":"enum IDiamond.FacetCutAction","name":"action","type":"uint8"},{"internalType":"bytes4[]","name":"functionSelectors","type":"bytes4[]"}],"internalType":"struct IDiamond.FacetCut[]","name":"_diamondCut","type":"tuple[]"},{"components":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"init","type":"address"},{"internalType":"bytes","name":"initCalldata","type":"bytes"}],"internalType":"struct DiamondArgs","name":"_args","type":"tuple"}],"stateMutability":"payable","type":"constructor"},{"inputs":[{"internalType":"bytes4","name":"_selector","type":"bytes4"}],"name":"CannotAddFunctionToDiamondThatAlreadyExists","type":"error"},{"inputs":[{"internalType":"bytes4[]","name":"_selectors","type":"bytes4[]"}],"name":"CannotAddSelectorsToZeroAddress","type":"error"},{"inputs":[{"internalType":"bytes4","name":"_selector","type":"bytes4"}],"name":"CannotRemoveFunctionThatDoesNotExist","type":"error"},{"inputs":[{"internalType":"bytes4","name":"_selector","type":"bytes4"}],"name":"CannotRemoveImmutableFunction","type":"error"},{"inputs":[{"internalType":"bytes4","name":"_selector","type":"bytes4"}],"name":"CannotReplaceFunctionThatDoesNotExists","type":"error"},{"inputs":[{"internalType":"bytes4","name":"_selector","type":"bytes4"}],"name":"CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet","type":"error"},{"inputs":[{"internalType":"bytes4[]","name":"_selectors","type":"bytes4[]"}],"name":"CannotReplaceFunctionsFromFacetWithZeroAddress","type":"error"},{"inputs":[{"internalType":"bytes4","name":"_selector","type":"bytes4"}],"name":"CannotReplaceImmutableFunction","type":"error"},{"inputs":[{"internalType":"bytes4","name":"_functionSelector","type":"bytes4"}],"name":"FunctionNotFound","type":"error"},{"inputs":[{"internalType":"uint8","name":"_action","type":"uint8"}],"name":"IncorrectFacetCutAction","type":"error"},{"inputs":[{"internalType":"address","name":"_initializationContractAddress","type":"address"},{"internalType":"bytes","name":"_calldata","type":"bytes"}],"name":"InitializationFunctionReverted","type":"error"},{"inputs":[{"internalType":"address","name":"_contractAddress","type":"address"},{"internalType":"string","name":"_message","type":"string"}],"name":"NoBytecodeAtAddress","type":"error"},{"inputs":[{"internalType":"address","name":"_facetAddress","type":"address"}],"name":"NoSelectorsProvidedForFacetForCut","type":"error"},{"inputs":[{"internalType":"address","name":"_facetAddress","type":"address"}],"name":"RemoveFacetAddressMustBeZeroAddress","type":"error"},{"stateMutability":"payable","type":"fallback"},{"stateMutability":"payable","type":"receive"}]

60806040526040516200120238038062001202833981016040819052620000269162000b75565b8051620000339062000056565b6200004e8282602001518360400151620000da60201b60201c565b505062000f92565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131f80546001600160a01b031981166001600160a01b038481169182179093556040516000805160206200114e833981519152939092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b60005b83518110156200026c576000848281518110620000fe57620000fe62000d33565b6020026020010151604001519050600085838151811062000123576200012362000d33565b60200260200101516000015190508151600003620001645760405163e767f91f60e01b81526001600160a01b03821660048201526024015b60405180910390fd5b60008684815181106200017b576200017b62000d33565b6020026020010151602001519050600060028111156200019f576200019f62000d49565b816002811115620001b457620001b462000d49565b03620001cc57620001c68284620002bb565b62000253565b6001816002811115620001e357620001e362000d49565b03620001f557620001c6828462000481565b60028160028111156200020c576200020c62000d49565b036200021e57620001c6828462000628565b80600281111562000233576200023362000d49565b604051633ff4d20f60e11b815260ff90911660048201526024016200015b565b5050508080620002639062000d75565b915050620000dd565b507f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb673838383604051620002a29392919062000e06565b60405180910390a1620002b68282620008cc565b505050565b6001600160a01b038216620002e757806040516302b8da0760e21b81526004016200015b919062000ed6565b600080516020620011ba83398151915254604080516060810190915260248082526000805160206200114e833981519152929162000331918691906200116e60208301396200099e565b60005b83518110156200047a57600084828151811062000355576200035562000d33565b6020908102919091018101516001600160e01b031981166000908152918690526040909120549091506001600160a01b03168015620003b45760405163ebbf5d0760e01b81526001600160e01b0319831660048201526024016200015b565b6040805180820182526001600160a01b03808a16825261ffff80881660208085019182526001600160e01b0319881660009081528b8252958620945185549251909316600160a01b026001600160b01b0319909216929093169190911717909155600180880180549182018155835291206008820401805460e085901c60046007909416939093026101000a92830263ffffffff9093021916919091179055836200045f8162000ef2565b94505050508080620004719062000d75565b91505062000334565b5050505050565b6000805160206200114e8339815191526001600160a01b038316620004bd578160405163cd98a96f60e01b81526004016200015b919062000ed6565b620004e283604051806060016040528060288152602001620011da602891396200099e565b60005b82518110156200062257600083828151811062000506576200050662000d33565b6020908102919091018101516001600160e01b031981166000908152918590526040909120549091506001600160a01b03163081036200056657604051632901806d60e11b81526001600160e01b0319831660048201526024016200015b565b856001600160a01b0316816001600160a01b031603620005a657604051631ac6ce8d60e11b81526001600160e01b0319831660048201526024016200015b565b6001600160a01b038116620005db57604051637479f93960e01b81526001600160e01b0319831660048201526024016200015b565b506001600160e01b031916600090815260208390526040902080546001600160a01b0319166001600160a01b03861617905580620006198162000d75565b915050620004e5565b50505050565b600080516020620011ba833981519152546000805160206200114e833981519152906001600160a01b038416156200067f5760405163d091bc8160e01b81526001600160a01b03851660048201526024016200015b565b60005b83518110156200047a576000848281518110620006a357620006a362000d33565b6020908102919091018101516001600160e01b0319811660009081528683526040908190208151808301909252546001600160a01b038116808352600160a01b90910461ffff1693820193909352909250906200072057604051637a08a22d60e01b81526001600160e01b0319831660048201526024016200015b565b8051306001600160a01b03909116036200075a57604051630df5fd6160e31b81526001600160e01b0319831660048201526024016200015b565b83620007668162000f16565b94505083816020015161ffff16146200084b57600085600101858154811062000793576200079362000d33565b90600052602060002090600891828204019190066004029054906101000a900460e01b90508086600101836020015161ffff1681548110620007d957620007d962000d33565b600091825260208083206008830401805463ffffffff60079094166004026101000a938402191660e09590951c92909202939093179055838201516001600160e01b03199390931681529087905260409020805461ffff60a01b1916600160a01b61ffff909316929092029190911790555b8460010180548062000861576200086162000f30565b60008281526020808220600860001990940193840401805463ffffffff600460078716026101000a0219169055919092556001600160e01b0319909316815291859052506040902080546001600160b01b031916905580620008c38162000d75565b91505062000682565b6001600160a01b038216620008df575050565b620009048260405180606001604052806028815260200162001192602891396200099e565b600080836001600160a01b03168360405162000921919062000f46565b600060405180830381855af49150503d80600081146200095e576040519150601f19603f3d011682016040523d82523d6000602084013e62000963565b606091505b50915091508162000622578051156200097f5780518082602001fd5b838360405163192105d760e01b81526004016200015b92919062000f64565b813b6000819003620002b657828260405163919834b960e01b81526004016200015b92919062000f64565b634e487b7160e01b600052604160045260246000fd5b604051606081016001600160401b038111828210171562000a045762000a04620009c9565b60405290565b604051601f8201601f191681016001600160401b038111828210171562000a355762000a35620009c9565b604052919050565b60006001600160401b0382111562000a595762000a59620009c9565b5060051b60200190565b80516001600160a01b038116811462000a7b57600080fd5b919050565b60005b8381101562000a9d57818101518382015260200162000a83565b50506000910152565b60006060828403121562000ab957600080fd5b62000ac3620009df565b905062000ad08262000a63565b8152602062000ae181840162000a63565b8282015260408301516001600160401b038082111562000b0057600080fd5b818501915085601f83011262000b1557600080fd5b81518181111562000b2a5762000b2a620009c9565b62000b3e601f8201601f1916850162000a0a565b9150808252868482850101111562000b5557600080fd5b62000b668185840186860162000a80565b50604084015250909392505050565b6000806040838503121562000b8957600080fd5b82516001600160401b038082111562000ba157600080fd5b818501915085601f83011262000bb657600080fd5b8151602062000bcf62000bc98362000a3d565b62000a0a565b82815260059290921b8401810191818101908984111562000bef57600080fd5b8286015b8481101562000cff5780518681111562000c0c57600080fd5b87016060818d03601f1901121562000c2357600080fd5b62000c2d620009df565b62000c3a86830162000a63565b815260408201516003811062000c4f57600080fd5b8187015260608201518881111562000c6657600080fd5b8083019250508c603f83011262000c7c57600080fd5b8582015162000c8f62000bc98262000a3d565b81815260059190911b830160400190878101908f83111562000cb057600080fd5b6040850194505b8285101562000ce95784516001600160e01b03198116811462000cd957600080fd5b8252938801939088019062000cb7565b6040840152505084525091830191830162000bf3565b509188015191965090935050508082111562000d1a57600080fd5b5062000d298582860162000aa6565b9150509250929050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006001820162000d8a5762000d8a62000d5f565b5060010190565b600081518084526020808501945080840160005b8381101562000dcd5781516001600160e01b0319168752958201959082019060010162000da5565b509495945050505050565b6000815180845262000df281602086016020860162000a80565b601f01601f19169290920160200192915050565b6000606080830181845280875180835260808601915060808160051b87010192506020808a016000805b8481101562000ea457898703607f19018652825180516001600160a01b03168852848101516003811062000e7257634e487b7160e01b84526021600452602484fd5b8886015260409081015190880189905262000e908989018262000d91565b975050948301949183019160010162000e30565b5050506001600160a01b038916908701525050838103604085015262000ecb818662000dd8565b979650505050505050565b60208152600062000eeb602083018462000d91565b9392505050565b600061ffff80831681810362000f0c5762000f0c62000d5f565b6001019392505050565b60008162000f285762000f2862000d5f565b506000190190565b634e487b7160e01b600052603160045260246000fd5b6000825162000f5a81846020870162000a80565b9190910192915050565b6001600160a01b038316815260406020820181905260009062000f8a9083018462000dd8565b949350505050565b6101ac8062000fa26000396000f3fe608060405236610096577f31c1f8402397e5b1e3d75f3da7207ce6f54556b27afe723742768c4e4be50cf3547f31c1f8402397e5b1e3d75f3da7207ce6f54556b27afe723742768c4e4be50d02547f31c1f8402397e5b1e3d75f3da7207ce6f54556b27afe723742768c4e4be50ce09161007b91349190610131565b81602101600082825461008e919061014f565b925050819055005b600080356001600160e01b03191681527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c602081905260409091205481906001600160a01b03168061010d57604051630a82dd7360e31b81526001600160e01b031960003516600482015260240160405180910390fd5b3660008037600080366000845af43d6000803e80801561012c573d6000f35b3d6000fd5b600082600019048411830215820261014857600080fd5b5091020490565b8082018082111561017057634e487b7160e01b600052601160045260246000fd5b9291505056fea26469706673582212206741ef906a187b566d9cd1fbb1cd9c1e90d86318961903f9a4035e46e5a8f1ff64736f6c63430008130033c8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c4c69624469616d6f6e644375743a2041646420666163657420686173206e6f20636f64654c69624469616d6f6e644375743a205f696e6974206164647265737320686173206e6f20636f6465c8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131d4c69624469616d6f6e644375743a205265706c61636520666163657420686173206e6f20636f64650000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000366f400e50aabbd29869fec46a62462a1a98792a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000011f931c1c00000000000000000000000000000000000000000000000000000000000000000000000000000000047f606fd5b2baa5f5c6c4ab8958e45cb6b054b700000000000000000000000090a4bc11b79b2d234372118f03466554050f37a8000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001a402ccf8a2000000000000000000000000ff0c532fdb8cd566ae169c1cb157ff2bdc83e1050000000000000000000000005b51cf49cb48617084ef35e7c7d7a21914769ff1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002580000000000000000000000000000000000000000000000056bc75e2d6310000000000000000000000000000000000000000000000000006c6b935b8bbd40000000000000000000000000000000000000000000000000000000000000654d85070000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000056bc75e2d631000000000000000000000000000004de57ce8c5c688f9b841b89cb08b2c8178557f970000000000000000000000004a84c33ebe4824feb1943fc6a85d81058a7e68a900000000000000000000000000000000000000000000000000000000

Deployed Bytecode

0x608060405236610096577f31c1f8402397e5b1e3d75f3da7207ce6f54556b27afe723742768c4e4be50cf3547f31c1f8402397e5b1e3d75f3da7207ce6f54556b27afe723742768c4e4be50d02547f31c1f8402397e5b1e3d75f3da7207ce6f54556b27afe723742768c4e4be50ce09161007b91349190610131565b81602101600082825461008e919061014f565b925050819055005b600080356001600160e01b03191681527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c602081905260409091205481906001600160a01b03168061010d57604051630a82dd7360e31b81526001600160e01b031960003516600482015260240160405180910390fd5b3660008037600080366000845af43d6000803e80801561012c573d6000f35b3d6000fd5b600082600019048411830215820261014857600080fd5b5091020490565b8082018082111561017057634e487b7160e01b600052601160045260246000fd5b9291505056fea26469706673582212206741ef906a187b566d9cd1fbb1cd9c1e90d86318961903f9a4035e46e5a8f1ff64736f6c63430008130033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000366f400e50aabbd29869fec46a62462a1a98792a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000011f931c1c00000000000000000000000000000000000000000000000000000000000000000000000000000000047f606fd5b2baa5f5c6c4ab8958e45cb6b054b700000000000000000000000090a4bc11b79b2d234372118f03466554050f37a8000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001a402ccf8a2000000000000000000000000ff0c532fdb8cd566ae169c1cb157ff2bdc83e1050000000000000000000000005b51cf49cb48617084ef35e7c7d7a21914769ff1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002580000000000000000000000000000000000000000000000056bc75e2d6310000000000000000000000000000000000000000000000000006c6b935b8bbd40000000000000000000000000000000000000000000000000000000000000654d85070000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000056bc75e2d631000000000000000000000000000004de57ce8c5c688f9b841b89cb08b2c8178557f970000000000000000000000004a84c33ebe4824feb1943fc6a85d81058a7e68a900000000000000000000000000000000000000000000000000000000

-----Decoded View---------------
Arg [0] : _diamondCut (tuple[]): System.Collections.Generic.List`1[Nethereum.ABI.FunctionEncoding.ParameterOutput]
Arg [1] : _args (tuple): System.Collections.Generic.List`1[Nethereum.ABI.FunctionEncoding.ParameterOutput]

-----Encoded View---------------
27 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000040
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000120
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000020
Arg [4] : 000000000000000000000000366f400e50aabbd29869fec46a62462a1a98792a
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000060
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [8] : 1f931c1c00000000000000000000000000000000000000000000000000000000
Arg [9] : 000000000000000000000000047f606fd5b2baa5f5c6c4ab8958e45cb6b054b7
Arg [10] : 00000000000000000000000090a4bc11b79b2d234372118f03466554050f37a8
Arg [11] : 0000000000000000000000000000000000000000000000000000000000000060
Arg [12] : 00000000000000000000000000000000000000000000000000000000000001a4
Arg [13] : 02ccf8a2000000000000000000000000ff0c532fdb8cd566ae169c1cb157ff2b
Arg [14] : dc83e1050000000000000000000000005b51cf49cb48617084ef35e7c7d7a219
Arg [15] : 14769ff100000000000000000000000000000000000000000000000000000000
Arg [16] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [17] : 000002580000000000000000000000000000000000000000000000056bc75e2d
Arg [18] : 6310000000000000000000000000000000000000000000000000006c6b935b8b
Arg [19] : bd40000000000000000000000000000000000000000000000000000000000000
Arg [20] : 654d850700000000000000000000000000000000000000000000000000000000
Arg [21] : 0000000100000000000000000000000000000000000000000000000000000000
Arg [22] : 0000000200000000000000000000000000000000000000000000000000000000
Arg [23] : 000000020000000000000000000000000000000000000000000000056bc75e2d
Arg [24] : 631000000000000000000000000000004de57ce8c5c688f9b841b89cb08b2c81
Arg [25] : 78557f970000000000000000000000004a84c33ebe4824feb1943fc6a85d8105
Arg [26] : 8a7e68a900000000000000000000000000000000000000000000000000000000


Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.