S Price: $0.437306 (+0.03%)

Contract

0x6A43b2c8a00D2D0616a4e2A7d1e3c97f890d1211

Overview

S Balance

Sonic LogoSonic LogoSonic Logo0.648000032400000019 S

S Value

$0.28 (@ $0.44/S)

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Perform Upkeep56687592025-01-28 10:30:018 days ago1738060201IN
0x6A43b2c8...f890d1211
0.036 S0.004869950
Set Upkeep Calle...56681522025-01-28 10:18:078 days ago1738059487IN
0x6A43b2c8...f890d1211
0 S0.001847660.5
Enter Astro Spin56669702025-01-28 9:58:518 days ago1738058331IN
0x6A43b2c8...f890d1211
0.12790175 S0.0062702550
Enter Astro Spin56669582025-01-28 9:58:448 days ago1738058324IN
0x6A43b2c8...f890d1211
0.10580319 S0.0062702550
Enter Astro Spin56669522025-01-28 9:58:368 days ago1738058316IN
0x6A43b2c8...f890d1211
0.13345613 S0.0062702550
Enter Astro Spin56669442025-01-28 9:58:308 days ago1738058310IN
0x6A43b2c8...f890d1211
0.12392219 S0.0062702550
Enter Astro Spin56669382025-01-28 9:58:238 days ago1738058303IN
0x6A43b2c8...f890d1211
0.08766109 S0.0062702550
Enter Astro Spin56669292025-01-28 9:58:168 days ago1738058296IN
0x6A43b2c8...f890d1211
0.06336663 S0.0062702550
Enter Astro Spin56669162025-01-28 9:58:098 days ago1738058289IN
0x6A43b2c8...f890d1211
0.11915244 S0.0062702550
Enter Astro Spin56669082025-01-28 9:58:038 days ago1738058283IN
0x6A43b2c8...f890d1211
0.10009963 S0.0062702550
Enter Astro Spin56669012025-01-28 9:57:568 days ago1738058276IN
0x6A43b2c8...f890d1211
0.08964594 S0.0062702550
Enter Astro Spin56668932025-01-28 9:57:498 days ago1738058269IN
0x6A43b2c8...f890d1211
0.04749255 S0.0062702550
Enter Astro Spin56668892025-01-28 9:57:468 days ago1738058266IN
0x6A43b2c8...f890d1211
0.12129038 S0.0062702550
Enter Astro Spin56668812025-01-28 9:57:398 days ago1738058259IN
0x6A43b2c8...f890d1211
0.05310844 S0.0062702550
Enter Astro Spin56668752025-01-28 9:57:338 days ago1738058253IN
0x6A43b2c8...f890d1211
0.09789848 S0.0062702550
Enter Astro Spin56668642025-01-28 9:57:258 days ago1738058245IN
0x6A43b2c8...f890d1211
0.11908238 S0.0062702550
Enter Astro Spin56668542025-01-28 9:57:138 days ago1738058233IN
0x6A43b2c8...f890d1211
0.09286584 S0.0062702550
Enter Astro Spin56668472025-01-28 9:57:048 days ago1738058224IN
0x6A43b2c8...f890d1211
0.13473853 S0.0062702550
Enter Astro Spin56668342025-01-28 9:56:528 days ago1738058212IN
0x6A43b2c8...f890d1211
0.0692134 S0.0062702550
Enter Astro Spin56668152025-01-28 9:56:458 days ago1738058205IN
0x6A43b2c8...f890d1211
0.05885934 S0.0079802550

Latest 3 internal transactions

Parent Transaction Hash Block From To
56687622025-01-28 10:30:048 days ago1738060204
0x6A43b2c8...f890d1211
0.21951167 S
56687622025-01-28 10:30:048 days ago1738060204
0x6A43b2c8...f890d1211
0.8780467 S
56687592025-01-28 10:30:018 days ago1738060201
0x6A43b2c8...f890d1211
0.036 S
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
AstroSpin

