Skip to content
Verified contractPartialMIT

BatteryCoinPresale

Address0x529a7fd649e58c17e8e2f24841fa2cd391e6ebce
Balance

0 ETH

 

Transactions

17

 

Compiler

solc 0.8.28

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.28+commit.7893614a
Language
solidity
Optimization
No
EVM version
cancun
License
MIT
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
21,083,948
Creation transaction
0x5a46ac2736…935aa3e9f4

BatteryCoinPresale.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import "./IERC20.sol";
import "./Ownable.sol";
import "./ReentrancyGuard.sol";
import "./Pausable.sol";
import "./AggregatorV3Interface.sol";

contract BatteryCoinPresale is Ownable, ReentrancyGuard, Pausable {
    IERC20 public BATT;
    IERC20 public USDT;
    IERC20 public USDC;

    AggregatorV3Interface internal priceFeed;

    struct PresaleRound {
        uint256 startDate;
        uint256 roundNo;
        uint256 roundPrice;
        uint256 totalTokenAmount;
        uint256 remainAmount;
        bool isStarted;
        bool isFinished;
    }

    struct HashValue {
        address userAddress;
        uint roundNo;
        bytes32 hashValue;
        uint256 reserveDate;
        uint256 totalBATTAmount;
        uint256 tokenPrice;
        address tokenSymbol;
        uint256 totalPaidAmount;
        bool isReleased;
        uint256 vestingStart;
        uint256 vestingClaimedMonths;
        bool isRefunded;
        uint256 releasedBATTAmount;
    }

    mapping(uint256 => PresaleRound) public presaleRoundList;
    uint256 public presaleRoundCount;
    mapping(address => uint256) public userParticipation;
    mapping(address => bool) public ownerList;
    mapping(address => bool) public coreOwnerList;
    bytes32[] private hashValueList;
    mapping(bytes32 => HashValue) hashValues;
    uint256 lastRoundNo = 0;

    uint8 public USDTDecimal = 6;
    uint8 public batteryTokenDecimal = 18;
    uint8 public tokenValueDecimals = 2;
    uint256 public constant MAX_PARTICIPATION_AMOUNT = 1000000;
    uint256 public constant VESTING_PERIOD_MONTHS = 24;
    uint256 public constant ANNUAL_FEE_PERCENTAGE = 88; // 8.8% annual fee

    bool public vestingPeriodStarted = false;
    uint256 public vestingPeriodStartTime;
    bool private roundsInitialized = false; // Flag to check if rounds are initialized

    event OwnerAdded(address indexed newOwner);
    event OwnerRemoved(address indexed removedOwner);
    event RoundSet(uint256 indexed roundNo, uint256 startDate);
    event Reserved(
        address indexed user,
        bytes32 hashValue,
        uint256 amount,
        uint256 price
    );
    event PresaleReleased(
        bytes32 hashValue,
        address indexed user,
        uint256 amount
    );
    event MoneyReleased(address indexed to, uint256 amount);
    event TokenAddressSet(address indexed tokenAddress);
    event Debug(string message);
    event Refunded(address indexed user, uint256 amount);

    constructor() Ownable(msg.sender) {
        emit Debug("Constructor started");

        address _usdt = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
        address _usdc = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;

        require(
            _usdt != address(0) && _usdc != address(0),
            "Invalid token address"
        );

        USDT = IERC20(_usdt);
        USDC = IERC20(_usdc);

        emit TokenAddressSet(_usdt);
        emit TokenAddressSet(_usdc);

        // Initialize the Chainlink price feed
        priceFeed = AggregatorV3Interface(
            0xF79D6aFBb6dA890132F9D7c355e3015f15F3406F
        );

        emit Debug("Constructor finished");
    }

    modifier onlyOwners() {
        require(isOwner(msg.sender), "Caller is not an owner");
        _;
    }

    modifier onlyCoreOwners() {
        require(isCoreOwner(msg.sender), "Caller is not a core owner");
        _;
    }

    function isOwner(address _address) public view returns (bool) {
        return ownerList[_address];
    }

    function isCoreOwner(address _address) public view returns (bool) {
        return coreOwnerList[_address];
    }

    function addOwner(address _newOwner) external onlyOwner {
        ownerList[_newOwner] = true;
        emit OwnerAdded(_newOwner);
    }

    function removeOwner(address _owner) external onlyOwner {
        ownerList[_owner] = false;
        coreOwnerList[_owner] = false; // Ensure core owners are also removed
        emit OwnerRemoved(_owner);
    }

    function addCoreOwner(address _newCoreOwner) external onlyOwner {
        require(ownerList[_newCoreOwner], "Core owner must be an owner");
        coreOwnerList[_newCoreOwner] = true;
    }

    function removeCoreOwner(address _coreOwner) external onlyOwner {
        coreOwnerList[_coreOwner] = false;
    }

    function pause() external onlyCoreOwners {
        vestingPeriodStarted = true;
        vestingPeriodStartTime = block.timestamp;

        _pause();
    }

    function unpause() external onlyCoreOwners {
        vestingPeriodStarted = false;
        vestingPeriodStartTime = 0;

        _unpause();
    }

    function initializeRounds() external onlyOwner {
        require(!roundsInitialized, "Rounds have already been initialized");
        roundsInitialized = true; // Set the flag to true after initialization

        uint16[20] memory roundPrices = [
            50,
            75,
            100,
            200,
            400,
            600,
            800,
            1000,
            1200,
            1400,
            1600,
            1800,
            2000,
            2300,
            2600,
            2900,
            3200,
            3300,
            3400,
            3500
        ];
        uint32[20] memory totalTokenAmounts = [
            2000000,
            3000000,
            4000000,
            5000000,
            6000000,
            7000000,
            8000000,
            9000000,
            10000000,
            11000000,
            12000000,
            13000000,
            14000000,
            15000000,
            16000000,
            17000000,
            18000000,
            19000000,
            20000000,
            30000000
        ];

        uint256 multiplier = 10 ** batteryTokenDecimal;
        for (uint256 i = 0; i < roundPrices.length; i++) {
            presaleRoundList[i] = PresaleRound({
                startDate: 0,
                roundNo: i,
                roundPrice: roundPrices[i],
                totalTokenAmount: totalTokenAmounts[i] * multiplier,
                remainAmount: totalTokenAmounts[i] * multiplier,
                isStarted: false,
                isFinished: false
            });
        }

        presaleRoundCount = roundPrices.length;
        lastRoundNo = 0;
    }

    function setBATTTokenAddress(
        address _tokenAddress,
        uint8 _decimal
    ) external onlyOwners {
        BATT = IERC20(_tokenAddress);
        batteryTokenDecimal = _decimal;
        emit TokenAddressSet(_tokenAddress);
    }

    function setRound(
        uint256 _roundNo,
        uint256 _startDate
    ) external onlyOwners {
        require(_roundNo < presaleRoundCount, "Invalid round number");
        PresaleRound storage round = presaleRoundList[_roundNo];
        round.startDate = _startDate;
        updateRoundStatus(round);
        emit RoundSet(_roundNo, _startDate);
    }

    function updateRoundStatus(PresaleRound storage round) internal {
        if (round.remainAmount == 0) {
            round.isStarted = false;
            round.isFinished = true;

            if (round.roundNo == 19) {
                vestingPeriodStarted = true;
                vestingPeriodStartTime = block.timestamp;
            }
        } else {
            round.isStarted = block.timestamp >= round.startDate;
            round.isFinished = false;
        }
    }

    function reserve(
        uint256 _amount,
        address _token
    ) external nonReentrant whenNotPaused {
        require(
            _token == address(USDT) || _token == address(USDC),
            "Invalid token"
        );
        require(_amount > 0, "Amount must be greater than zero");
        require(
            userParticipation[msg.sender] + _amount <=
                MAX_PARTICIPATION_AMOUNT * (10 ** batteryTokenDecimal),
            "Exceeds max participation amount"
        );

        PresaleRound storage currentRound = getCurrentRound();
        updateRoundStatus(currentRound);
        require(
            currentRound.isStarted && !currentRound.isFinished,
            "Presale round not active"
        );
        require(
            currentRound.remainAmount >= _amount,
            "Not enough tokens left in this round"
        );

        uint256 usdAmount = (((_amount / (10 ** batteryTokenDecimal)) *
            currentRound.roundPrice) / (10 ** tokenValueDecimals)) *
            10 ** USDTDecimal;

        require(
            IERC20(_token).allowance(msg.sender, address(this)) >= usdAmount,
            "Insufficient allowance"
        );

        require(
            IERC20(_token).transferFrom(msg.sender, address(this), usdAmount),
            "Token transfer failed"
        );

        bytes32 hashValue = keccak256(
            abi.encodePacked(
                msg.sender,
                block.timestamp,
                _amount,
                currentRound.roundPrice
            )
        );
        hashValues[hashValue] = HashValue({
            userAddress: msg.sender,
            roundNo: currentRound.roundNo,
            hashValue: hashValue,
            reserveDate: block.timestamp,
            totalBATTAmount: _amount,
            tokenPrice: currentRound.roundPrice,
            tokenSymbol: _token,
            totalPaidAmount: usdAmount,
            isReleased: false,
            vestingStart: 0,
            vestingClaimedMonths: 0,
            isRefunded: false,
            releasedBATTAmount: 0
        });

        hashValueList.push(hashValue);

        currentRound.remainAmount -= _amount;
        userParticipation[msg.sender] += _amount;
        emit Reserved(msg.sender, hashValue, _amount, currentRound.roundPrice);
    }

    function reserveWithETH(
        uint256 _amount
    ) external payable nonReentrant whenNotPaused {
        require(_amount > 0, "Amount must be greater than zero");
        require(
            userParticipation[msg.sender] + _amount <=
                MAX_PARTICIPATION_AMOUNT * (10 ** batteryTokenDecimal),
            "Exceeds max participation amount"
        );

        PresaleRound storage currentRound = getCurrentRound();
        updateRoundStatus(currentRound);
        require(
            currentRound.isStarted && !currentRound.isFinished,
            "Presale round not active"
        );
        require(
            currentRound.remainAmount >= _amount,
            "Not enough tokens left in this round"
        );

        bytes32 hashValue = keccak256(
            abi.encodePacked(
                msg.sender,
                block.timestamp,
                _amount,
                currentRound.roundPrice
            )
        );
        hashValues[hashValue] = HashValue({
            userAddress: msg.sender,
            roundNo: currentRound.roundNo,
            hashValue: hashValue,
            reserveDate: block.timestamp,
            totalBATTAmount: _amount,
            tokenPrice: currentRound.roundPrice,
            tokenSymbol: address(0),
            totalPaidAmount: msg.value,
            isReleased: false,
            vestingStart: 0,
            vestingClaimedMonths: 0,
            isRefunded: false,
            releasedBATTAmount: 0
        });

        hashValueList.push(hashValue);

        currentRound.remainAmount -= _amount;
        userParticipation[msg.sender] += _amount;

        emit Reserved(msg.sender, hashValue, _amount, currentRound.roundPrice);
    }

    function getHashValuesByAddress(
        address userAddress
    ) external view returns (HashValue[] memory) {
        uint256 count = 0;
        for (uint256 i = 0; i < hashValueList.length; i++) {
            if (hashValues[hashValueList[i]].userAddress == userAddress) {
                count++;
            }
        }

        HashValue[] memory userHashValues = new HashValue[](count);
        uint256 index = 0;
        for (uint256 i = 0; i < hashValueList.length; i++) {
            if (hashValues[hashValueList[i]].userAddress == userAddress) {
                userHashValues[index++] = hashValues[hashValueList[i]];
            }
        }

        return userHashValues;
    }

    function getLastHashValueByAddress(
        address userAddress
    ) external view returns (bytes32) {
        for (uint256 i = hashValueList.length; i > 0; i--) {
            bytes32 hashValue = hashValueList[i - 1];
            if (hashValues[hashValue].userAddress == userAddress) {
                return hashValue;
            }
        }
        revert("No hash value found for the given address");
    }

    function getPresaleInfo(
        bytes32 _hashValue
    ) external view returns (HashValue memory) {
        HashValue storage hashValue = hashValues[_hashValue];
        require(hashValue.userAddress != address(0), "Invalid hash value");
        return hashValue;
    }

    function releasePresaleAll(
        bool isReleaseOneTime,
        uint256 releaseGroupNumber
    ) external onlyOwners nonReentrant {
        require(vestingPeriodStarted, "Release only after round 20 or paused");

        uint256 oneTimeRelease = 100;
        uint256 startIndex = isReleaseOneTime
            ? 0
            : oneTimeRelease * releaseGroupNumber;
        uint256 endIndex = isReleaseOneTime
            ? hashValueList.length
            : oneTimeRelease * (releaseGroupNumber + 1);
        if (endIndex > hashValueList.length) {
            endIndex = hashValueList.length;
        }

        for (uint256 i = startIndex; i < endIndex; i++) {
            bytes32 hashValue = hashValueList[i];
            HashValue storage hv = hashValues[hashValue];
            if (!hv.isReleased) {
                require(hv.userAddress != address(0), "Invalid hash value");

                uint256 monthlyAmount = (hv.totalBATTAmount -
                    hv.releasedBATTAmount) /
                    (VESTING_PERIOD_MONTHS - hv.vestingClaimedMonths);

                if (hv.vestingStart == 0) {
                    hv.vestingStart = vestingPeriodStartTime;
                }
                uint256 monthsElapsed = (block.timestamp - hv.vestingStart) /
                    30 days;
                uint256 claimableMonths = monthsElapsed -
                    hv.vestingClaimedMonths;

                if (
                    hv.vestingClaimedMonths + monthsElapsed >
                    VESTING_PERIOD_MONTHS
                ) {
                    claimableMonths =
                        VESTING_PERIOD_MONTHS -
                        hv.vestingClaimedMonths;
                }

                if (claimableMonths > 0) {
                    uint256 amountToRelease = monthlyAmount * claimableMonths;
                    if (
                        amountToRelease >
                        (hv.totalBATTAmount - hv.releasedBATTAmount)
                    ) {
                        amountToRelease =
                            hv.totalBATTAmount -
                            hv.releasedBATTAmount;
                    }

                    // Calculate the fee amount to add
                    uint256 feeAmount = (amountToRelease *
                        ANNUAL_FEE_PERCENTAGE) / 1000;
                    uint256 totalAmountToRelease = amountToRelease + feeAmount;

                    hv.releasedBATTAmount += amountToRelease;
                    hv.vestingClaimedMonths += claimableMonths;

                    // Transfer tokens from the caller to the userAddress
                    require(
                        BATT.transferFrom(
                            msg.sender,
                            hv.userAddress,
                            totalAmountToRelease
                        ),
                        "Token transfer failed"
                    );

                    emit PresaleReleased(
                        hashValue,
                        hv.userAddress,
                        totalAmountToRelease
                    );
                }

                if (hv.releasedBATTAmount == hv.totalBATTAmount) {
                    hv.isReleased = true;
                }
            }
        }
    }

    function releasePresaleByHashValue(
        bytes32 _hashValue
    ) external onlyOwners nonReentrant {
        require(vestingPeriodStarted, "Release only after round 20 or paused");

        HashValue storage hashValue = hashValues[_hashValue];
        require(hashValue.userAddress != address(0), "Invalid hash value");
        require(!hashValue.isReleased, "Already released");

        uint256 monthlyAmount = (hashValue.totalBATTAmount -
            hashValue.releasedBATTAmount) /
            (VESTING_PERIOD_MONTHS - hashValue.vestingClaimedMonths);

        if (hashValue.vestingStart == 0) {
            hashValue.vestingStart = vestingPeriodStartTime;
        }
        uint256 monthsElapsed = (block.timestamp - hashValue.vestingStart) /
            30 days;
        uint256 claimableMonths = monthsElapsed -
            hashValue.vestingClaimedMonths;

        if (
            hashValue.vestingClaimedMonths + monthsElapsed >
            VESTING_PERIOD_MONTHS
        ) {
            claimableMonths =
                VESTING_PERIOD_MONTHS -
                hashValue.vestingClaimedMonths;
        }

        if (claimableMonths > 0) {
            uint256 amountToRelease = monthlyAmount * claimableMonths;
            if (
                amountToRelease >
                (hashValue.totalBATTAmount - hashValue.releasedBATTAmount)
            ) {
                amountToRelease =
                    hashValue.totalBATTAmount -
                    hashValue.releasedBATTAmount;
            }

            // Calculate the fee amount to add
            uint256 feeAmount = (amountToRelease * ANNUAL_FEE_PERCENTAGE) /
                1000;
            uint256 totalAmountToRelease = amountToRelease + feeAmount;

            hashValue.releasedBATTAmount += amountToRelease;
            hashValue.vestingClaimedMonths += claimableMonths;

            // Transfer tokens from the caller to the userAddress
            require(
                BATT.transferFrom(
                    msg.sender,
                    hashValue.userAddress,
                    totalAmountToRelease
                ),
                "Token transfer failed"
            );

            emit PresaleReleased(
                _hashValue,
                hashValue.userAddress,
                totalAmountToRelease
            );
        }

        if (hashValue.releasedBATTAmount == hashValue.totalBATTAmount) {
            hashValue.isReleased = true;
        }
    }

    function releaseFunds(
        address _to,
        uint256 _amount,
        address _token
    ) external onlyOwners nonReentrant {
        if (_token == address(USDT) || _token == address(USDC)) {
            require(
                IERC20(_token).transfer(_to, _amount),
                "Token transfer failed"
            );
        } else if (_token == address(0)) {
            // address(0) is used to represent ETH
            (bool success, ) = _to.call{value: _amount}("");
            require(success, "ETH transfer failed");
        } else {
            revert("Invalid token");
        }
        emit MoneyReleased(_to, _amount);
    }

    function getCurrentRound() internal view returns (PresaleRound storage) {
        for (uint256 i = 0; i < presaleRoundCount; i++) {
            PresaleRound storage round = presaleRoundList[i];
            if (block.timestamp >= round.startDate && round.remainAmount > 0) {
                return round;
            }
        }
        revert("No active presale round");
    }

    function getLatestRound() external view returns (PresaleRound memory) {
        for (uint256 i = 0; i < presaleRoundCount; i++) {
            PresaleRound memory round = presaleRoundList[i];
            if (!round.isFinished) {
                return round;
            }
        }
        revert("No active presale round");
    }

    function refundUser(bytes32 _hashValue) external onlyOwners nonReentrant {
        require(
            vestingPeriodStarted &&
                block.timestamp >=
                vestingPeriodStartTime + VESTING_PERIOD_MONTHS * 30 days,
            "Refunds only available after vesting period"
        );

        HashValue storage hashValue = hashValues[_hashValue];
        require(
            hashValue.roundNo >= 0 && hashValue.roundNo <= 5,
            "Refunds only available for rounds 1 to 6"
        );
        require(hashValue.userAddress != address(0), "Invalid hash value");
        require(!hashValue.isRefunded, "Already refunded");

        uint256 refundAmount = hashValue.totalPaidAmount;
        address userAddress = hashValue.userAddress;
        address tokenSymbol = hashValue.tokenSymbol;

        if (tokenSymbol == address(0)) {
            // Refund in ETH
            (bool success, ) = userAddress.call{value: refundAmount}("");
            require(success, "ETH refund transfer failed");
        } else {
            // Refund in USDT or USDC
            require(
                IERC20(tokenSymbol).transfer(userAddress, refundAmount),
                "Token refund transfer failed"
            );
        }

        hashValue.isRefunded = true; // Set the isRefunded flag to true

        emit Refunded(userAddress, refundAmount);
    }
}

