Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0x5B6447Ab64ea08f5A5975a35AAf45225f85a4da2
Balance 0 ETH
Nonce 1
Code Size 8272 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

8272 bytes
0x608060405260043610610236575f3560e01c80637200940711610129578063aba668c5116100a8578063d939c9601161006d578063d939c96014610682578063e12f3a61146106a1578063e268e4d3146106d5578063eb91d37e146106f4578063f2fde38b1461071d575f5ffd5b8063aba668c5146105e7578063bce4d6ae14610606578063bfb6202814610625578063d186baa014610644578063d547741f14610663575f5ffd5b80639106d7ba116100ee5780639106d7ba1461056257806391d14854146105775780639c007c7514610596578063a217fddf146105b5578063a89c8c5e146105c8575f5ffd5b806372009407146104b457806375b238fc146104c75780637abe2bfa146104e7578063842a77d3146105065780638da5cb5b14610531575f5ffd5b806332cb6b0c116101b557806350480fd21161017a57806350480fd2146104395780635a18664c1461044e5780635ac3cb3d146104625780636f8b44b014610481578063715018a6146104a0575f5ffd5b806332cb6b0c146103bc57806335a9e7d6146103d157806336568abe146103f2578063428a64551461041157806348c54b9d14610425575f5ffd5b80631011589f116101fb5780631011589f146102f95780631ad874b414610338578063248a9ca3146103515780632959258f1461037f5780632f2ff15d1461039d575f5ffd5b806301ffc9a71461024157806309b6c9ba146102755780630e760a81146102965780630f03e156146102b75780630f2cdd6c146102d6575f5ffd5b3661023d57005b5f5ffd5b34801561024c575f5ffd5b5061026061025b366004611bb5565b61073c565b60405190151581526020015b60405180910390f35b348015610280575f5ffd5b50610289610772565b60405161026c9190611bdc565b3480156102a1575f5ffd5b506102b56102b0366004611c4a565b6107f5565b005b3480156102c2575f5ffd5b506102b56102d1366004611d07565b610859565b3480156102e1575f5ffd5b506102eb60085481565b60405190815260200161026c565b348015610304575f5ffd5b50610318610313366004611c4a565b610927565b60408051948552602085019390935291830152606082015260800161026c565b348015610343575f5ffd5b50600a546102609060ff1681565b34801561035c575f5ffd5b506102eb61036b366004611c4a565b5f9081526020819052604090206001015490565b34801561038a575f5ffd5b50600a5461026090610100900460ff1681565b3480156103a8575f5ffd5b506102b56103b7366004611dc7565b61095f565b3480156103c7575f5ffd5b506102eb60065481565b3480156103dc575f5ffd5b506103e5610989565b60405161026c9190611df5565b3480156103fd575f5ffd5b506102b561040c366004611dc7565b610a55565b34801561041c575f5ffd5b506102b5610a8d565b348015610430575f5ffd5b506102b5610c13565b348015610444575f5ffd5b506102eb60095481565b348015610459575f5ffd5b506102b5610d77565b34801561046d575f5ffd5b506102b561047c366004611e20565b610e52565b34801561048c575f5ffd5b506102b561049b366004611c4a565b610fcd565b3480156104ab575f5ffd5b506102b5611028565b6102b56104c2366004611e3b565b611039565b3480156104d2575f5ffd5b506102eb5f516020611ffb5f395f51905f5281565b3480156104f2575f5ffd5b506102b5610501366004611e63565b611371565b348015610511575f5ffd5b506102eb610520366004611e20565b600c6020525f908152604090205481565b34801561053c575f5ffd5b506002546001600160a01b03165b6040516001600160a01b03909116815260200161026c565b34801561056d575f5ffd5b506102eb60075481565b348015610582575f5ffd5b50610260610591366004611dc7565b61145b565b3480156105a1575f5ffd5b506102b56105b0366004611e9b565b611483565b3480156105c0575f5ffd5b506102eb5f81565b3480156105d3575f5ffd5b506102b56105e2366004611eb6565b6114f3565b3480156105f2575f5ffd5b5060035461054a906001600160a01b031681565b348015610611575f5ffd5b506102b5610620366004611e9b565b611577565b348015610630575f5ffd5b506102b561063f366004611e20565b6115e0565b34801561064f575f5ffd5b5060045461054a906001600160a01b031681565b34801561066e575f5ffd5b506102b561067d366004611dc7565b61160a565b34801561068d575f5ffd5b5060055461054a906001600160a01b031681565b3480156106ac575f5ffd5b506102eb6106bb366004611e20565b6001600160a01b03165f908152600c602052604090205490565b3480156106e0575f5ffd5b506102b56106ef366004611c4a565b61162e565b3480156106ff575f5ffd5b50610708611689565b6040805192835260208301919091520161026c565b348015610728575f5ffd5b506102b5610737366004611e20565b6116a9565b5f6001600160e01b03198216637965db0b60e01b148061076c57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600b805480602002602001604051908101604052809291908181526020015f905b828210156107ec578382905f5260205f2090600402016040518060800160405290815f8201548152602001600182015481526020016002820154815260200160038201548152505081526020019060010190610795565b50505050905090565b336108086002546001600160a01b031690565b6001600160a01b0316148061082f575061082f5f516020611ffb5f395f51905f523361145b565b6108545760405162461bcd60e51b815260040161084b90611ee2565b60405180910390fd5b600955565b3361086c6002546001600160a01b031690565b6001600160a01b0316148061089357506108935f516020611ffb5f395f51905f523361145b565b6108af5760405162461bcd60e51b815260040161084b90611ee2565b6108ba600b5f611b70565b5f5b815181101561092357600b8282815181106108d9576108d9611f19565b6020908102919091018101518254600181810185555f94855293839020825160049092020190815591810151828401556040810151600283015560600151600390910155016108bc565b5050565b600b8181548110610936575f80fd5b5f9182526020909120600490910201805460018201546002830154600390930154919350919084565b5f82815260208190526040902060010154610979816116e6565b61098383836116f0565b50505050565b6109b060405180608001604052805f81526020015f81526020015f81526020015f81525090565b600b545f906109c190600190611f41565b90505b600b81815481106109d7576109d7611f19565b905f5260205f2090600402015f01544210610a4357600b81815481106109ff576109ff611f19565b905f5260205f2090600402016040518060800160405290815f8201548152602001600182015481526020016002820154815260200160038201548152505091505090565b80610a4d81611f54565b9150506109c4565b6001600160a01b0381163314610a7e5760405163334bd91960e11b815260040160405180910390fd5b610a88828261177f565b505050565b33610aa06002546001600160a01b031690565b6001600160a01b03161480610ac75750610ac75f516020611ffb5f395f51905f523361145b565b610ae35760405162461bcd60e51b815260040161084b90611ee2565b600480546040516370a0823160e01b815230928101929092525f916001600160a01b03909116906370a0823190602401602060405180830381865afa158015610b2e573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b529190611f69565b90505f8111610b9b5760405162461bcd60e51b81526020600482015260156024820152744e6f20746f6b656e7320746f20776974686472617760581b604482015260640161084b565b6004805460055460405163a9059cbb60e01b81526001600160a01b039182169381019390935260248301849052169063a9059cbb906044016020604051808303815f875af1158015610bef573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109239190611f80565b610c1b6117e8565b600a54610100900460ff16610c6b5760405162461bcd60e51b8152602060048201526016602482015275436c61696d696e67206973206e6f742061637469766560501b604482015260640161084b565b600954421015610cbd5760405162461bcd60e51b815260206004820152601c60248201527f436c61696d696e6720686173206e6f7420737461727465642079657400000000604482015260640161084b565b335f908152600c602052604090205480610d0e5760405162461bcd60e51b81526020600482015260126024820152714e6f20746f6b656e7320746f20636c61696d60701b604482015260640161084b565b335f818152600c6020526040812055600354610d36916001600160a01b039091169083611841565b60405181815233907f896e034966eaaf1adc54acc0f257056febbd300c9e47182cf761982cf1f5e4309060200160405180910390a250610d7560018055565b565b33610d8a6002546001600160a01b031690565b6001600160a01b03161480610db15750610db15f516020611ffb5f395f51905f523361145b565b610dcd5760405162461bcd60e51b815260040161084b90611ee2565b4780610e1b5760405162461bcd60e51b815260206004820152601b60248201527f4e6f206e617469766520746f6b656e20746f2077697468647261770000000000604482015260640161084b565b6005546040516001600160a01b039091169082156108fc029083905f818181858888f19350505050158015610923573d5f5f3e3d5ffd5b33610e656002546001600160a01b031690565b6001600160a01b03161480610e8c5750610e8c5f516020611ffb5f395f51905f523361145b565b610ea85760405162461bcd60e51b815260040161084b90611ee2565b6040516370a0823160e01b81523060048201525f906001600160a01b038316906370a0823190602401602060405180830381865afa158015610eec573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610f109190611f69565b90505f8111610f595760405162461bcd60e51b81526020600482015260156024820152744e6f20746f6b656e7320746f20776974686472617760581b604482015260640161084b565b60055460405163a9059cbb60e01b81526001600160a01b039182166004820152602481018390529083169063a9059cbb906044016020604051808303815f875af1158015610fa9573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a889190611f80565b33610fe06002546001600160a01b031690565b6001600160a01b0316148061100757506110075f516020611ffb5f395f51905f523361145b565b6110235760405162461bcd60e51b815260040161084b90611ee2565b600655565b6110306118a0565b610d755f6118cd565b6110416117e8565b600a5460ff1661108b5760405162461bcd60e51b815260206004820152601560248201527450726573616c65206973206e6f742061637469766560581b604482015260640161084b565b5f600b61109661191e565b815481106110a6576110a6611f19565b905f5260205f209060040201905080600301548310156111205760405162461bcd60e51b815260206004820152602f60248201527f507572636861736520616d6f756e742062656c6f77206d696e696d756d20666f60448201526e722063757272656e7420706861736560881b606482015260840161084b565b600854335f908152600c602052604090205461113c9085611973565b11156111835760405162461bcd60e51b8152602060048201526016602482015275115e18d959591cc81b585e081c195c881dd85b1b195d60521b604482015260640161084b565b6006546007546111939085611973565b11156111d65760405162461bcd60e51b815260206004820152601260248201527145786365656473206d617820737570706c7960701b604482015260640161084b565b5f8260ff165f036112615761120a670de0b6b3a764000061120484600101548761198590919063ffffffff16565b90611990565b90508034101561125c5760405162461bcd60e51b815260206004820152601e60248201527f496e73756666696369656e74206e617469766520746f6b656e2073656e740000604482015260640161084b565b6112e9565b8260ff166001036112aa5761128f670de0b6b3a764000061120484600201548761198590919063ffffffff16565b60045490915061125c906001600160a01b031633308461199b565b60405162461bcd60e51b8152602060048201526014602482015273496e76616c696420746f6b656e2063686f69636560601b604482015260640161084b565b335f908152600c60205260409020546113029085611973565b335f908152600c602052604090205560075461131e9085611973565b600755604080518581526020810183905260ff851681830152905133917f07bd967119635e499edb871f00e988945fc967531c4dfa79a630a18ed98cf1eb919081900360600190a2505061092360018055565b336113846002546001600160a01b031690565b6001600160a01b031614806113ab57506113ab5f516020611ffb5f395f51905f523361145b565b6113c75760405162461bcd60e51b815260040161084b90611ee2565b600b54821061140e5760405162461bcd60e51b8152602060048201526013602482015272496e646578206f7574206f6620626f756e647360681b604482015260640161084b565b80600b838154811061142257611422611f19565b905f5260205f2090600402015f820151815f01556020820151816001015560408201518160020155606082015181600301559050505050565b5f918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b336114966002546001600160a01b031690565b6001600160a01b031614806114bd57506114bd5f516020611ffb5f395f51905f523361145b565b6114d95760405162461bcd60e51b815260040161084b90611ee2565b600a80549115156101000261ff0019909216919091179055565b336115066002546001600160a01b031690565b6001600160a01b0316148061152d575061152d5f516020611ffb5f395f51905f523361145b565b6115495760405162461bcd60e51b815260040161084b90611ee2565b600380546001600160a01b039384166001600160a01b03199182161790915560048054929093169116179055565b3361158a6002546001600160a01b031690565b6001600160a01b031614806115b157506115b15f516020611ffb5f395f51905f523361145b565b6115cd5760405162461bcd60e51b815260040161084b90611ee2565b600a805460ff1916911515919091179055565b6115e86118a0565b600580546001600160a01b0319166001600160a01b0392909216919091179055565b5f82815260208190526040902060010154611624816116e6565b610983838361177f565b336116416002546001600160a01b031690565b6001600160a01b0316148061166857506116685f516020611ffb5f395f51905f523361145b565b6116845760405162461bcd60e51b815260040161084b90611ee2565b600855565b5f5f5f611694610989565b90508060200151816040015192509250509091565b6116b16118a0565b6001600160a01b0381166116da57604051631e4fbdf760e01b81525f600482015260240161084b565b6116e3816118cd565b50565b6116e381336119d4565b5f6116fb838361145b565b611778575f838152602081815260408083206001600160a01b03861684529091529020805460ff191660011790556117303390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a450600161076c565b505f61076c565b5f61178a838361145b565b15611778575f838152602081815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a450600161076c565b60026001540361183a5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161084b565b6002600155565b6040516001600160a01b03838116602483015260448201839052610a8891859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050611a0d565b6002546001600160a01b03163314610d755760405163118cdaa760e01b815233600482015260240161084b565b600280546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b600b545f90819061193190600190611f41565b90505b600b818154811061194757611947611f19565b905f5260205f2090600402015f0154421061196157919050565b8061196b81611f54565b915050611934565b5f61197e8284611f9b565b9392505050565b5f61197e8284611fae565b5f61197e8284611fc5565b6040516001600160a01b0384811660248301528381166044830152606482018390526109839186918216906323b872dd9060840161186e565b6119de828261145b565b6109235760405163e2517d3f60e01b81526001600160a01b03821660048201526024810183905260440161084b565b5f611a216001600160a01b03841683611a6e565b905080515f14158015611a45575080806020019051810190611a439190611f80565b155b15610a8857604051635274afe760e01b81526001600160a01b038416600482015260240161084b565b606061197e83835f845f5f856001600160a01b03168486604051611a929190611fe4565b5f6040518083038185875af1925050503d805f8114611acc576040519150601f19603f3d011682016040523d82523d5f602084013e611ad1565b606091505b5091509150611ae1868383611aeb565b9695505050505050565b606082611b0057611afb82611b47565b61197e565b8151158015611b1757506001600160a01b0384163b155b15611b4057604051639996b31560e01b81526001600160a01b038516600482015260240161084b565b508061197e565b805115611b575780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b5080545f8255600402905f5260205f20908101906116e391905b80821115611bb1575f80825560018201819055600282018190556003820155600401611b8a565b5090565b5f60208284031215611bc5575f5ffd5b81356001600160e01b03198116811461197e575f5ffd5b602080825282518282018190525f918401906040840190835b81811015611c3f57611c29838551805182526020810151602083015260408101516040830152606081015160608301525050565b6020939093019260809290920191600101611bf5565b509095945050505050565b5f60208284031215611c5a575f5ffd5b5035919050565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f1916810167ffffffffffffffff81118282101715611c9e57611c9e611c61565b604052919050565b5f60808284031215611cb6575f5ffd5b6040516080810167ffffffffffffffff81118282101715611cd957611cd9611c61565b6040908152833582526020808501359083015283810135908201526060928301359281019290925250919050565b5f60208284031215611d17575f5ffd5b813567ffffffffffffffff811115611d2d575f5ffd5b8201601f81018413611d3d575f5ffd5b803567ffffffffffffffff811115611d5757611d57611c61565b611d6660208260051b01611c75565b8082825260208201915060208360071b850101925086831115611d87575f5ffd5b6020840193505b82841015611ae157611da08785611ca6565b8252602082019150608084019350611d8e565b6001600160a01b03811681146116e3575f5ffd5b5f5f60408385031215611dd8575f5ffd5b823591506020830135611dea81611db3565b809150509250929050565b815181526020808301519082015260408083015190820152606080830151908201526080810161076c565b5f60208284031215611e30575f5ffd5b813561197e81611db3565b5f5f60408385031215611e4c575f5ffd5b82359150602083013560ff81168114611dea575f5ffd5b5f5f60a08385031215611e74575f5ffd5b82359150611e858460208501611ca6565b90509250929050565b80151581146116e3575f5ffd5b5f60208284031215611eab575f5ffd5b813561197e81611e8e565b5f5f60408385031215611ec7575f5ffd5b8235611ed281611db3565b91506020830135611dea81611db3565b6020808252601c908201527f43616c6c6572206973206e6f742061646d696e206f72206f776e657200000000604082015260600190565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b8181038181111561076c5761076c611f2d565b5f81611f6257611f62611f2d565b505f190190565b5f60208284031215611f79575f5ffd5b5051919050565b5f60208284031215611f90575f5ffd5b815161197e81611e8e565b8082018082111561076c5761076c611f2d565b808202811582820484141761076c5761076c611f2d565b5f82611fdf57634e487b7160e01b5f52601260045260245ffd5b500490565b5f82518060208501845e5f92019182525091905056fea49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775a2646970667358221220b3966c54051c655be3a2711ac64740873aa61b88ef3a561d61441b009523599964736f6c634300081c0033