Compiler Version
v0.8.16+commit.07a7930e

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 13 : AstroSpin.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@pythnetwork/entropy-sdk-solidity/IEntropy.sol";
import "@pythnetwork/entropy-sdk-solidity/IEntropyConsumer.sol";
import { SafeERC20, IERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";

error AstroSpin__NotEnoughEth();
error AstroSpin__TransferFailed();
error AstroSpin__NotOpen();
error AstroSpin__UpkeepNotNeeded(
	uint256 currentBalance,
	uint256 numPlayers,
	uint256 astroSpinState
);

contract AstroSpin is IEntropyConsumer, Ownable, ReentrancyGuard {
	// Entropy
	IEntropy entropy;
	address entropyProvider;

	/* state variables */
	uint256 public i_minEntranceFee;
	address payable[] public s_players;
	address payable public treasuryWallet;
	mapping(address => bool) public isSpecialWallet;
	address[] public specialWalletsList;
	bool public feeEnabled = true;

	uint256 public specialWalletPool;

	address payable[] public s_recentWinner;
	mapping(address => bool) public isPlayerEntered;
	uint256 public roundCount = 0;

	mapping(address => uint256) contributions;
	address public caller;

	/** Variables */
	enum AstroSpinState {
		OPEN,
		CALCULATING
	}
	AstroSpinState private s_AstroSpinState;
	uint256 private s_lastTimeStamp;

	/* events */
	event AstroSpinEnterRequest(uint64 sequenceNumber);
	event AstroSpinEnterResult(uint64 sequenceNumber);
	event AstroSpinEnter(address indexed player, uint256 amount);
	event AstroSpinResult(uint64 sequenceNumber);

	event RequestedAstroSpinWinner(uint256 indexed requestId);
	event WinnerPicked(address indexed winner, uint256 prize, uint256 contribution);
	event TreasuryChanged(address indexed newTreasury);

	// Events for tracking refund status
	event RefundIssued(address to, uint256 amount);
	event RefundFailed(address to, uint256 amount);
	event SpecialWalletPoolFilled(uint256 amount, uint256 newTotal);

	/**
	 * @notice Constructor initializes the AstroSpin contract
	 * @param minEntranceFee The fee required to enter the game
	 * @param _treasuryWallet Address where treasury funds will be sent
	 * @param _entropy Address of the Entropy contract for randomness
	 * @param _entropyProvider Address of the entropy provider
	 */
	constructor(
		uint256 minEntranceFee,
		address payable _treasuryWallet,
		address _entropy,
		address _entropyProvider,
		address _caller
	) {
		i_minEntranceFee = minEntranceFee;
		s_AstroSpinState = AstroSpinState.OPEN;
		treasuryWallet = _treasuryWallet;
		entropy = IEntropy(_entropy);
		entropyProvider = _entropyProvider;
		caller = _caller;
	}

	modifier onlyCaller() {
		require(
			msg.sender == caller || msg.sender == owner(),
			"Only the caller or owner can call this function"
		);
		_;
	}

	function setUpkeepCaller(address _newCaller) external onlyOwner {
		require(_newCaller != address(0), "New caller cannot be zero address");
		caller = _newCaller;
	}

	// This method is required by the IEntropyConsumer interface
	function getEntropy() internal view override returns (address) {
		return address(entropy);
	}

	function getFlipFee() public view returns (uint256 fee) {
		fee = entropy.getFee(entropyProvider);
	}

	function toggleFee(bool _enabled) public onlyOwner {
		feeEnabled = _enabled;
	}

	function enterAstroSpin() public payable {
		require(s_AstroSpinState == AstroSpinState.OPEN, "AstroSpin__NotOpen");

		uint256 flipFee = feeEnabled ? entropy.getFee(entropyProvider) : 0;
		specialWalletPool += flipFee;

		if (isSpecialWallet[msg.sender]) {
			require(specialWalletPool >= i_minEntranceFee, "Reserve__InsufficientFunds");
			specialWalletPool -= i_minEntranceFee;
			contributions[msg.sender] += i_minEntranceFee;

			// Remove from special wallet status
			isSpecialWallet[msg.sender] = false;

			// Remove from specialWalletsList
			for (uint i = 0; i < specialWalletsList.length; i++) {
				if (specialWalletsList[i] == msg.sender) {
					specialWalletsList[i] = specialWalletsList[
						specialWalletsList.length - 1
					];
					specialWalletsList.pop();
					break;
				}
			}
		} else {
			require(msg.value >= i_minEntranceFee, "AstroSpin__NotEnoughEth");
			contributions[msg.sender] += msg.value - flipFee;
		}

		if (!isPlayerEntered[msg.sender]) {
			s_players.push(payable(msg.sender));
			isPlayerEntered[msg.sender] = true;
		}

		emit AstroSpinEnter(msg.sender, contributions[msg.sender]);
	}

	/**
	 * @notice Initiates the random winner selection process if conditions are met
	 * @dev Checks if game is open, has balance and minimum players before requesting entropy
	 * @param userRandomNumber Additional entropy input from user
	 */
	function performUpkeep(bytes32 userRandomNumber) external payable onlyCaller {
		bool isOpen = AstroSpinState.OPEN == s_AstroSpinState;
		bool hasBalance = address(this).balance > 0;
		bool hasPlayers = s_players.length >= 2;

		bool upkeepNeeded = (isOpen && hasBalance && hasPlayers);

		if (!upkeepNeeded) {
			revert AstroSpin__UpkeepNotNeeded(
				address(this).balance,
				s_players.length,
				uint256(s_AstroSpinState)
			);
		}

		s_AstroSpinState = AstroSpinState.CALCULATING;

		uint256 fee = entropy.getFee(entropyProvider);

		uint64 sequenceNumber = entropy.requestWithCallback{ value: fee }(
			entropyProvider,
			userRandomNumber
		);

		emit RequestedAstroSpinWinner(sequenceNumber);
		emit AstroSpinEnterRequest(sequenceNumber);
	}

	/**
	 * @notice Callback function called by entropy provider with random number
	 * @dev Selects winner based on weighted contributions and distributes prizes
	 * @param sequenceNumber The sequence number of the entropy request
	 * @param randomNumber The random number provided by entropy source
	 */
	function entropyCallback(
		uint64 sequenceNumber,
		address,
		bytes32 randomNumber
	) internal override {
		delete s_recentWinner;

		uint256 totalContributions = 0;
		for (uint256 i = 0; i < s_players.length; i++) {
			totalContributions += contributions[s_players[i]];
		}

		require(totalContributions > 0, "Total contributions must be positive");

		uint256 winningThreshold = uint256(randomNumber) % totalContributions;
		uint256 cumulativeContribution = 0;
		address payable recentWinner = payable(address(0));

		for (uint256 i = 0; i < s_players.length; i++) {
			cumulativeContribution += contributions[s_players[i]];
			if (winningThreshold < cumulativeContribution) {
				recentWinner = s_players[i];
				break;
			}
		}

		uint256 pool = address(this).balance - specialWalletPool;

		uint256 prizes;
		uint256 treasuryAmount;

		// Check if winner's contribution is greater than potential prize
		uint256 potentialPrize = (pool * 80) / 100;
		if (contributions[recentWinner] > potentialPrize) {
			// If winner would get less than their contribution, give them the full pool
			prizes = pool;
			treasuryAmount = 0;
		} else {
			// Otherwise proceed with normal 80/20 split
			prizes = potentialPrize;
			treasuryAmount = (pool * 20) / 100;
		}
		// Transfer prize directly to winner
		(bool prizeSuccess, ) = recentWinner.call{ value: prizes }("");
		require(prizeSuccess, "Prize transfer failed");

		// Transfer treasury amount to treasury wallet if any
		if (treasuryAmount > 0) {
			(bool treasurySuccess, ) = treasuryWallet.call{ value: treasuryAmount }("");
			require(treasurySuccess, "Treasury transfer failed");
		}

		s_recentWinner.push(recentWinner);
		emit WinnerPicked(recentWinner, prizes, contributions[recentWinner]);
		emit AstroSpinResult(sequenceNumber);

		// Reset for next AstroSpin
		for (uint256 i = 0; i < s_players.length; i++) {
			address player = s_players[i];
			contributions[player] = 0;
			isPlayerEntered[player] = false;
		}
		roundCount++;
		s_AstroSpinState = AstroSpinState.OPEN;
		s_players = new address payable[](0);
		s_lastTimeStamp = block.timestamp;
	}

	function getContractBalance() public view returns (uint256) {
		return address(this).balance;
	}

	function getBalanceWithoutPlatformFund() public view returns (uint256) {
		if (specialWalletPool > address(this).balance) {
			return 0;
		}
		uint256 totalDeductions = address(this).balance - specialWalletPool;
		return totalDeductions;
	}

	function getAstroSpinState() public view returns (AstroSpinState) {
		return s_AstroSpinState;
	}

	function getSpecialWallets() public view returns (address[] memory) {
		return specialWalletsList;
	}

	function getMinEntranceFee() public view returns (uint256) {
		return i_minEntranceFee;
	}

	function getPlayer(uint256 index) public view returns (address) {
		return s_players[index];
	}

	function getAllPlayers() public view returns (address payable[] memory) {
		return s_players;
	}

	function getRecentWinners() public view returns (address payable[] memory) {
		return s_recentWinner;
	}

	function getLastTimeStamp() public view returns (uint256) {
		return s_lastTimeStamp;
	}

	function getNumberOfPlayers() public view returns (uint256) {
		return s_players.length;
	}

	function getRoundCount() public view returns (uint256) {
		return roundCount;
	}

	function getSpecialWalletPool() public view returns (uint256) {
		return specialWalletPool;
	}

	/**
	 * @notice Fills the pool used for special free entries
	 * @dev Only callable by contract owner, requires ETH to be sent
	 */
	function fundSpecialPool() external payable {
		require(msg.value > 0, "Must send ETH");
		specialWalletPool += msg.value;
		emit SpecialWalletPoolFilled(msg.value, specialWalletPool);
	}

	function transferSpecialPoolFunds(address payable _to) public onlyOwner {
		require(_to != address(0), "Invalid address");
		require(specialWalletPool > 0, "No funds to transfer");

		uint256 amountToTransfer = specialWalletPool;
		specialWalletPool = 0; // Reset before transfer to prevent reentrancy

		(bool success, ) = _to.call{ value: amountToTransfer }("");
		require(success, "Transfer failed");
	}

	function getPlayerContributionsPercentages()
		public
		view
		returns (address[] memory, uint256[] memory, uint256[] memory)
	{
		address[] memory players = new address[](s_players.length);
		uint256[] memory percentages = new uint256[](s_players.length);
		uint256[] memory contributionsArray = new uint256[](s_players.length);
		uint256 total = 0;

		// Calculate total contributions
		for (uint256 i = 0; i < s_players.length; i++) {
			total += contributions[s_players[i]];
		}

		// Calculate each player's percentage of total contributions and get their contribution
		for (uint256 i = 0; i < s_players.length; i++) {
			players[i] = s_players[i];
			contributionsArray[i] = contributions[s_players[i]]; // Store individual contributions
			if (total > 0) {
				percentages[i] = (contributions[s_players[i]] * 100) / total;
			} else {
				percentages[i] = 0;
			}
		}

		return (players, percentages, contributionsArray);
	}

	function removeSpecialWallets(address[] calldata _wallets) external onlyOwner {
		for (uint256 i = 0; i < _wallets.length; i++) {
			address wallet = _wallets[i];
			isSpecialWallet[wallet] = false;

			// Remove from specialWalletsList
			for (uint256 j = 0; j < specialWalletsList.length; j++) {
				if (specialWalletsList[j] == wallet) {
					// Swap with last element and pop
					specialWalletsList[j] = specialWalletsList[
						specialWalletsList.length - 1
					];
					specialWalletsList.pop();
					break;
				}
			}
		}
	}

	function addSpecialWallets(address[] calldata _wallets) external onlyOwner {
		for (uint256 i = 0; i < _wallets.length; i++) {
			address wallet = _wallets[i];
			require(wallet != address(0), "Invalid address");

			// Check if wallet already exists in the list
			bool walletExists = false;
			for (uint256 j = 0; j < specialWalletsList.length; j++) {
				if (specialWalletsList[j] == wallet) {
					walletExists = true;
					break;
				}
			}

			// Only add if wallet is not already in the list
			if (!walletExists) {
				isSpecialWallet[wallet] = true;
				specialWalletsList.push(wallet);
			}
		}
	}

	// Function to update the entrance fee
	function updateEntranceFee(uint256 _newMinEntranceFee) external onlyOwner {
		i_minEntranceFee = _newMinEntranceFee;
	}

	function setTreasury(address payable _newTreasury) public onlyOwner {
		require(_newTreasury != address(0), "New treasury cannot be the zero address");
		treasuryWallet = _newTreasury;
		emit TreasuryChanged(_newTreasury);
	}

	function refundAllParticipants() external onlyOwner nonReentrant {
		// require(s_AstroSpinState == AstroSpinState.CALCULATING);
		uint256 playerCount = s_players.length;

		for (uint256 i = 0; i < playerCount; i++) {
			address payable player = s_players[i];
			uint256 playerContribution = contributions[player];
			if (playerContribution > 0) {
				if (isSpecialWallet[player]) {
					// Return contribution back to specialWalletPool
					specialWalletPool += playerContribution;
				} else {
					// Regular player gets refunded
					(bool success, ) = player.call{ value: playerContribution }("");
					require(success, "REFUND_FAILED");
				}
				contributions[player] = 0;
				isPlayerEntered[player] = false;
			}
		}
		s_AstroSpinState = AstroSpinState.OPEN;
		delete s_players;
	}

	receive() external payable {}
}

File 2 of 13 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/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.
 *
 * By default, the owner account will be the one that deploys the contract. 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;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @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 {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @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 {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _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 3 of 13 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// 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 4 of 13 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @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 5 of 13 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @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 amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

File 6 of 13 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";

/**
 * @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 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.encodeWithSelector(token.transfer.selector, 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.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 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);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @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.encodeWithSelector(token.approve.selector, spender, value);

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

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @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, "SafeERC20: low-level call failed");
        require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
    }

    /**
     * @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.isContract(address(token));
    }
}

File 7 of 13 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @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.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @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, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * 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.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @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`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

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

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) 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(errorMessage);
        }
    }
}

File 8 of 13 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @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 9 of 13 : SafeMath.sol
// SPDX-License-Identifier: MIT
// 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 10 of 13 : EntropyEvents.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

import "./EntropyStructs.sol";

interface EntropyEvents {
    event Registered(EntropyStructs.ProviderInfo provider);

    event Requested(EntropyStructs.Request request);
    event RequestedWithCallback(
        address indexed provider,
        address indexed requestor,
        uint64 indexed sequenceNumber,
        bytes32 userRandomNumber,
        EntropyStructs.Request request
    );

    event Revealed(
        EntropyStructs.Request request,
        bytes32 userRevelation,
        bytes32 providerRevelation,
        bytes32 blockHash,
        bytes32 randomNumber
    );
    event RevealedWithCallback(
        EntropyStructs.Request request,
        bytes32 userRandomNumber,
        bytes32 providerRevelation,
        bytes32 randomNumber
    );

    event ProviderFeeUpdated(address provider, uint128 oldFee, uint128 newFee);

    event ProviderUriUpdated(address provider, bytes oldUri, bytes newUri);

    event ProviderFeeManagerUpdated(
        address provider,
        address oldFeeManager,
        address newFeeManager
    );

    event Withdrawal(
        address provider,
        address recipient,
        uint128 withdrawnAmount
    );
}

File 11 of 13 : EntropyStructs.sol
// SPDX-License-Identifier: Apache 2

pragma solidity ^0.8.0;

contract EntropyStructs {
    struct ProviderInfo {
        uint128 feeInWei;
        uint128 accruedFeesInWei;
        // The commitment that the provider posted to the blockchain, and the sequence number
        // where they committed to this. This value is not advanced after the provider commits,
        // and instead is stored to help providers track where they are in the hash chain.
        bytes32 originalCommitment;
        uint64 originalCommitmentSequenceNumber;
        // Metadata for the current commitment. Providers may optionally use this field to help
        // manage rotations (i.e., to pick the sequence number from the correct hash chain).
        bytes commitmentMetadata;
        // Optional URI where clients can retrieve revelations for the provider.
        // Client SDKs can use this field to automatically determine how to retrieve random values for each provider.
        // TODO: specify the API that must be implemented at this URI
        bytes uri;
        // The first sequence number that is *not* included in the current commitment (i.e., an exclusive end index).
        // The contract maintains the invariant that sequenceNumber <= endSequenceNumber.
        // If sequenceNumber == endSequenceNumber, the provider must rotate their commitment to add additional random values.
        uint64 endSequenceNumber;
        // The sequence number that will be assigned to the next inbound user request.
        uint64 sequenceNumber;
        // The current commitment represents an index/value in the provider's hash chain.
        // These values are used to verify requests for future sequence numbers. Note that
        // currentCommitmentSequenceNumber < sequenceNumber.
        //
        // The currentCommitment advances forward through the provider's hash chain as values
        // are revealed on-chain.
        bytes32 currentCommitment;
        uint64 currentCommitmentSequenceNumber;
        // An address that is authorized to set / withdraw fees on behalf of this provider.
        address feeManager;
    }

    struct Request {
        // Storage slot 1 //
        address provider;
        uint64 sequenceNumber;
        // The number of hashes required to verify the provider revelation.
        uint32 numHashes;
        // Storage slot 2 //
        // The commitment is keccak256(userCommitment, providerCommitment). Storing the hash instead of both saves 20k gas by
        // eliminating 1 store.
        bytes32 commitment;
        // Storage slot 3 //
        // The number of the block where this request was created.
        // Note that we're using a uint64 such that we have an additional space for an address and other fields in
        // this storage slot. Although block.number returns a uint256, 64 bits should be plenty to index all of the
        // blocks ever generated.
        uint64 blockNumber;
        // The address that requested this random number.
        address requester;
        // If true, incorporate the blockhash of blockNumber into the generated random value.
        bool useBlockhash;
        // If true, the requester will be called back with the generated random value.
        bool isRequestWithCallback;
        // There are 2 remaining bytes of free space in this slot.
    }
}

File 12 of 13 : IEntropy.sol
// SPDX-License-Identifier: Apache 2
pragma solidity ^0.8.0;

import "./EntropyEvents.sol";

interface IEntropy is EntropyEvents {
    // Register msg.sender as a randomness provider. The arguments are the provider's configuration parameters
    // and initial commitment. Re-registering the same provider rotates the provider's commitment (and updates
    // the feeInWei).
    //
    // chainLength is the number of values in the hash chain *including* the commitment, that is, chainLength >= 1.
    function register(
        uint128 feeInWei,
        bytes32 commitment,
        bytes calldata commitmentMetadata,
        uint64 chainLength,
        bytes calldata uri
    ) external;

    // Withdraw a portion of the accumulated fees for the provider msg.sender.
    // Calling this function will transfer `amount` wei to the caller (provided that they have accrued a sufficient
    // balance of fees in the contract).
    function withdraw(uint128 amount) external;

    // Withdraw a portion of the accumulated fees for provider. The msg.sender must be the fee manager for this provider.
    // Calling this function will transfer `amount` wei to the caller (provided that they have accrued a sufficient
    // balance of fees in the contract).
    function withdrawAsFeeManager(address provider, uint128 amount) external;

    // As a user, request a random number from `provider`. Prior to calling this method, the user should
    // generate a random number x and keep it secret. The user should then compute hash(x) and pass that
    // as the userCommitment argument. (You may call the constructUserCommitment method to compute the hash.)
    //
    // This method returns a sequence number. The user should pass this sequence number to
    // their chosen provider (the exact method for doing so will depend on the provider) to retrieve the provider's
    // number. The user should then call fulfillRequest to construct the final random number.
    //
    // This method will revert unless the caller provides a sufficient fee (at least getFee(provider)) as msg.value.
    // Note that excess value is *not* refunded to the caller.
    function request(
        address provider,
        bytes32 userCommitment,
        bool useBlockHash
    ) external payable returns (uint64 assignedSequenceNumber);

    // Request a random number. The method expects the provider address and a secret random number
    // in the arguments. It returns a sequence number.
    //
    // The address calling this function should be a contract that inherits from the IEntropyConsumer interface.
    // The `entropyCallback` method on that interface will receive a callback with the generated random number.
    //
    // This method will revert unless the caller provides a sufficient fee (at least getFee(provider)) as msg.value.
    // Note that excess value is *not* refunded to the caller.
    function requestWithCallback(
        address provider,
        bytes32 userRandomNumber
    ) external payable returns (uint64 assignedSequenceNumber);

    // Fulfill a request for a random number. This method validates the provided userRandomness and provider's proof
    // against the corresponding commitments in the in-flight request. If both values are validated, this function returns
    // the corresponding random number.
    //
    // Note that this function can only be called once per in-flight request. Calling this function deletes the stored
    // request information (so that the contract doesn't use a linear amount of storage in the number of requests).
    // If you need to use the returned random number more than once, you are responsible for storing it.
    function reveal(
        address provider,
        uint64 sequenceNumber,
        bytes32 userRevelation,
        bytes32 providerRevelation
    ) external returns (bytes32 randomNumber);

    // Fulfill a request for a random number. This method validates the provided userRandomness
    // and provider's revelation against the corresponding commitment in the in-flight request. If both values are validated
    // and the requestor address is a contract address, this function calls the requester's entropyCallback method with the
    // sequence number, provider address and the random number as arguments. Else if the requestor is an EOA, it won't call it.
    //
    // Note that this function can only be called once per in-flight request. Calling this function deletes the stored
    // request information (so that the contract doesn't use a linear amount of storage in the number of requests).
    // If you need to use the returned random number more than once, you are responsible for storing it.
    //
    // Anyone can call this method to fulfill a request, but the callback will only be made to the original requester.
    function revealWithCallback(
        address provider,
        uint64 sequenceNumber,
        bytes32 userRandomNumber,
        bytes32 providerRevelation
    ) external;

    function getProviderInfo(
        address provider
    ) external view returns (EntropyStructs.ProviderInfo memory info);

    function getDefaultProvider() external view returns (address provider);

    function getRequest(
        address provider,
        uint64 sequenceNumber
    ) external view returns (EntropyStructs.Request memory req);

    function getFee(address provider) external view returns (uint128 feeAmount);

    function getAccruedPythFees()
        external
        view
        returns (uint128 accruedPythFeesInWei);

    function setProviderFee(uint128 newFeeInWei) external;

    function setProviderFeeAsFeeManager(
        address provider,
        uint128 newFeeInWei
    ) external;

    function setProviderUri(bytes calldata newUri) external;

    // Set manager as the fee manager for the provider msg.sender.
    // After calling this function, manager will be able to set the provider's fees and withdraw them.
    // Only one address can be the fee manager for a provider at a time -- calling this function again with a new value
    // will override the previous value. Call this function with the all-zero address to disable the fee manager role.
    function setFeeManager(address manager) external;

    function constructUserCommitment(
        bytes32 userRandomness
    ) external pure returns (bytes32 userCommitment);

    function combineRandomValues(
        bytes32 userRandomness,
        bytes32 providerRandomness,
        bytes32 blockHash
    ) external pure returns (bytes32 combinedRandomness);
}

File 13 of 13 : IEntropyConsumer.sol
// SPDX-License-Identifier: Apache 2
pragma solidity ^0.8.0;

abstract contract IEntropyConsumer {
    // This method is called by Entropy to provide the random number to the consumer.
    // It asserts that the msg.sender is the Entropy contract. It is not meant to be
    // override by the consumer.
    function _entropyCallback(
        uint64 sequence,
        address provider,
        bytes32 randomNumber
    ) external {
        address entropy = getEntropy();
        require(entropy != address(0), "Entropy address not set");
        require(msg.sender == entropy, "Only Entropy can call this function");

        entropyCallback(sequence, provider, randomNumber);
    }

    // getEntropy returns Entropy contract address. The method is being used to check that the
    // callback is indeed from Entropy contract. The consumer is expected to implement this method.
    // Entropy address can be found here - https://docs.pyth.network/entropy/contract-addresses
    function getEntropy() internal view virtual returns (address);

    // This method is expected to be implemented by the consumer to handle the random number.
    // It will be called by _entropyCallback after _entropyCallback ensures that the call is
    // indeed from Entropy contract.
    function entropyCallback(
        uint64 sequence,
        address provider,
        bytes32 randomNumber
    ) internal virtual;
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "metadata": {
    "useLiteralContent": true
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"uint256","name":"minEntranceFee","type":"uint256"},{"internalType":"address payable","name":"_treasuryWallet","type":"address"},{"internalType":"address","name":"_entropy","type":"address"},{"internalType":"address","name":"_entropyProvider","type":"address"},{"internalType":"address","name":"_caller","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256","name":"currentBalance","type":"uint256"},{"internalType":"uint256","name":"numPlayers","type":"uint256"},{"internalType":"uint256","name":"astroSpinState","type":"uint256"}],"name":"AstroSpin__UpkeepNotNeeded","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"player","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AstroSpinEnter","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"sequenceNumber","type":"uint64"}],"name":"AstroSpinEnterRequest","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"sequenceNumber","type":"uint64"}],"name":"AstroSpinEnterResult","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"sequenceNumber","type":"uint64"}],"name":"AstroSpinResult","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RefundFailed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RefundIssued","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"requestId","type":"uint256"}],"name":"RequestedAstroSpinWinner","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTotal","type":"uint256"}],"name":"SpecialWalletPoolFilled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newTreasury","type":"address"}],"name":"TreasuryChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":false,"internalType":"uint256","name":"prize","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"contribution","type":"uint256"}],"name":"WinnerPicked","type":"event"},{"inputs":[{"internalType":"uint64","name":"sequence","type":"uint64"},{"internalType":"address","name":"provider","type":"address"},{"internalType":"bytes32","name":"randomNumber","type":"bytes32"}],"name":"_entropyCallback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_wallets","type":"address[]"}],"name":"addSpecialWallets","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"caller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"enterAstroSpin","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"feeEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fundSpecialPool","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getAllPlayers","outputs":[{"internalType":"address payable[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAstroSpinState","outputs":[{"internalType":"enum AstroSpin.AstroSpinState","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBalanceWithoutPlatformFund","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getContractBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getFlipFee","outputs":[{"internalType":"uint256","name":"fee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLastTimeStamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMinEntranceFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNumberOfPlayers","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getPlayer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPlayerContributionsPercentages","outputs":[{"internalType":"address[]","name":"","type":"address[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRecentWinners","outputs":[{"internalType":"address payable[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRoundCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSpecialWalletPool","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSpecialWallets","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"i_minEntranceFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isPlayerEntered","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isSpecialWallet","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"userRandomNumber","type":"bytes32"}],"name":"performUpkeep","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"refundAllParticipants","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_wallets","type":"address[]"}],"name":"removeSpecialWallets","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"roundCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"s_players","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"s_recentWinner","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address payable","name":"_newTreasury","type":"address"}],"name":"setTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newCaller","type":"address"}],"name":"setUpkeepCaller","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"specialWalletPool","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"specialWalletsList","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"_enabled","type":"bool"}],"name":"toggleFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"_to","type":"address"}],"name":"transferSpecialPoolFunds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasuryWallet","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newMinEntranceFee","type":"uint256"}],"name":"updateEntranceFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60806040526009805460ff191660011790556000600d553480156200002357600080fd5b50604051620027f4380380620027f4833981016040819052620000469162000122565b6200005133620000b9565b60018055600494909455600f8054600680546001600160a01b03199081166001600160a01b03978816179091556002805482169587169590951790945560038054909416928516929092179092556001600160a81b0319169290911691909117905562000196565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b03811681146200011f57600080fd5b50565b600080600080600060a086880312156200013b57600080fd5b8551945060208601516200014f8162000109565b6040870151909450620001628162000109565b6060870151909350620001758162000109565b6080870151909250620001888162000109565b809150509295509295909350565b61264e80620001a66000396000f3fe60806040526004361061023f5760003560e01c8063a1e9b5111161012e578063e044e9c3116100ab578063f077b9741161006f578063f077b9741461064f578063f0f4426014610664578063f2fde38b14610684578063fc9c8d39146106a4578063fd6673f5146106c457600080fd5b8063e044e9c3146105b6578063e2a6b148146105d8578063e55ae4e8146105f8578063ee78635514610618578063efa1c4821461062d57600080fd5b8063c1c6d865116100f2578063c1c6d86514610522578063c7da8f8114610537578063d604e29b1461053f578063ddc382d21461056f578063df66a8361461058f57600080fd5b8063a1e9b51114610480578063a771ebc714610493578063ae771f6b146104bd578063b9e7987e146104dd578063c1c244e81461050d57600080fd5b806352a5f1f8116101bc578063715018a611610180578063715018a6146103f757806377ec0f9a1461040c5780637f1fce7814610422578063868e4c61146104425780638da5cb5b1461046257600080fd5b806352a5f1f814610379578063654ebd6214610399578063659c1465146103af5780636de7da78146103cf5780636f9fb98a146103e457600080fd5b80633b35c517116102035780633b35c517146102d35780634244b0da146102e857806342aaa9e4146103085780634626402b1461031d5780634edbf60a1461035557600080fd5b8063046596fa1461024b578063127f0b3f1461025557806325f227751461027e57806335fec07014610293578063391c3fe1146102b357600080fd5b3661024657005b600080fd5b6102536106d9565b005b34801561026157600080fd5b5061026b600d5481565b6040519081526020015b60405180910390f35b34801561028a57600080fd5b5061026b610aef565b34801561029f57600080fd5b506102536102ae366004612249565b610b72565b3480156102bf57600080fd5b506102536102ce3660046122d3565b610cf1565b3480156102df57600080fd5b5060045461026b565b3480156102f457600080fd5b506102536103033660046122f7565b610e27565b34801561031457600080fd5b5061026b610e34565b34801561032957600080fd5b5060065461033d906001600160a01b031681565b6040516001600160a01b039091168152602001610275565b34801561036157600080fd5b5061036a610e5c565b60405161027593929190612384565b34801561038557600080fd5b506102536103943660046123dd565b611132565b3480156103a557600080fd5b5061026b600a5481565b3480156103bb57600080fd5b5061033d6103ca3660046122f7565b611213565b3480156103db57600080fd5b50600d5461026b565b3480156103f057600080fd5b504761026b565b34801561040357600080fd5b5061025361123d565b34801561041857600080fd5b5061026b60045481565b34801561042e57600080fd5b5061025361043d3660046122d3565b611251565b34801561044e57600080fd5b5061025361045d36600461241e565b6112db565b34801561046e57600080fd5b506000546001600160a01b031661033d565b61025361048e3660046122f7565b6112f6565b34801561049f57600080fd5b506009546104ad9060ff1681565b6040519015158152602001610275565b3480156104c957600080fd5b5061033d6104d83660046122f7565b6115aa565b3480156104e957600080fd5b506104ad6104f83660046122d3565b60076020526000908152604090205460ff1681565b34801561051957600080fd5b5060105461026b565b34801561052e57600080fd5b50600a5461026b565b6102536115ba565b34801561054b57600080fd5b506104ad61055a3660046122d3565b600c6020526000908152604090205460ff1681565b34801561057b57600080fd5b5061025361058a366004612249565b611650565b34801561059b57600080fd5b50600f54600160a01b900460ff166040516102759190612456565b3480156105c257600080fd5b506105cb6117b7565b604051610275919061247e565b3480156105e457600080fd5b5061033d6105f33660046122f7565b611819565b34801561060457600080fd5b5061033d6106133660046122f7565b611829565b34801561062457600080fd5b50610253611859565b34801561063957600080fd5b506106426119f4565b6040516102759190612491565b34801561065b57600080fd5b50610642611a54565b34801561067057600080fd5b5061025361067f3660046122d3565b611ab4565b34801561069057600080fd5b5061025361069f3660046122d3565b611b6c565b3480156106b057600080fd5b50600f5461033d906001600160a01b031681565b3480156106d057600080fd5b5060055461026b565b6000600f54600160a01b900460ff1660018111156106f9576106f9612440565b146107405760405162461bcd60e51b815260206004820152601260248201527120b9ba3937a9b834b72fafa737ba27b832b760711b60448201526064015b60405180910390fd5b60095460009060ff166107545760006107c4565b600254600354604051631711922960e31b81526001600160a01b03918216600482015291169063b88c914890602401602060405180830381865afa1580156107a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107c491906124de565b6001600160801b0316905080600a60008282546107e1919061251d565b90915550503360009081526007602052604090205460ff16156109b557600454600a5410156108525760405162461bcd60e51b815260206004820152601a60248201527f526573657276655f5f496e73756666696369656e7446756e64730000000000006044820152606401610737565b600454600a60008282546108669190612530565b9091555050600454336000908152600e60205260408120805490919061088d90849061251d565b9091555050336000908152600760205260408120805460ff191690555b6008548110156109af57336001600160a01b0316600882815481106108d1576108d1612543565b6000918252602090912001546001600160a01b03160361099d57600880546108fb90600190612530565b8154811061090b5761090b612543565b600091825260209091200154600880546001600160a01b03909216918390811061093757610937612543565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600880548061097657610976612559565b600082815260209020810160001990810180546001600160a01b03191690550190556109af565b806109a78161256f565b9150506108aa565b50610a36565b600454341015610a075760405162461bcd60e51b815260206004820152601760248201527f417374726f5370696e5f5f4e6f74456e6f7567684574680000000000000000006044820152606401610737565b610a118134612530565b336000908152600e602052604081208054909190610a3090849061251d565b90915550505b336000908152600c602052604090205460ff16610aa8576005805460018181019092557f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db00180546001600160a01b031916339081179091556000908152600c60205260409020805460ff191690911790555b336000818152600e60209081526040918290205491519182527f54c1120c1b252c0b6ef35a1b86ebb8365d71cac345475d39526567501e7dc0b9910160405180910390a250565b600254600354604051631711922960e31b81526001600160a01b039182166004820152600092919091169063b88c914890602401602060405180830381865afa158015610b40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b6491906124de565b6001600160801b0316905090565b610b7a611be5565b60005b81811015610cec576000838383818110610b9957610b99612543565b9050602002016020810190610bae91906122d3565b6001600160a01b0381166000908152600760205260408120805460ff191690559091505b600854811015610cd757816001600160a01b031660088281548110610bf957610bf9612543565b6000918252602090912001546001600160a01b031603610cc55760088054610c2390600190612530565b81548110610c3357610c33612543565b600091825260209091200154600880546001600160a01b039092169183908110610c5f57610c5f612543565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506008805480610c9e57610c9e612559565b600082815260209020810160001990810180546001600160a01b0319169055019055610cd7565b80610ccf8161256f565b915050610bd2565b50508080610ce49061256f565b915050610b7d565b505050565b610cf9611be5565b6001600160a01b038116610d415760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606401610737565b6000600a5411610d8a5760405162461bcd60e51b8152602060048201526014602482015273273790333ab73239903a37903a3930b739b332b960611b6044820152606401610737565b600a80546000918290556040519091906001600160a01b0384169083908381818185875af1925050503d8060008114610ddf576040519150601f19603f3d011682016040523d82523d6000602084013e610de4565b606091505b5050905080610cec5760405162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b6044820152606401610737565b610e2f611be5565b600455565b600047600a541115610e465750600090565b6000600a5447610e569190612530565b92915050565b6060806060600060058054905067ffffffffffffffff811115610e8157610e81612588565b604051908082528060200260200182016040528015610eaa578160200160208202803683370190505b5060055490915060009067ffffffffffffffff811115610ecc57610ecc612588565b604051908082528060200260200182016040528015610ef5578160200160208202803683370190505b5060055490915060009067ffffffffffffffff811115610f1757610f17612588565b604051908082528060200260200182016040528015610f40578160200160208202803683370190505b5090506000805b600554811015610fab57600e600060058381548110610f6857610f68612543565b60009182526020808320909101546001600160a01b03168352820192909252604001902054610f97908361251d565b915080610fa38161256f565b915050610f47565b5060005b6005548110156111255760058181548110610fcc57610fcc612543565b9060005260206000200160009054906101000a90046001600160a01b0316858281518110610ffc57610ffc612543565b60200260200101906001600160a01b031690816001600160a01b031681525050600e60006005838154811061103357611033612543565b60009182526020808320909101546001600160a01b03168352820192909252604001902054835184908390811061106c5761106c612543565b602090810291909101015281156110f25781600e60006005848154811061109557611095612543565b60009182526020808320909101546001600160a01b031683528201929092526040019020546110c590606461259e565b6110cf91906125d3565b8482815181106110e1576110e1612543565b602002602001018181525050611113565b600084828151811061110657611106612543565b6020026020010181815250505b8061111d8161256f565b915050610faf565b5092969195509350915050565b60006111466002546001600160a01b031690565b90506001600160a01b03811661119e5760405162461bcd60e51b815260206004820152601760248201527f456e74726f70792061646472657373206e6f74207365740000000000000000006044820152606401610737565b336001600160a01b038216146112025760405162461bcd60e51b815260206004820152602360248201527f4f6e6c7920456e74726f70792063616e2063616c6c20746869732066756e637460448201526234b7b760e91b6064820152608401610737565b61120d848484611c3f565b50505050565b6008818154811061122357600080fd5b6000918252602090912001546001600160a01b0316905081565b611245611be5565b61124f6000612108565b565b611259611be5565b6001600160a01b0381166112b95760405162461bcd60e51b815260206004820152602160248201527f4e65772063616c6c65722063616e6e6f74206265207a65726f206164647265736044820152607360f81b6064820152608401610737565b600f80546001600160a01b0319166001600160a01b0392909216919091179055565b6112e3611be5565b6009805460ff1916911515919091179055565b600f546001600160a01b031633148061131957506000546001600160a01b031633145b61137d5760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c79207468652063616c6c6572206f72206f776e65722063616e2063616c60448201526e36103a3434b990333ab731ba34b7b760891b6064820152608401610737565b600f54600090600160a01b900460ff16600181111561139e5761139e612440565b60055490159150471515906002111560008380156113b95750825b80156113c25750815b90508061141657600554600f54479190600160a01b900460ff1660018111156113ed576113ed612440565b60405162bf9ea560e61b8152600481019390935260248301919091526044820152606401610737565b600f8054600160a01b60ff60a01b19909116179055600254600354604051631711922960e31b81526001600160a01b039182166004820152600092919091169063b88c914890602401602060405180830381865afa15801561147c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114a091906124de565b6002546003546040516319cb825f60e01b81526001600160a01b039182166004820152602481018a90526001600160801b039390931693506000929116906319cb825f90849060440160206040518083038185885af1158015611507573d6000803e3d6000fd5b50505050506040513d601f19601f8201168201806040525081019061152c91906125e7565b60405190915067ffffffffffffffff8216907f5beb2af3b50debed400e3605ba22bb501038c089d951d7fa560cf94db564ddb890600090a260405167ffffffffffffffff821681527f7f45e714f78c137943988efd3188c92c586458180c00f18f5ac76b00bbd256d29060200160405180910390a150505050505050565b6005818154811061122357600080fd5b600034116115fa5760405162461bcd60e51b815260206004820152600d60248201526c09aeae6e840e6cadcc8408aa89609b1b6044820152606401610737565b34600a600082825461160c919061251d565b9091555050600a546040805134815260208101929092527f2da012741527a2d1fe767ad626e563d77376120fcf5e38ce12aa18703f27f755910160405180910390a1565b611658611be5565b60005b81811015610cec57600083838381811061167757611677612543565b905060200201602081019061168c91906122d3565b90506001600160a01b0381166116d65760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606401610737565b6000805b60085481101561173657826001600160a01b03166008828154811061170157611701612543565b6000918252602090912001546001600160a01b0316036117245760019150611736565b8061172e8161256f565b9150506116da565b50806117a2576001600160a01b0382166000818152600760205260408120805460ff191660019081179091556008805491820181559091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30180546001600160a01b03191690911790555b505080806117af9061256f565b91505061165b565b6060600880548060200260200160405190810160405280929190818152602001828054801561180f57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116117f1575b5050505050905090565b600b818154811061122357600080fd5b60006005828154811061183e5761183e612543565b6000918252602090912001546001600160a01b031692915050565b611861611be5565b611869612158565b60055460005b818110156119d05760006005828154811061188c5761188c612543565b60009182526020808320909101546001600160a01b0316808352600e90915260409091205490915080156119bb576001600160a01b03821660009081526007602052604090205460ff16156118f85780600a60008282546118ed919061251d565b9091555061198d9050565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114611945576040519150601f19603f3d011682016040523d82523d6000602084013e61194a565b606091505b505090508061198b5760405162461bcd60e51b815260206004820152600d60248201526c14915195539117d19052531151609a1b6044820152606401610737565b505b6001600160a01b0382166000908152600e60209081526040808320839055600c9091529020805460ff191690555b505080806119c89061256f565b91505061186f565b50600f805460ff60a01b191690556119ea600560006121b1565b5061124f60018055565b6060600580548060200260200160405190810160405280929190818152602001828054801561180f576020028201919060005260206000209081546001600160a01b031681526001909101906020018083116117f1575050505050905090565b6060600b80548060200260200160405190810160405280929190818152602001828054801561180f576020028201919060005260206000209081546001600160a01b031681526001909101906020018083116117f1575050505050905090565b611abc611be5565b6001600160a01b038116611b225760405162461bcd60e51b815260206004820152602760248201527f4e65772074726561737572792063616e6e6f7420626520746865207a65726f206044820152666164647265737360c81b6064820152608401610737565b600680546001600160a01b0319166001600160a01b0383169081179091556040517fc714d22a2f08b695f81e7c707058db484aa5b4d6b4c9fd64beb10fe85832f60890600090a250565b611b74611be5565b6001600160a01b038116611bd95760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610737565b611be281612108565b50565b6000546001600160a01b0316331461124f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610737565b611c4b600b60006121b1565b6000805b600554811015611cb357600e600060058381548110611c7057611c70612543565b60009182526020808320909101546001600160a01b03168352820192909252604001902054611c9f908361251d565b915080611cab8161256f565b915050611c4f565b5060008111611d105760405162461bcd60e51b8152602060048201526024808201527f546f74616c20636f6e747269627574696f6e73206d75737420626520706f73696044820152637469766560e01b6064820152608401610737565b6000611d1c8284612604565b905060008060005b600554811015611dbf57600e600060058381548110611d4557611d45612543565b60009182526020808320909101546001600160a01b03168352820192909252604001902054611d74908461251d565b925082841015611dad5760058181548110611d9157611d91612543565b6000918252602090912001546001600160a01b03169150611dbf565b80611db78161256f565b915050611d24565b506000600a5447611dd09190612530565b9050600080806064611de385605061259e565b611ded91906125d3565b6001600160a01b0386166000908152600e6020526040902054909150811015611e1c5783925060009150611e39565b9150816064611e2c85601461259e565b611e3691906125d3565b91505b6000856001600160a01b03168460405160006040518083038185875af1925050503d8060008114611e86576040519150601f19603f3d011682016040523d82523d6000602084013e611e8b565b606091505b5050905080611ed45760405162461bcd60e51b8152602060048201526015602482015274141c9a5e99481d1c985b9cd9995c8819985a5b1959605a1b6044820152606401610737565b8215611f7f576006546040516000916001600160a01b03169085908381818185875af1925050503d8060008114611f27576040519150601f19603f3d011682016040523d82523d6000602084013e611f2c565b606091505b5050905080611f7d5760405162461bcd60e51b815260206004820152601860248201527f5472656173757279207472616e73666572206661696c656400000000000000006044820152606401610737565b505b600b8054600181019091557f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db90180546001600160a01b0319166001600160a01b0388169081179091556000818152600e6020908152604091829020548251888152918201527f7e57d825a2478cc8123a008d7d1e20c0f6e8cbca89a7bc100c9b05ecb3698deb910160405180910390a260405167ffffffffffffffff8d1681527ffdd45ca0b53cc67af770583f046be250f4ed6e8fa7412fa42ca5565ba08051f59060200160405180910390a160005b6005548110156120b55760006005828154811061206e5761206e612543565b60009182526020808320909101546001600160a01b03168252600e81526040808320839055600c9091529020805460ff1916905550806120ad8161256f565b91505061204f565b50600d80549060006120c68361256f565b9091555050600f805460ff60a01b1916905560408051600081526020810191829052516120f5916005916121cf565b5050426010555050505050505050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6002600154036121aa5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610737565b6002600155565b5080546000825590600052602060002090810190611be29190612234565b828054828255906000526020600020908101928215612224579160200282015b8281111561222457825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906121ef565b50612230929150612234565b5090565b5b808211156122305760008155600101612235565b6000806020838503121561225c57600080fd5b823567ffffffffffffffff8082111561227457600080fd5b818501915085601f83011261228857600080fd5b81358181111561229757600080fd5b8660208260051b85010111156122ac57600080fd5b60209290920196919550909350505050565b6001600160a01b0381168114611be257600080fd5b6000602082840312156122e557600080fd5b81356122f0816122be565b9392505050565b60006020828403121561230957600080fd5b5035919050565b600081518084526020808501945080840160005b838110156123495781516001600160a01b031687529582019590820190600101612324565b509495945050505050565b600081518084526020808501945080840160005b8381101561234957815187529582019590820190600101612368565b6060815260006123976060830186612310565b82810360208401526123a98186612354565b905082810360408401526123bd8185612354565b9695505050505050565b67ffffffffffffffff81168114611be257600080fd5b6000806000606084860312156123f257600080fd5b83356123fd816123c7565b9250602084013561240d816122be565b929592945050506040919091013590565b60006020828403121561243057600080fd5b813580151581146122f057600080fd5b634e487b7160e01b600052602160045260246000fd5b602081016002831061247857634e487b7160e01b600052602160045260246000fd5b91905290565b6020815260006122f06020830184612310565b6020808252825182820181905260009190848201906040850190845b818110156124d25783516001600160a01b0316835292840192918401916001016124ad565b50909695505050505050565b6000602082840312156124f057600080fd5b81516001600160801b03811681146122f057600080fd5b634e487b7160e01b600052601160045260246000fd5b80820180821115610e5657610e56612507565b81810381811115610e5657610e56612507565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b60006001820161258157612581612507565b5060010190565b634e487b7160e01b600052604160045260246000fd5b60008160001904831182151516156125b8576125b8612507565b500290565b634e487b7160e01b600052601260045260246000fd5b6000826125e2576125e26125bd565b500490565b6000602082840312156125f957600080fd5b81516122f0816123c7565b600082612613576126136125bd565b50069056fea264697066735822122080d55f8cacec0a774958935248d18aec3f8a7861d102ee0f6c7356ebd4d4fd0d64736f6c63430008100033000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000007c817d793715baaee120624e6ce499b29aa105ac00000000000000000000000036825bf3fbdf5a29e2d5148bfe7dcf7b5639e32000000000000000000000000052deaa1c84233f7bb8c8a45baede41091c6165060000000000000000000000005df4707980440d7beb2ad83dfa0321889fb27aed

Deployed Bytecode

0x60806040526004361061023f5760003560e01c8063a1e9b5111161012e578063e044e9c3116100ab578063f077b9741161006f578063f077b9741461064f578063f0f4426014610664578063f2fde38b14610684578063fc9c8d39146106a4578063fd6673f5146106c457600080fd5b8063e044e9c3146105b6578063e2a6b148146105d8578063e55ae4e8146105f8578063ee78635514610618578063efa1c4821461062d57600080fd5b8063c1c6d865116100f2578063c1c6d86514610522578063c7da8f8114610537578063d604e29b1461053f578063ddc382d21461056f578063df66a8361461058f57600080fd5b8063a1e9b51114610480578063a771ebc714610493578063ae771f6b146104bd578063b9e7987e146104dd578063c1c244e81461050d57600080fd5b806352a5f1f8116101bc578063715018a611610180578063715018a6146103f757806377ec0f9a1461040c5780637f1fce7814610422578063868e4c61146104425780638da5cb5b1461046257600080fd5b806352a5f1f814610379578063654ebd6214610399578063659c1465146103af5780636de7da78146103cf5780636f9fb98a146103e457600080fd5b80633b35c517116102035780633b35c517146102d35780634244b0da146102e857806342aaa9e4146103085780634626402b1461031d5780634edbf60a1461035557600080fd5b8063046596fa1461024b578063127f0b3f1461025557806325f227751461027e57806335fec07014610293578063391c3fe1146102b357600080fd5b3661024657005b600080fd5b6102536106d9565b005b34801561026157600080fd5b5061026b600d5481565b6040519081526020015b60405180910390f35b34801561028a57600080fd5b5061026b610aef565b34801561029f57600080fd5b506102536102ae366004612249565b610b72565b3480156102bf57600080fd5b506102536102ce3660046122d3565b610cf1565b3480156102df57600080fd5b5060045461026b565b3480156102f457600080fd5b506102536103033660046122f7565b610e27565b34801561031457600080fd5b5061026b610e34565b34801561032957600080fd5b5060065461033d906001600160a01b031681565b6040516001600160a01b039091168152602001610275565b34801561036157600080fd5b5061036a610e5c565b60405161027593929190612384565b34801561038557600080fd5b506102536103943660046123dd565b611132565b3480156103a557600080fd5b5061026b600a5481565b3480156103bb57600080fd5b5061033d6103ca3660046122f7565b611213565b3480156103db57600080fd5b50600d5461026b565b3480156103f057600080fd5b504761026b565b34801561040357600080fd5b5061025361123d565b34801561041857600080fd5b5061026b60045481565b34801561042e57600080fd5b5061025361043d3660046122d3565b611251565b34801561044e57600080fd5b5061025361045d36600461241e565b6112db565b34801561046e57600080fd5b506000546001600160a01b031661033d565b61025361048e3660046122f7565b6112f6565b34801561049f57600080fd5b506009546104ad9060ff1681565b6040519015158152602001610275565b3480156104c957600080fd5b5061033d6104d83660046122f7565b6115aa565b3480156104e957600080fd5b506104ad6104f83660046122d3565b60076020526000908152604090205460ff1681565b34801561051957600080fd5b5060105461026b565b34801561052e57600080fd5b50600a5461026b565b6102536115ba565b34801561054b57600080fd5b506104ad61055a3660046122d3565b600c6020526000908152604090205460ff1681565b34801561057b57600080fd5b5061025361058a366004612249565b611650565b34801561059b57600080fd5b50600f54600160a01b900460ff166040516102759190612456565b3480156105c257600080fd5b506105cb6117b7565b604051610275919061247e565b3480156105e457600080fd5b5061033d6105f33660046122f7565b611819565b34801561060457600080fd5b5061033d6106133660046122f7565b611829565b34801561062457600080fd5b50610253611859565b34801561063957600080fd5b506106426119f4565b6040516102759190612491565b34801561065b57600080fd5b50610642611a54565b34801561067057600080fd5b5061025361067f3660046122d3565b611ab4565b34801561069057600080fd5b5061025361069f3660046122d3565b611b6c565b3480156106b057600080fd5b50600f5461033d906001600160a01b031681565b3480156106d057600080fd5b5060055461026b565b6000600f54600160a01b900460ff1660018111156106f9576106f9612440565b146107405760405162461bcd60e51b815260206004820152601260248201527120b9ba3937a9b834b72fafa737ba27b832b760711b60448201526064015b60405180910390fd5b60095460009060ff166107545760006107c4565b600254600354604051631711922960e31b81526001600160a01b03918216600482015291169063b88c914890602401602060405180830381865afa1580156107a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107c491906124de565b6001600160801b0316905080600a60008282546107e1919061251d565b90915550503360009081526007602052604090205460ff16156109b557600454600a5410156108525760405162461bcd60e51b815260206004820152601a60248201527f526573657276655f5f496e73756666696369656e7446756e64730000000000006044820152606401610737565b600454600a60008282546108669190612530565b9091555050600454336000908152600e60205260408120805490919061088d90849061251d565b9091555050336000908152600760205260408120805460ff191690555b6008548110156109af57336001600160a01b0316600882815481106108d1576108d1612543565b6000918252602090912001546001600160a01b03160361099d57600880546108fb90600190612530565b8154811061090b5761090b612543565b600091825260209091200154600880546001600160a01b03909216918390811061093757610937612543565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600880548061097657610976612559565b600082815260209020810160001990810180546001600160a01b03191690550190556109af565b806109a78161256f565b9150506108aa565b50610a36565b600454341015610a075760405162461bcd60e51b815260206004820152601760248201527f417374726f5370696e5f5f4e6f74456e6f7567684574680000000000000000006044820152606401610737565b610a118134612530565b336000908152600e602052604081208054909190610a3090849061251d565b90915550505b336000908152600c602052604090205460ff16610aa8576005805460018181019092557f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db00180546001600160a01b031916339081179091556000908152600c60205260409020805460ff191690911790555b336000818152600e60209081526040918290205491519182527f54c1120c1b252c0b6ef35a1b86ebb8365d71cac345475d39526567501e7dc0b9910160405180910390a250565b600254600354604051631711922960e31b81526001600160a01b039182166004820152600092919091169063b88c914890602401602060405180830381865afa158015610b40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b6491906124de565b6001600160801b0316905090565b610b7a611be5565b60005b81811015610cec576000838383818110610b9957610b99612543565b9050602002016020810190610bae91906122d3565b6001600160a01b0381166000908152600760205260408120805460ff191690559091505b600854811015610cd757816001600160a01b031660088281548110610bf957610bf9612543565b6000918252602090912001546001600160a01b031603610cc55760088054610c2390600190612530565b81548110610c3357610c33612543565b600091825260209091200154600880546001600160a01b039092169183908110610c5f57610c5f612543565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506008805480610c9e57610c9e612559565b600082815260209020810160001990810180546001600160a01b0319169055019055610cd7565b80610ccf8161256f565b915050610bd2565b50508080610ce49061256f565b915050610b7d565b505050565b610cf9611be5565b6001600160a01b038116610d415760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606401610737565b6000600a5411610d8a5760405162461bcd60e51b8152602060048201526014602482015273273790333ab73239903a37903a3930b739b332b960611b6044820152606401610737565b600a80546000918290556040519091906001600160a01b0384169083908381818185875af1925050503d8060008114610ddf576040519150601f19603f3d011682016040523d82523d6000602084013e610de4565b606091505b5050905080610cec5760405162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b6044820152606401610737565b610e2f611be5565b600455565b600047600a541115610e465750600090565b6000600a5447610e569190612530565b92915050565b6060806060600060058054905067ffffffffffffffff811115610e8157610e81612588565b604051908082528060200260200182016040528015610eaa578160200160208202803683370190505b5060055490915060009067ffffffffffffffff811115610ecc57610ecc612588565b604051908082528060200260200182016040528015610ef5578160200160208202803683370190505b5060055490915060009067ffffffffffffffff811115610f1757610f17612588565b604051908082528060200260200182016040528015610f40578160200160208202803683370190505b5090506000805b600554811015610fab57600e600060058381548110610f6857610f68612543565b60009182526020808320909101546001600160a01b03168352820192909252604001902054610f97908361251d565b915080610fa38161256f565b915050610f47565b5060005b6005548110156111255760058181548110610fcc57610fcc612543565b9060005260206000200160009054906101000a90046001600160a01b0316858281518110610ffc57610ffc612543565b60200260200101906001600160a01b031690816001600160a01b031681525050600e60006005838154811061103357611033612543565b60009182526020808320909101546001600160a01b03168352820192909252604001902054835184908390811061106c5761106c612543565b602090810291909101015281156110f25781600e60006005848154811061109557611095612543565b60009182526020808320909101546001600160a01b031683528201929092526040019020546110c590606461259e565b6110cf91906125d3565b8482815181106110e1576110e1612543565b602002602001018181525050611113565b600084828151811061110657611106612543565b6020026020010181815250505b8061111d8161256f565b915050610faf565b5092969195509350915050565b60006111466002546001600160a01b031690565b90506001600160a01b03811661119e5760405162461bcd60e51b815260206004820152601760248201527f456e74726f70792061646472657373206e6f74207365740000000000000000006044820152606401610737565b336001600160a01b038216146112025760405162461bcd60e51b815260206004820152602360248201527f4f6e6c7920456e74726f70792063616e2063616c6c20746869732066756e637460448201526234b7b760e91b6064820152608401610737565b61120d848484611c3f565b50505050565b6008818154811061122357600080fd5b6000918252602090912001546001600160a01b0316905081565b611245611be5565b61124f6000612108565b565b611259611be5565b6001600160a01b0381166112b95760405162461bcd60e51b815260206004820152602160248201527f4e65772063616c6c65722063616e6e6f74206265207a65726f206164647265736044820152607360f81b6064820152608401610737565b600f80546001600160a01b0319166001600160a01b0392909216919091179055565b6112e3611be5565b6009805460ff1916911515919091179055565b600f546001600160a01b031633148061131957506000546001600160a01b031633145b61137d5760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c79207468652063616c6c6572206f72206f776e65722063616e2063616c60448201526e36103a3434b990333ab731ba34b7b760891b6064820152608401610737565b600f54600090600160a01b900460ff16600181111561139e5761139e612440565b60055490159150471515906002111560008380156113b95750825b80156113c25750815b90508061141657600554600f54479190600160a01b900460ff1660018111156113ed576113ed612440565b60405162bf9ea560e61b8152600481019390935260248301919091526044820152606401610737565b600f8054600160a01b60ff60a01b19909116179055600254600354604051631711922960e31b81526001600160a01b039182166004820152600092919091169063b88c914890602401602060405180830381865afa15801561147c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114a091906124de565b6002546003546040516319cb825f60e01b81526001600160a01b039182166004820152602481018a90526001600160801b039390931693506000929116906319cb825f90849060440160206040518083038185885af1158015611507573d6000803e3d6000fd5b50505050506040513d601f19601f8201168201806040525081019061152c91906125e7565b60405190915067ffffffffffffffff8216907f5beb2af3b50debed400e3605ba22bb501038c089d951d7fa560cf94db564ddb890600090a260405167ffffffffffffffff821681527f7f45e714f78c137943988efd3188c92c586458180c00f18f5ac76b00bbd256d29060200160405180910390a150505050505050565b6005818154811061122357600080fd5b600034116115fa5760405162461bcd60e51b815260206004820152600d60248201526c09aeae6e840e6cadcc8408aa89609b1b6044820152606401610737565b34600a600082825461160c919061251d565b9091555050600a546040805134815260208101929092527f2da012741527a2d1fe767ad626e563d77376120fcf5e38ce12aa18703f27f755910160405180910390a1565b611658611be5565b60005b81811015610cec57600083838381811061167757611677612543565b905060200201602081019061168c91906122d3565b90506001600160a01b0381166116d65760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606401610737565b6000805b60085481101561173657826001600160a01b03166008828154811061170157611701612543565b6000918252602090912001546001600160a01b0316036117245760019150611736565b8061172e8161256f565b9150506116da565b50806117a2576001600160a01b0382166000818152600760205260408120805460ff191660019081179091556008805491820181559091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30180546001600160a01b03191690911790555b505080806117af9061256f565b91505061165b565b6060600880548060200260200160405190810160405280929190818152602001828054801561180f57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116117f1575b5050505050905090565b600b818154811061122357600080fd5b60006005828154811061183e5761183e612543565b6000918252602090912001546001600160a01b031692915050565b611861611be5565b611869612158565b60055460005b818110156119d05760006005828154811061188c5761188c612543565b60009182526020808320909101546001600160a01b0316808352600e90915260409091205490915080156119bb576001600160a01b03821660009081526007602052604090205460ff16156118f85780600a60008282546118ed919061251d565b9091555061198d9050565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114611945576040519150601f19603f3d011682016040523d82523d6000602084013e61194a565b606091505b505090508061198b5760405162461bcd60e51b815260206004820152600d60248201526c14915195539117d19052531151609a1b6044820152606401610737565b505b6001600160a01b0382166000908152600e60209081526040808320839055600c9091529020805460ff191690555b505080806119c89061256f565b91505061186f565b50600f805460ff60a01b191690556119ea600560006121b1565b5061124f60018055565b6060600580548060200260200160405190810160405280929190818152602001828054801561180f576020028201919060005260206000209081546001600160a01b031681526001909101906020018083116117f1575050505050905090565b6060600b80548060200260200160405190810160405280929190818152602001828054801561180f576020028201919060005260206000209081546001600160a01b031681526001909101906020018083116117f1575050505050905090565b611abc611be5565b6001600160a01b038116611b225760405162461bcd60e51b815260206004820152602760248201527f4e65772074726561737572792063616e6e6f7420626520746865207a65726f206044820152666164647265737360c81b6064820152608401610737565b600680546001600160a01b0319166001600160a01b0383169081179091556040517fc714d22a2f08b695f81e7c707058db484aa5b4d6b4c9fd64beb10fe85832f60890600090a250565b611b74611be5565b6001600160a01b038116611bd95760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610737565b611be281612108565b50565b6000546001600160a01b0316331461124f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610737565b611c4b600b60006121b1565b6000805b600554811015611cb357600e600060058381548110611c7057611c70612543565b60009182526020808320909101546001600160a01b03168352820192909252604001902054611c9f908361251d565b915080611cab8161256f565b915050611c4f565b5060008111611d105760405162461bcd60e51b8152602060048201526024808201527f546f74616c20636f6e747269627574696f6e73206d75737420626520706f73696044820152637469766560e01b6064820152608401610737565b6000611d1c8284612604565b905060008060005b600554811015611dbf57600e600060058381548110611d4557611d45612543565b60009182526020808320909101546001600160a01b03168352820192909252604001902054611d74908461251d565b925082841015611dad5760058181548110611d9157611d91612543565b6000918252602090912001546001600160a01b03169150611dbf565b80611db78161256f565b915050611d24565b506000600a5447611dd09190612530565b9050600080806064611de385605061259e565b611ded91906125d3565b6001600160a01b0386166000908152600e6020526040902054909150811015611e1c5783925060009150611e39565b9150816064611e2c85601461259e565b611e3691906125d3565b91505b6000856001600160a01b03168460405160006040518083038185875af1925050503d8060008114611e86576040519150601f19603f3d011682016040523d82523d6000602084013e611e8b565b606091505b5050905080611ed45760405162461bcd60e51b8152602060048201526015602482015274141c9a5e99481d1c985b9cd9995c8819985a5b1959605a1b6044820152606401610737565b8215611f7f576006546040516000916001600160a01b03169085908381818185875af1925050503d8060008114611f27576040519150601f19603f3d011682016040523d82523d6000602084013e611f2c565b606091505b5050905080611f7d5760405162461bcd60e51b815260206004820152601860248201527f5472656173757279207472616e73666572206661696c656400000000000000006044820152606401610737565b505b600b8054600181019091557f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db90180546001600160a01b0319166001600160a01b0388169081179091556000818152600e6020908152604091829020548251888152918201527f7e57d825a2478cc8123a008d7d1e20c0f6e8cbca89a7bc100c9b05ecb3698deb910160405180910390a260405167ffffffffffffffff8d1681527ffdd45ca0b53cc67af770583f046be250f4ed6e8fa7412fa42ca5565ba08051f59060200160405180910390a160005b6005548110156120b55760006005828154811061206e5761206e612543565b60009182526020808320909101546001600160a01b03168252600e81526040808320839055600c9091529020805460ff1916905550806120ad8161256f565b91505061204f565b50600d80549060006120c68361256f565b9091555050600f805460ff60a01b1916905560408051600081526020810191829052516120f5916005916121cf565b5050426010555050505050505050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6002600154036121aa5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610737565b6002600155565b5080546000825590600052602060002090810190611be29190612234565b828054828255906000526020600020908101928215612224579160200282015b8281111561222457825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906121ef565b50612230929150612234565b5090565b5b808211156122305760008155600101612235565b6000806020838503121561225c57600080fd5b823567ffffffffffffffff8082111561227457600080fd5b818501915085601f83011261228857600080fd5b81358181111561229757600080fd5b8660208260051b85010111156122ac57600080fd5b60209290920196919550909350505050565b6001600160a01b0381168114611be257600080fd5b6000602082840312156122e557600080fd5b81356122f0816122be565b9392505050565b60006020828403121561230957600080fd5b5035919050565b600081518084526020808501945080840160005b838110156123495781516001600160a01b031687529582019590820190600101612324565b509495945050505050565b600081518084526020808501945080840160005b8381101561234957815187529582019590820190600101612368565b6060815260006123976060830186612310565b82810360208401526123a98186612354565b905082810360408401526123bd8185612354565b9695505050505050565b67ffffffffffffffff81168114611be257600080fd5b6000806000606084860312156123f257600080fd5b83356123fd816123c7565b9250602084013561240d816122be565b929592945050506040919091013590565b60006020828403121561243057600080fd5b813580151581146122f057600080fd5b634e487b7160e01b600052602160045260246000fd5b602081016002831061247857634e487b7160e01b600052602160045260246000fd5b91905290565b6020815260006122f06020830184612310565b6020808252825182820181905260009190848201906040850190845b818110156124d25783516001600160a01b0316835292840192918401916001016124ad565b50909695505050505050565b6000602082840312156124f057600080fd5b81516001600160801b03811681146122f057600080fd5b634e487b7160e01b600052601160045260246000fd5b80820180821115610e5657610e56612507565b81810381811115610e5657610e56612507565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b60006001820161258157612581612507565b5060010190565b634e487b7160e01b600052604160045260246000fd5b60008160001904831182151516156125b8576125b8612507565b500290565b634e487b7160e01b600052601260045260246000fd5b6000826125e2576125e26125bd565b500490565b6000602082840312156125f957600080fd5b81516122f0816123c7565b600082612613576126136125bd565b50069056fea264697066735822122080d55f8cacec0a774958935248d18aec3f8a7861d102ee0f6c7356ebd4d4fd0d64736f6c63430008100033

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

000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000007c817d793715baaee120624e6ce499b29aa105ac00000000000000000000000036825bf3fbdf5a29e2d5148bfe7dcf7b5639e32000000000000000000000000052deaa1c84233f7bb8c8a45baede41091c6165060000000000000000000000005df4707980440d7beb2ad83dfa0321889fb27aed

-----Decoded View---------------
Arg [0] : minEntranceFee (uint256): 10000000000000000
Arg [1] : _treasuryWallet (address): 0x7c817d793715baAEe120624E6cE499B29aa105ac
Arg [2] : _entropy (address): 0x36825bf3Fbdf5a29E2d5148bfe7Dcf7B5639e320
Arg [3] : _entropyProvider (address): 0x52DeaA1c84233F7bb8C8A45baeDE41091c616506
Arg [4] : _caller (address): 0x5DF4707980440D7BEB2AD83dfA0321889FB27AeD

-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 000000000000000000000000000000000000000000000000002386f26fc10000
Arg [1] : 0000000000000000000000007c817d793715baaee120624e6ce499b29aa105ac
Arg [2] : 00000000000000000000000036825bf3fbdf5a29e2d5148bfe7dcf7b5639e320
Arg [3] : 00000000000000000000000052deaa1c84233f7bb8c8a45baede41091c616506
Arg [4] : 0000000000000000000000005df4707980440d7beb2ad83dfa0321889fb27aed


Block Transaction Gas Used Reward
view all blocks produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.