AggregatorV3Interface.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface AggregatorV3Interface {
    function decimals() external view returns (uint8);

    function description() external view returns (string memory);

    function version() external view returns (uint256);

    function getRoundData(
        uint80 _roundId
    )
        external
        view
        returns (
            uint80 roundId,
            int256 answer,
            uint256 startedAt,
            uint256 updatedAt,
            uint80 answeredInRound
        );

    function latestRoundData()
        external
        view
        returns (
            uint80 roundId,
            int256 answer,
            uint256 startedAt,
            uint256 updatedAt,
            uint80 answeredInRound
        );
}

Context.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.19;

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

ERC165.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)

pragma solidity ^0.8.19;

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

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC-165 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;
    }
}

IERC165.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.19;

/**
 * @dev Interface of the ERC-165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[ERC].
 *
 * 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[ERC 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);
}

IERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.19;

/**
 * @dev Interface of the ERC-20 standard as defined in the ERC.
 */
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);
}

Ownable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.19;

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

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

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

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

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

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

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

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

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

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

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

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

Pausable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)

pragma solidity ^0.8.19;

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

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    bool private _paused;

    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    /**
     * @dev The operation failed because the contract is paused.
     */
    error EnforcedPause();

    /**
     * @dev The operation failed because the contract is not paused.
     */
    error ExpectedPause();

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        _requirePaused();
        _;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        if (paused()) {
            revert EnforcedPause();
        }
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        if (!paused()) {
            revert ExpectedPause();
        }
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}

ReentrancyGuard.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)

pragma solidity ^0.8.19;

/**
 * @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 EIP-1153 (transient storage) is available on the chain you're deploying at,
 * consider using {ReentrancyGuardTransient} instead.
 *
 * 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;

    /**
     * @dev Unauthorized reentrant call.
     */
    error ReentrancyGuardReentrantCall();

    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
        if (_status == ENTERED) {
            revert ReentrancyGuardReentrantCall();
        }

        // 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;
    }
}
Compiler settingsShow
{
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "libraries": {},
  "optimizer": {
    "runs": 200,
    "enabled": false
  },
  "evmVersion": "cancun",
  "remappings": []
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.