Verified Source Code Partial Match

Compiler: v0.8.28+commit.7893614a EVM: cancun Optimization: Yes (200 runs)
YUUGEPresaleClaim.sol 1450 lines
// File: @openzeppelin/contracts/access/IAccessControl.sol


// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)

pragma solidity ^0.8.20;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev The `account` is missing a role.
     */
    error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);

    /**
     * @dev The caller of a function is not the expected one.
     *
     * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
     */
    error AccessControlBadConfirmation();

    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `callerConfirmation`.
     */
    function renounceRole(bytes32 role, address callerConfirmation) external;
}

// File: @openzeppelin/contracts/utils/Context.sol


// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

// File: @openzeppelin/contracts/utils/introspection/IERC165.sol


// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

// File: @openzeppelin/contracts/utils/introspection/ERC165.sol


// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)

pragma solidity ^0.8.20;


/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

// File: @openzeppelin/contracts/access/AccessControl.sol


// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)

pragma solidity ^0.8.20;




/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```solidity
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```solidity
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
 * to enforce additional security measures for this role.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address account => bool) hasRole;
        bytes32 adminRole;
    }

    mapping(bytes32 role => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with an {AccessControlUnauthorizedAccount} error including the required role.
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual returns (bool) {
        return _roles[role].hasRole[account];
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
     * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
     * is missing `role`.
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert AccessControlUnauthorizedAccount(account, role);
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `callerConfirmation`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address callerConfirmation) public virtual {
        if (callerConfirmation != _msgSender()) {
            revert AccessControlBadConfirmation();
        }

        _revokeRole(role, callerConfirmation);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
        if (!hasRole(role, account)) {
            _roles[role].hasRole[account] = true;
            emit RoleGranted(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
        if (hasRole(role, account)) {
            _roles[role].hasRole[account] = false;
            emit RoleRevoked(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }
}

// File: @openzeppelin/contracts/security/ReentrancyGuard.sol


// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == _ENTERED;
    }
}

// File: @openzeppelin/contracts/token/ERC20/IERC20.sol


// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the value of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 value) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 value) external returns (bool);
}

// File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol


// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     *
     * CAUTION: See Security Considerations above.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

// File: @openzeppelin/contracts/utils/Address.sol


// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error AddressInsufficientBalance(address account);

    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedInnerCall();

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        if (address(this).balance < amount) {
            revert AddressInsufficientBalance(address(this));
        }

        (bool success, ) = recipient.call{value: amount}("");
        if (!success) {
            revert FailedInnerCall();
        }
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason or custom error, it is bubbled
     * up by this function (like regular Solidity function calls). However, if
     * the call reverted with no returned reason, this function reverts with a
     * {FailedInnerCall} error.
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert AddressInsufficientBalance(address(this));
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
     * unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {FailedInnerCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
     */
    function _revert(bytes memory returndata) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert FailedInnerCall();
        }
    }
}

// File: @openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol


// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;




/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    /**
     * @dev An operation with an ERC20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data);
        if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
    }
}

// File: @openzeppelin/contracts/utils/math/SafeMath.sol


// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/SafeMath.sol)

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

// File: @openzeppelin/contracts/access/Ownable.sol


// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;


/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is set to the address provided by the deployer. This can
 * later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

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

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

// File: new/contracts/YUUGEPresale.sol


pragma solidity ^0.8.22;







contract YUUGEPresaleClaim is AccessControl, ReentrancyGuard, Ownable {
    using SafeMath for uint256;
    using SafeERC20 for IERC20;

    bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");

    struct PriceStep {
        uint256 timestamp;
        uint256 nativeTokenPrice;
        uint256 extraToken1Price;
        uint256 minPurchase;
    }

    IERC20 public tokenBeingSold = IERC20(0x39A90b49006964C1778Db5Ad10503B37da9EEB02);
    IERC20 public extraToken1 = IERC20(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48);

    address public fundRecipient;
    
    uint256 public MAX_SUPPLY = 40000000 ether;
    uint256 public totalSold;
    uint256 public MAX_PER_WALLET = 1500000 ether;

    uint256 public claimingStartTime = 1765534332;

    bool public presaleOn = true;
    bool public claimingOn = false;

    PriceStep[] public priceSteps;

    mapping(address => uint256) public purchases;

    event TokensPurchased(address indexed buyer, uint256 amount, uint256 price, uint8 tokenChoice);
    event TokensClaimed(address indexed claimer, uint256 amount);

    constructor(address _initialOwner) Ownable(_initialOwner) {
        _grantRole(ADMIN_ROLE, msg.sender);
        _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);

        fundRecipient = msg.sender;

        // Initialize priceSteps with maxTokens, tokensSold, and minPurchase
        priceSteps.push(PriceStep(block.timestamp, 0.00000034 ether, 0.0009e6, 11111 ether));
        priceSteps.push(PriceStep(block.timestamp + 7 days, 0.00000045 ether, 0.0012e6,  8333 ether));
        priceSteps.push(PriceStep(block.timestamp + 14 days, 0.00000057 ether, 0.0015e6, 6666 ether));
    }

    modifier onlyAdminOrOwner() {
        require(owner() == msg.sender || hasRole(ADMIN_ROLE, msg.sender), "Caller is not admin or owner");
        _;
    }

    function setPresaleState(bool _state) external onlyAdminOrOwner {
        presaleOn = _state;
    }

    function setClaimingState(bool _state) external onlyAdminOrOwner {
        claimingOn = _state;
    }

    function setClaimingStartTime(uint256 _startTime) external onlyAdminOrOwner {
        claimingStartTime = _startTime;
    }

    function updatePriceSteps(PriceStep[] memory _newPriceSteps) external onlyAdminOrOwner {
        delete priceSteps;
        for (uint i = 0; i < _newPriceSteps.length; i++) {
            priceSteps.push(_newPriceSteps[i]);
        }
    }

    function updateSinglePriceStep(uint256 _index, PriceStep memory _newStep) external onlyAdminOrOwner {
        require(_index < priceSteps.length, "Index out of bounds");
        priceSteps[_index] = _newStep;
    }

    function setMaxSupply(uint256 _maxSupply) external onlyAdminOrOwner {
        MAX_SUPPLY = _maxSupply;
    }

    function setMaxPerWallet(uint256 _maxPerWallet) external onlyAdminOrOwner {
        MAX_PER_WALLET = _maxPerWallet;
    }

    function setTokenAddresses(address _tokenBeingSold, address _extraToken1) external onlyAdminOrOwner {
        tokenBeingSold = IERC20(_tokenBeingSold);
        extraToken1 = IERC20(_extraToken1);
    }

    function setFundRecipient(address _newRecipient) external onlyOwner {
        fundRecipient = _newRecipient;
    }

    function getCurrentPriceStep() public view returns (PriceStep memory) {
        for (uint i = priceSteps.length - 1; i >= 0; i--) {
            if (block.timestamp >= priceSteps[i].timestamp) {
                return priceSteps[i];
            }
        }
        revert("No valid price step found");
    }

    function getCurrentPrice() public view returns (uint256 nativeTokenPrice, uint256 extraToken1Price) {
        PriceStep memory currentStep = getCurrentPriceStep();
        return (currentStep.nativeTokenPrice, currentStep.extraToken1Price);
    }

    function getPriceSteps() external view returns (PriceStep[] memory) {
        return priceSteps;
    }

    function purchase(uint256 _quantity, uint8 _tokenChoice) external payable nonReentrant {
        require(presaleOn, "...

// [truncated — 52789 bytes total]

Read Contract

ADMIN_ROLE 0x75b238fc → bytes32
DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
MAX_PER_WALLET 0x0f2cdd6c → uint256
MAX_SUPPLY 0x32cb6b0c → uint256
claimingOn 0x2959258f → bool
claimingStartTime 0x50480fd2 → uint256
extraToken1 0xd186baa0 → address
fundRecipient 0xd939c960 → address
getClaimableAmount 0xe12f3a61 → uint256
getCurrentPrice 0xeb91d37e → uint256, uint256
getCurrentPriceStep 0x35a9e7d6 → tuple
getPriceSteps 0x09b6c9ba → tuple[]
getRoleAdmin 0x248a9ca3 → bytes32
hasRole 0x91d14854 → bool
owner 0x8da5cb5b → address
presaleOn 0x1ad874b4 → bool
priceSteps 0x1011589f → uint256, uint256, uint256, uint256
purchases 0x842a77d3 → uint256
supportsInterface 0x01ffc9a7 → bool
tokenBeingSold 0xaba668c5 → address
totalSold 0x9106d7ba → uint256

Write Contract 19 functions

These functions modify contract state and require a wallet transaction to execute.

claimTokens 0x48c54b9d
No parameters
grantRole 0x2f2ff15d
bytes32 role
address account
purchase 0x72009407
uint256 _quantity
uint8 _tokenChoice
renounceOwnership 0x715018a6
No parameters
renounceRole 0x36568abe
bytes32 role
address callerConfirmation
revokeRole 0xd547741f
bytes32 role
address account
setClaimingStartTime 0x0e760a81
uint256 _startTime
setClaimingState 0x9c007c75
bool _state
setFundRecipient 0xbfb62028
address _newRecipient
setMaxPerWallet 0xe268e4d3
uint256 _maxPerWallet
setMaxSupply 0x6f8b44b0
uint256 _maxSupply
setPresaleState 0xbce4d6ae
bool _state
setTokenAddresses 0xa89c8c5e
address _tokenBeingSold
address _extraToken1
transferOwnership 0xf2fde38b
address newOwner
updatePriceSteps 0x6e42a51f
tuple[] _newPriceSteps
updateSinglePriceStep 0xb6f11aae
uint256 _index
tuple _newStep
withdrawCustomToken 0x5ac3cb3d
address _token
withdrawExtraToken 0x428a6455
No parameters
withdrawNativeToken 0x5a18664c
No parameters

Recent Transactions

No transactions found for this address