Overview
AVAX Balance
AVAX Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 11,746 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Play Game | 60769218 | 5 hrs ago | IN | 2.1735 AVAX | 0.00059083 | ||||
Play Game | 60769174 | 5 hrs ago | IN | 2.1735 AVAX | 0.00059807 | ||||
Play Game | 60768117 | 5 hrs ago | IN | 1.05 AVAX | 0.00059131 | ||||
Play Game | 60768096 | 5 hrs ago | IN | 0.42 AVAX | 0.00059517 | ||||
Play Game | 60768082 | 5 hrs ago | IN | 0.42 AVAX | 0.00059573 | ||||
Play Game | 60768062 | 5 hrs ago | IN | 0.42 AVAX | 0.00059125 | ||||
Play Game | 60767970 | 5 hrs ago | IN | 1.05 AVAX | 0.00059346 | ||||
Play Game | 60762536 | 7 hrs ago | IN | 3.15 AVAX | 0.00059767 | ||||
Play Game | 60762510 | 7 hrs ago | IN | 1.89 AVAX | 0.00059858 | ||||
Play Game | 60761219 | 8 hrs ago | IN | 0.0525 AVAX | 0.00036839 | ||||
Play Game | 60749369 | 12 hrs ago | IN | 0.63 AVAX | 0.00058913 | ||||
Play Game | 60748693 | 12 hrs ago | IN | 1.05 AVAX | 0.00060137 | ||||
Play Game | 60748600 | 12 hrs ago | IN | 0.63 AVAX | 0.00060362 | ||||
Play Game | 60748576 | 12 hrs ago | IN | 0.315 AVAX | 0.00059833 | ||||
Play Game | 60748550 | 12 hrs ago | IN | 1.05 AVAX | 0.00060339 | ||||
Play Game | 60748527 | 12 hrs ago | IN | 0.525 AVAX | 0.00059876 | ||||
Play Game | 60748381 | 12 hrs ago | IN | 2.1 AVAX | 0.00059989 | ||||
Play Game | 60748192 | 12 hrs ago | IN | 0.5775 AVAX | 0.00058963 | ||||
Play Game | 60748163 | 12 hrs ago | IN | 0.5775 AVAX | 0.00059054 | ||||
Play Game | 60748101 | 12 hrs ago | IN | 2.31 AVAX | 0.00059097 | ||||
Play Game | 60747987 | 12 hrs ago | IN | 2.6775 AVAX | 0.00058781 | ||||
Play Game | 60747966 | 12 hrs ago | IN | 0.5775 AVAX | 0.00059019 | ||||
Play Game | 60746359 | 13 hrs ago | IN | 1.05 AVAX | 0.0005914 | ||||
Play Game | 60746338 | 13 hrs ago | IN | 1.155 AVAX | 0.00059039 | ||||
Play Game | 60746319 | 13 hrs ago | IN | 0.63 AVAX | 0.00059081 |
Latest 25 internal transactions (View All)
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
60769218 | 5 hrs ago | 0.1035 AVAX | ||||
60769218 | 5 hrs ago | 2.07 AVAX | ||||
60769174 | 5 hrs ago | 0.1035 AVAX | ||||
60769174 | 5 hrs ago | 2.07 AVAX | ||||
60768117 | 5 hrs ago | 0.05 AVAX | ||||
60768117 | 5 hrs ago | 1 AVAX | ||||
60768096 | 5 hrs ago | 0.02 AVAX | ||||
60768096 | 5 hrs ago | 0.4 AVAX | ||||
60768082 | 5 hrs ago | 0.02 AVAX | ||||
60768082 | 5 hrs ago | 0.4 AVAX | ||||
60768062 | 5 hrs ago | 0.02 AVAX | ||||
60768062 | 5 hrs ago | 0.4 AVAX | ||||
60767970 | 5 hrs ago | 0.05 AVAX | ||||
60767970 | 5 hrs ago | 1 AVAX | ||||
60762536 | 7 hrs ago | 0.15 AVAX | ||||
60762536 | 7 hrs ago | 3 AVAX | ||||
60762510 | 7 hrs ago | 0.09 AVAX | ||||
60762510 | 7 hrs ago | 1.8 AVAX | ||||
60761219 | 8 hrs ago | 0.0025 AVAX | ||||
60761219 | 8 hrs ago | 0.05 AVAX | ||||
60749369 | 12 hrs ago | 0.03 AVAX | ||||
60749369 | 12 hrs ago | 0.6 AVAX | ||||
60748693 | 12 hrs ago | 0.05 AVAX | ||||
60748693 | 12 hrs ago | 1 AVAX | ||||
60748600 | 12 hrs ago | 0.03 AVAX |
Loading...
Loading
Contract Name:
Plinko
Compiler Version
v0.8.22+commit.4fc1097e
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.22; import "@openzeppelin/contracts/access/Ownable.sol"; import "../CentralGameBase.sol"; import "../GameBet.sol"; import "../GameVRF.sol"; import "../IRakeDistributor.sol"; import "../ITreasury.sol"; /// Plinko contract using a global treasury and multiple balls. contract Plinko is CentralGameBase, GameBet, GameVRF { /// Standardized game complete info. struct RoundInfo { RoundState state; uint256 sent; uint8 selected; } /// Emitted when game is started. event GameStarted( address indexed creator, uint256 indexed gameId, uint8 subgame, uint256 numRounds, uint8 bucketCount, address referrer, uint256 betPerRound, uint256 rakePerRound, FulfillmentMethod method ); /// Emitted when game is fully completed with no other actions available. event WinnerPicked(uint256 indexed gameId, RoundInfo[] results); /// Number of buckets to the multipliers for the buckets mapping(uint8 => uint256[]) public bucketMultipliers; /// Number of buckets to the cumulative probabilities for the buckets mapping(uint8 => uint256[]) public bucketProbabilities; /// Per-game bucket counts, by gameId. mapping(uint256 => uint8) public bucketCountByGameId; /// Amount to divide the multipliers by to get to the percent uint256 private divisor = 1000000; /// Contract can be funded. receive() external payable {} /// Constructor populates generic Chainlink values. /// Also sets static multipliers for winning. constructor() GameVRF() { // Need to be higher to ensure we cover chainlink fees. minBet = 1 ether; // More than the standard number of bets, here. maxConsecutiveRounds = 100; bucketMultipliers[7] = [1000, 100, 70, 40, 70, 100, 1000]; bucketProbabilities[7] = [14314, 173137, 347463, 652537, 826863, 985686, 1000000]; bucketMultipliers[8] = [1500, 250, 70, 40, 40, 70, 250, 1500]; bucketProbabilities[8] = [7445, 69485, 226035, 499998, 773965, 930515, 992555, 1000000]; bucketMultipliers[9] = [2050, 400, 90, 60, 40, 60, 90, 400, 2050]; bucketProbabilities[9] = [4713, 28893, 158853, 353793, 646207, 841147, 971107, 995287, 1000000]; bucketMultipliers[10] = [4500, 800, 90, 60, 40, 40, 60, 90, 800, 4500]; bucketProbabilities[10] = [1881, 17763, 119286, 271570, 499997, 728430, 880714, 982237, 998119, 1000000]; bucketMultipliers[11] = [4700, 800, 200, 90, 60, 40, 60, 90, 200, 800, 4700]; bucketProbabilities[11] = [1860, 7369, 44006, 165699, 355288, 644712, 834301, 955994, 992631, 998140, 1000000]; bucketMultipliers[12] = [6500, 1700, 400, 90, 60, 40, 40, 60, 90, 400, 1700, 6500]; bucketProbabilities[12] = [1187, 5034, 23069, 123475, 274084, 499997, 725916, 876525, 976931, 994966, 998813, 1000000]; bucketMultipliers[13] = [7000, 1600, 300, 200, 90, 60, 40, 60, 90, 200, 300, 1600, 7000]; bucketProbabilities[13] = [823, 4080, 21943, 42131, 162027, 356551, 643449, 837973, 957869, 978057, 995920, 999177, 1000000]; } /// Create a new game. /// User can specify the number of rounds, and the configuration (size of board). function playGame( uint8 roundCount, uint8 bucketCount, string memory referralCode, FulfillmentMethod method ) external payable isEOA isNotPaused isEnoughTreasury { _createGame(roundCount, bucketCount, referralCode, method); } function _createGame( uint256 roundCount, uint8 bucketCount, string memory referralCode, FulfillmentMethod method ) internal returns (uint256) { IRakeDistributor rakeDistributor = IRakeDistributor(rakeDistributorAddress); BetDetails memory details = validateBet( treasuryAddress.balance, rakeDistributor.getTotalRake(), roundCount); require(roundCount <= 100, "No more than 100 balls, king"); require(bucketMultipliers[bucketCount].length > 0, "Use an expected configuration, pleb"); require(bucketProbabilities[bucketCount].length > 0, "Use an expected configuration, pleb"); uint256 maxPayout = details.betPerRound * bucketMultipliers[bucketCount][0] / 100; require(maxPayout <= (treasuryAddress.balance / maxBetDivisor), "Gamble less, king"); currentGameId++; GameInfo memory gi; gi.numRounds = roundCount; gi.creator = msg.sender; gi.subgame = 5; gi.referrer = rakeDistributor.getReferrerFromGamerAndCode(msg.sender, referralCode); gi.gameId = currentGameId; gi.state = GameState.CALCULATING; gi.betPerRound = details.betPerRound; gi.rakePerRound = details.rakePerRound; { (bool success,) = payable(treasuryAddress).call{value: details.bet}(""); require(success); } gameById[gi.gameId] = gi; bucketCountByGameId[gi.gameId] = bucketCount; emit GameStarted( msg.sender, gi.gameId, gi.subgame, roundCount, bucketCount, gi.referrer, gi.betPerRound, gi.rakePerRound, method ); rakeDistributor.distributeReferredRake{value: details.rake}(gi.gameId, msg.sender, gi.referrer); _requestGameFulfillment(gi.gameId, method); return gi.gameId; } /// Receives the random number from VRF and calculates win/loss/tie. /// Transfers the appropriate amount of funds from treasury to the user on wins. function fulfillRandomWords(uint256 requestId, uint256[] memory randomWords) internal override { uint256 gameId = gameIdByRequestId[requestId]; require(gameId != 0, "Request already fulfilled"); GameInfo storage gi = gameById[gameId]; require(gi.state == GameState.CALCULATING, "Game not waiting for results"); uint256 roundCount = gi.numRounds; uint8 bucketCount = bucketCountByGameId[gameId]; RoundInfo[] memory results = new RoundInfo[](roundCount); uint256 amountToUser; uint256[] memory multipliers = bucketMultipliers[bucketCount]; uint256[] memory probabilities = bucketProbabilities[bucketCount]; for (uint256 i; i < roundCount; ++i) { uint256 roundRandom = uint256(keccak256(abi.encode(randomWords[0], i))); uint256 roundValue = roundRandom % divisor; for (uint256 j; j < bucketCount; ++j) { if (roundValue < probabilities[j]) { results[i].selected = uint8(j); uint256 amountForRound = gi.betPerRound * multipliers[j] / 100; results[i].sent = amountForRound; amountToUser += amountForRound; break; } } } emit WinnerPicked(gameId, results); address creator = gi.creator; delete gameById[gameId]; delete gameIdByRequestId[requestId]; if (amountToUser > 0) { ITreasury(treasuryAddress).sendPayout(creator, amountToUser); } } /// Triggers VRF process for a given game in case of emergency. function forceRequestWinner(uint256 gameId, FulfillmentMethod method) external onlyOwner { GameInfo storage gi = gameById[gameId]; require(gi.state != GameState.CLOSED, "already closed"); _requestGameFulfillment(gi.gameId, method); } /// Compute the max bet, for use by the UI. Slightly trims the actual max amount. function getMaxBetPerRound(uint8 bucketCount) external view returns (uint256 safeMaxPotentialBet) { uint256 maxPotentialWin = treasuryAddress.balance / maxBetDivisor; uint256 maxPotentialBet = maxPotentialWin * 100 / bucketMultipliers[bucketCount][0]; safeMaxPotentialBet = maxPotentialBet * 100 / 95; } }
// 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); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.22; import "@openzeppelin/contracts/access/Ownable2Step.sol"; import "./Rescue.sol"; import "./ITreasury.sol"; /// Centralized handling of a lot of stuff our games need. All games inherit from this. abstract contract CentralGameBase is Ownable2Step, Rescue { /// Status of an individual betting round in a game. /// Not all states apply to all games (e.g. TIE). enum RoundState { UNKNOWN, // Should never be used. LOST, TIE, WON } /// The status of the game, consisting of a set of rounds. enum GameState { /// Waiting for RNG. CALCULATING, /// Game is finalized and no actions can be taken. CLOSED, /// For PvP games, waiting for 1 or more other players. WAITING_FOR_PLAYER, /// For PvP games, the game creator canceled play. CANCELED } /// Every game played has a GameInfo created for it. /// The details for the individual game are stored separately per game. struct GameInfo { uint256 gameId; uint256 betPerRound; uint256 rakePerRound; uint256 numRounds; address creator; address referrer; uint8 subgame; GameState state; } /// Incrementing counter for the current gameId. uint256 public currentGameId; /// Standardized GameInfo structs mapped by gameId. mapping(uint256 => GameInfo) public gameById; /// Global switch to disallow play. bool public paused; /// Address of the rake distributor. address public rakeDistributorAddress; /// Address of the referral tracker address public referralTrackerAddress; /// Address of the treasury. address public treasuryAddress; /// Prevent contracts from playing with this modifier. modifier isEOA() { require(tx.origin == msg.sender, "No contracts allowed"); _; } /// Prevent play when the game is paused. modifier isNotPaused() { require(!paused, "Game is paused"); _; } modifier isEnoughTreasury() { require(!ITreasury(treasuryAddress).isTreasuryTooLow(), "Treasury is too low!"); _; } /// Fetch details about an individual game. function getGameInfo(uint256 gameId) public view returns (GameInfo memory) { return gameById[gameId]; } /// Fetch details about many games simultaneously. /// This is just a helper function for offline use. function getManyGameInfo(uint256[] memory gameIds) public view returns (GameInfo[] memory) { uint256 gameIdLength = gameIds.length; GameInfo[] memory ret = new GameInfo[](gameIdLength); for (uint256 i; i < gameIdLength; ++i) { ret[i] = gameById[gameIds[i]]; } return ret; } function setPaused(bool paused_) public onlyOwner { paused = paused_; } function setRakeDistributorAddress(address rakeAddress) external onlyOwner { rakeDistributorAddress = rakeAddress; } function setTreasuryAddress(address _treasuryAddress) external onlyOwner { treasuryAddress = _treasuryAddress; } function setReferralTrackerAddress(address _referralTrackerAddress) external onlyOwner { referralTrackerAddress = _referralTrackerAddress; } function setCurrentGameId(uint256 gameId_) external onlyOwner { currentGameId = gameId_; } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.22; import "@openzeppelin/contracts/access/Ownable2Step.sol"; abstract contract GameBet is Ownable2Step { /// Minimum allowed bet. uint256 public minBet = .5 ether; /// Maximum single bet amount is treasury divided by this. uint256 public maxBetDivisor = 20; /// Maxmimum number of rounds that can be played in a single game. // /// The total amount bet is the limiting factor, so this is just a reasonable-ness limit /// on the number of rounds allowed. uint256 public maxConsecutiveRounds = 10; /// Bet amounts per round must be a multiple of this uint256 public betMultiplePerRound = .01 ether; struct BetDetails { uint256 bet; uint256 rake; uint256 betPerRound; uint256 rakePerRound; uint256 payoutPerRound; } function validateBet(uint256 treasuryBalance, uint256 totalRake, uint256 numRounds) internal returns (BetDetails memory) { // TODO: this is retarded, pass the bet in instead? uint256 bet = (msg.value * 10000 / (totalRake + 10000)); uint256 rake = msg.value - bet; require(bet >= minBet, "Gamble more, pleb"); // TODO: This should probably apply to the potentialWin instead of the bet amount // Currently this assumes 2x win values? require(bet <= (treasuryBalance / maxBetDivisor), "Gamble less, king"); require(numRounds > 0, "Gamble at least once, pleb"); require(numRounds <= maxConsecutiveRounds, "Gamble fewer times, king"); uint256 betPerRound = bet / numRounds; require(bet % numRounds == 0, "Gamble an amount divisible by your bets, pleb"); require(betPerRound % betMultiplePerRound == 0, "Gamble the right amount per bet, pleb"); uint256 rakePerRound = rake / numRounds; require(rake % numRounds == 0, "Internal error; wrong rake amount"); return BetDetails({ bet: bet, rake: rake, betPerRound: betPerRound, rakePerRound: rakePerRound, payoutPerRound: 0 // Not supported }); } function validateBetWithPayout(uint256 treasuryBalance, uint256 totalRake, uint256 numRounds, uint256 betNumerator, uint256 betDenominator) internal returns (BetDetails memory) { uint256 bet = (msg.value * 10000 / (totalRake + 10000)); uint256 maxPayoutValue = bet * betNumerator / betDenominator; return validateBetWithMaxPayoutValue(treasuryBalance, totalRake, numRounds, maxPayoutValue); } function validateBetWithMaxPayoutValue(uint256 treasuryBalance, uint256 totalRake, uint256 numRounds, uint256 maxPayoutValue) internal returns (BetDetails memory) { require(numRounds > 0, "Gamble at least one round, pleb"); uint256 bet = (msg.value * 10000 / (totalRake + 10000)); uint256 rake = msg.value - bet; require(bet >= minBet, "Gamble more, pleb"); require(numRounds > 0, "Gamble at least once, pleb"); require(numRounds <= maxConsecutiveRounds, "Gamble fewer times, king"); uint256 betPerRound = bet / numRounds; require(bet % numRounds == 0, "Gamble an amount divisible by your bets, pleb"); require(betPerRound % betMultiplePerRound == 0, "Gamble the right amount per bet, pleb"); uint256 rakePerRound = rake / numRounds; require(rake % numRounds == 0, "Internal error; wrong rake amount"); uint256 maxPayoutPerRound = maxPayoutValue / numRounds; require(betPerRound < maxPayoutPerRound, "Place a gamble that won't guarantee you lose, pleb"); require(maxPayoutPerRound - betPerRound <= (treasuryBalance / maxBetDivisor), "Gamble less, king"); return BetDetails({ bet: bet, rake: rake, betPerRound: betPerRound, rakePerRound: rakePerRound, payoutPerRound: maxPayoutPerRound }); } function setMinBet(uint256 minBet_) external onlyOwner { minBet = minBet_; } function setMaxBetDivisor(uint256 maxBetDivisor_) external onlyOwner { maxBetDivisor = maxBetDivisor_; } function setMaxConsecutiveRounds(uint256 maxConsecutiveRounds_) external onlyOwner { maxConsecutiveRounds = maxConsecutiveRounds_; } function setBetMultiplePerRound(uint256 betMultiplePerRound_) external onlyOwner { betMultiplePerRound = betMultiplePerRound_; } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.22; import "@chainlink/contracts/src/v0.8/interfaces/VRFCoordinatorV2Interface.sol"; import "@chainlink/contracts/src/v0.8/VRFConsumerBaseV2.sol"; import "./FerdyMultiVRFConsumerBase.sol"; /// We have 3 different potential mechanisms for requesting randomness. /// Avax: Chainlink / FerdyRNG /// Base: FerdyRNG /// FerdyNet: On-chain via difficulty parameter // // These utilities abstracts that fact from each game. // The FerdyRNG and on-chain providers both copy the ChainLink coordinator mechanism. abstract contract GameVRF is FerdyMultiVRFConsumerBase { enum FulfillmentMethod { CHAINLINK, // 0 FERDY, // 1 ONCHAIN // 2 - no longer used, was for ferdynet } struct CoordinatorInfo { bytes32 gasLane; address coordAddress; uint64 subscriptionId; uint32 callbackGasLimit; } mapping(FulfillmentMethod => CoordinatorInfo) private coordinatorInfoByMethod; /// Minimum on AVAX is 2; might need changing for other chains. uint16 private _requestConfirmations = 2; /// We always request one word, and just permute it in the fulfillment as required. uint32 private constant NUM_WORDS = 1; /// Game IDs mapped by VRF request ID. /// Keeps track of which request was for which game, so they can be fulfilled mapping(uint256 => uint256) public gameIdByRequestId; /// Emitted when a VRF request has been sent for a game. event RequestedGameWinner(uint256 indexed requestId, address indexed vrfCoordinator, uint256 indexed gameId); constructor() {} function setVRFCoordinatorInfoByMethod(FulfillmentMethod method, bytes32 gasLane, address coordAddress, uint64 subscriptionId, uint32 callbackGasLimit) external onlyOwner { coordinatorInfoByMethod[method] = CoordinatorInfo(gasLane, coordAddress, subscriptionId, callbackGasLimit); setVRFCoordinator(coordAddress, true); } /// Requests VRF for a game and tracks the mapping from request to game. function _requestGameFulfillment(uint256 gameId, FulfillmentMethod method) internal { address coordinatorAddress = coordinatorInfoByMethod[method].coordAddress; require(coordinatorAddress != address(0), "Invalid VRF address"); VRFCoordinatorV2Interface vrfCoordinator = VRFCoordinatorV2Interface(coordinatorAddress); uint256 requestId = vrfCoordinator.requestRandomWords( coordinatorInfoByMethod[method].gasLane, coordinatorInfoByMethod[method].subscriptionId, _requestConfirmations, coordinatorInfoByMethod[method].callbackGasLimit, NUM_WORDS ); gameIdByRequestId[requestId] = gameId; } function getRequestConfirmations() public view returns (uint16) { return _requestConfirmations; } function setRequestConfirmations(uint16 requestConfirmations) public onlyOwner { _requestConfirmations = requestConfirmations; } function getNumWords() public pure returns (uint256) { return NUM_WORDS; } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.22; interface IRakeDistributor { function getTotalRake() external view returns (uint256); function distributeReferredRake(uint256 gameId, address player, address referrer) external payable; function getReferrerFromGamerAndCode(address gamer, string memory referralCode) external view returns (address); function setOperator(address operator, bool isValid) external; }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.22; interface ITreasury { function sendPayout(address gamer, uint256 amount) external; function setGame(address game, bool isValid) external; function isTreasuryTooLow() external returns (bool); }
// 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; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol) pragma solidity ^0.8.0; import "./Ownable.sol"; /** * @dev Contract module which provides 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} and {acceptOwnership}. * * This module is used through inheritance. It will make available all functions * from parent (Ownable). */ abstract contract Ownable2Step is Ownable { address private _pendingOwner; event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner); /** * @dev Returns the address of the pending owner. */ function pendingOwner() public view virtual returns (address) { return _pendingOwner; } /** * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual override onlyOwner { _pendingOwner = newOwner; emit OwnershipTransferStarted(owner(), newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner. * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual override { delete _pendingOwner; super._transferOwnership(newOwner); } /** * @dev The new owner accepts the ownership transfer. */ function acceptOwnership() public virtual { address sender = _msgSender(); require(pendingOwner() == sender, "Ownable2Step: caller is not the new owner"); _transferOwnership(sender); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.20; import "@openzeppelin/contracts/access/Ownable2Step.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; abstract contract Rescue is Ownable2Step { /// Withdraws native funds to contract owner in case of emergency. function rescueNative(uint256 amount) external onlyOwner { (bool success,) = payable(msg.sender).call{value: amount}(""); require(success); } /// Withdraws ERC20 to contract owner in case of emergency. function rescueERC20(address tokenAddress) public onlyOwner { IERC20 token = IERC20(tokenAddress); token.transfer(msg.sender, token.balanceOf(address(this))); } /// Withdraws ERC721 to contract owner in case of emergency. function rescueERC721(address tokenAddress, uint256 tokenId) public onlyOwner { IERC721 token = IERC721(tokenAddress); token.transferFrom(address(this), msg.sender, tokenId); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface VRFCoordinatorV2Interface { /** * @notice Get configuration relevant for making requests * @return minimumRequestConfirmations global min for request confirmations * @return maxGasLimit global max for request gas limit * @return s_provingKeyHashes list of registered key hashes */ function getRequestConfig() external view returns ( uint16, uint32, bytes32[] memory ); /** * @notice Request a set of random words. * @param keyHash - Corresponds to a particular oracle job which uses * that key for generating the VRF proof. Different keyHash's have different gas price * ceilings, so you can select a specific one to bound your maximum per request cost. * @param subId - The ID of the VRF subscription. Must be funded * with the minimum subscription balance required for the selected keyHash. * @param minimumRequestConfirmations - How many blocks you'd like the * oracle to wait before responding to the request. See SECURITY CONSIDERATIONS * for why you may want to request more. The acceptable range is * [minimumRequestBlockConfirmations, 200]. * @param callbackGasLimit - How much gas you'd like to receive in your * fulfillRandomWords callback. Note that gasleft() inside fulfillRandomWords * may be slightly less than this amount because of gas used calling the function * (argument decoding etc.), so you may need to request slightly more than you expect * to have inside fulfillRandomWords. The acceptable range is * [0, maxGasLimit] * @param numWords - The number of uint256 random values you'd like to receive * in your fulfillRandomWords callback. Note these numbers are expanded in a * secure way by the VRFCoordinator from a single random value supplied by the oracle. * @return requestId - A unique identifier of the request. Can be used to match * a request to a response in fulfillRandomWords. */ function requestRandomWords( bytes32 keyHash, uint64 subId, uint16 minimumRequestConfirmations, uint32 callbackGasLimit, uint32 numWords ) external returns (uint256 requestId); /** * @notice Create a VRF subscription. * @return subId - A unique subscription id. * @dev You can manage the consumer set dynamically with addConsumer/removeConsumer. * @dev Note to fund the subscription, use transferAndCall. For example * @dev LINKTOKEN.transferAndCall( * @dev address(COORDINATOR), * @dev amount, * @dev abi.encode(subId)); */ function createSubscription() external returns (uint64 subId); /** * @notice Get a VRF subscription. * @param subId - ID of the subscription * @return balance - LINK balance of the subscription in juels. * @return reqCount - number of requests for this subscription, determines fee tier. * @return owner - owner of the subscription. * @return consumers - list of consumer address which are able to use this subscription. */ function getSubscription(uint64 subId) external view returns ( uint96 balance, uint64 reqCount, address owner, address[] memory consumers ); /** * @notice Request subscription owner transfer. * @param subId - ID of the subscription * @param newOwner - proposed new owner of the subscription */ function requestSubscriptionOwnerTransfer(uint64 subId, address newOwner) external; /** * @notice Request subscription owner transfer. * @param subId - ID of the subscription * @dev will revert if original owner of subId has * not requested that msg.sender become the new owner. */ function acceptSubscriptionOwnerTransfer(uint64 subId) external; /** * @notice Add a consumer to a VRF subscription. * @param subId - ID of the subscription * @param consumer - New consumer which can use the subscription */ function addConsumer(uint64 subId, address consumer) external; /** * @notice Remove a consumer from a VRF subscription. * @param subId - ID of the subscription * @param consumer - Consumer to remove from the subscription */ function removeConsumer(uint64 subId, address consumer) external; /** * @notice Cancel a subscription * @param subId - ID of the subscription * @param to - Where to send the remaining LINK to */ function cancelSubscription(uint64 subId, address to) external; /* * @notice Check to see if there exists a request commitment consumers * for all consumers and keyhashes for a given sub. * @param subId - ID of the subscription * @return true if there exists at least one unfulfilled request for the subscription, false * otherwise. */ function pendingRequestExists(uint64 subId) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; /** **************************************************************************** * @notice Interface for contracts using VRF randomness * ***************************************************************************** * @dev PURPOSE * * @dev Reggie the Random Oracle (not his real job) wants to provide randomness * @dev to Vera the verifier in such a way that Vera can be sure he's not * @dev making his output up to suit himself. Reggie provides Vera a public key * @dev to which he knows the secret key. Each time Vera provides a seed to * @dev Reggie, he gives back a value which is computed completely * @dev deterministically from the seed and the secret key. * * @dev Reggie provides a proof by which Vera can verify that the output was * @dev correctly computed once Reggie tells it to her, but without that proof, * @dev the output is indistinguishable to her from a uniform random sample * @dev from the output space. * * @dev The purpose of this contract is to make it easy for unrelated contracts * @dev to talk to Vera the verifier about the work Reggie is doing, to provide * @dev simple access to a verifiable source of randomness. It ensures 2 things: * @dev 1. The fulfillment came from the VRFCoordinator * @dev 2. The consumer contract implements fulfillRandomWords. * ***************************************************************************** * @dev USAGE * * @dev Calling contracts must inherit from VRFConsumerBase, and can * @dev initialize VRFConsumerBase's attributes in their constructor as * @dev shown: * * @dev contract VRFConsumer { * @dev constructor(<other arguments>, address _vrfCoordinator, address _link) * @dev VRFConsumerBase(_vrfCoordinator) public { * @dev <initialization with other arguments goes here> * @dev } * @dev } * * @dev The oracle will have given you an ID for the VRF keypair they have * @dev committed to (let's call it keyHash). Create subscription, fund it * @dev and your consumer contract as a consumer of it (see VRFCoordinatorInterface * @dev subscription management functions). * @dev Call requestRandomWords(keyHash, subId, minimumRequestConfirmations, * @dev callbackGasLimit, numWords), * @dev see (VRFCoordinatorInterface for a description of the arguments). * * @dev Once the VRFCoordinator has received and validated the oracle's response * @dev to your request, it will call your contract's fulfillRandomWords method. * * @dev The randomness argument to fulfillRandomWords is a set of random words * @dev generated from your requestId and the blockHash of the request. * * @dev If your contract could have concurrent requests open, you can use the * @dev requestId returned from requestRandomWords to track which response is associated * @dev with which randomness request. * @dev See "SECURITY CONSIDERATIONS" for principles to keep in mind, * @dev if your contract could have multiple requests in flight simultaneously. * * @dev Colliding `requestId`s are cryptographically impossible as long as seeds * @dev differ. * * ***************************************************************************** * @dev SECURITY CONSIDERATIONS * * @dev A method with the ability to call your fulfillRandomness method directly * @dev could spoof a VRF response with any random value, so it's critical that * @dev it cannot be directly called by anything other than this base contract * @dev (specifically, by the VRFConsumerBase.rawFulfillRandomness method). * * @dev For your users to trust that your contract's random behavior is free * @dev from malicious interference, it's best if you can write it so that all * @dev behaviors implied by a VRF response are executed *during* your * @dev fulfillRandomness method. If your contract must store the response (or * @dev anything derived from it) and use it later, you must ensure that any * @dev user-significant behavior which depends on that stored value cannot be * @dev manipulated by a subsequent VRF request. * * @dev Similarly, both miners and the VRF oracle itself have some influence * @dev over the order in which VRF responses appear on the blockchain, so if * @dev your contract could have multiple VRF requests in flight simultaneously, * @dev you must ensure that the order in which the VRF responses arrive cannot * @dev be used to manipulate your contract's user-significant behavior. * * @dev Since the block hash of the block which contains the requestRandomness * @dev call is mixed into the input to the VRF *last*, a sufficiently powerful * @dev miner could, in principle, fork the blockchain to evict the block * @dev containing the request, forcing the request to be included in a * @dev different block with a different hash, and therefore a different input * @dev to the VRF. However, such an attack would incur a substantial economic * @dev cost. This cost scales with the number of blocks the VRF oracle waits * @dev until it calls responds to a request. It is for this reason that * @dev that you can signal to an oracle you'd like them to wait longer before * @dev responding to the request (however this is not enforced in the contract * @dev and so remains effective only in the case of unmodified oracle software). */ abstract contract VRFConsumerBaseV2 { error OnlyCoordinatorCanFulfill(address have, address want); address private immutable vrfCoordinator; /** * @param _vrfCoordinator address of VRFCoordinator contract */ constructor(address _vrfCoordinator) { vrfCoordinator = _vrfCoordinator; } /** * @notice fulfillRandomness handles the VRF response. Your contract must * @notice implement it. See "SECURITY CONSIDERATIONS" above for important * @notice principles to keep in mind when implementing your fulfillRandomness * @notice method. * * @dev VRFConsumerBaseV2 expects its subcontracts to have a method with this * @dev signature, and will call it once it has verified the proof * @dev associated with the randomness. (It is triggered via a call to * @dev rawFulfillRandomness, below.) * * @param requestId The Id initially returned by requestRandomness * @param randomWords the VRF output expanded to the requested number of words */ function fulfillRandomWords(uint256 requestId, uint256[] memory randomWords) internal virtual; // rawFulfillRandomness is called by VRFCoordinator when it receives a valid VRF // proof. rawFulfillRandomness then calls fulfillRandomness, after validating // the origin of the call function rawFulfillRandomWords(uint256 requestId, uint256[] memory randomWords) external { if (msg.sender != vrfCoordinator) { revert OnlyCoordinatorCanFulfill(msg.sender, vrfCoordinator); } fulfillRandomWords(requestId, randomWords); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.22; /** **************************************************************************** * @notice Interface for contracts using VRF randomness * Modified version of Chainlinks VRFConsumerBase to use multiple coordinators * ***************************************************************************** * * @dev Calling contracts must inherit from VRFConsumerBase * * @dev USAGE * * @dev Call requestRandomWords(keyHash, subId, minimumRequestConfirmations, * @dev callbackGasLimit, numWords), * @dev see (VRFCoordinatorInterface for a description of the arguments). * * @dev Once the VRFCoordinator has received and validated the oracle's response * @dev to your request, it will call your contract's fulfillRandomWords method. * * @dev The randomness argument to fulfillRandomWords is a set of random words * @dev generated from your requestId and the blockHash of the request. * * @dev If your contract could have concurrent requests open, you can use the * @dev requestId returned from requestRandomWords to track which response is associated * @dev with which randomness request. * * @dev Colliding `requestId`s are cryptographically impossible as long as seeds * @dev differ. **/ import "@openzeppelin/contracts/access/Ownable2Step.sol"; abstract contract FerdyMultiVRFConsumerBase is Ownable2Step { error OnlyCoordinatorCanFulfill(address have); /// List of coordinators that can send randomness. /// We support 3 different types, not just Chainlink. mapping(address => bool) private vrfCoordinators; function setVRFCoordinator(address coordinator, bool active) public onlyOwner { vrfCoordinators[coordinator] = active; } /** * @notice fulfillRandomWords handles the VRF response. Your contract must * @notice implement it. * * @dev VRFConsumerBaseV2 expects its subcontracts to have a method with this * @dev signature, and will call it once it has verified the proof * @dev associated with the randomness. (It is triggered via a call to * @dev rawFulfillRandomness, below.) * * @param requestId The Id initially returned by requestRandomness * @param randomWords the VRF output expanded to the requested number of words **/ function fulfillRandomWords(uint256 requestId, uint256[] memory randomWords) internal virtual; // rawFulfillRandomWords is called by VRFCoordinator when it receives a valid VRF // proof. rawFulfillRandomness then calls fulfillRandomness, after validating // the origin of the call function rawFulfillRandomWords(uint256 requestId, uint256[] memory randomWords) external { if (vrfCoordinators[msg.sender] != true) { revert OnlyCoordinatorCanFulfill(msg.sender); } fulfillRandomWords(requestId, randomWords); } }
// 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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: address zero is not a valid owner"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _ownerOf(tokenId); require(owner != address(0), "ERC721: invalid token ID"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { _requireMinted(tokenId); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not token owner or approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { _requireMinted(tokenId); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom(address from, address to, uint256 tokenId) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _safeTransfer(from, to, tokenId, data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist */ function _ownerOf(uint256 tokenId) internal view virtual returns (address) { return _owners[tokenId]; } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _ownerOf(tokenId) != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { address owner = ERC721.ownerOf(tokenId); return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId, 1); // Check that tokenId was not minted by `_beforeTokenTransfer` hook require(!_exists(tokenId), "ERC721: token already minted"); unchecked { // Will not overflow unless all 2**256 token ids are minted to the same owner. // Given that tokens are minted one by one, it is impossible in practice that // this ever happens. Might change if we allow batch minting. // The ERC fails to describe this case. _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId, 1); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * This is an internal function that does not check if the sender is authorized to operate on the token. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId, 1); // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook owner = ERC721.ownerOf(tokenId); // Clear approvals delete _tokenApprovals[tokenId]; unchecked { // Cannot overflow, as that would require more tokens to be burned/transferred // out than the owner initially received through minting and transferring in. _balances[owner] -= 1; } delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId, 1); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId, 1); // Check that tokenId was not transferred by `_beforeTokenTransfer` hook require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); // Clear approvals from the previous owner delete _tokenApprovals[tokenId]; unchecked { // `_balances[from]` cannot overflow for the same reason as described in `_burn`: // `from`'s balance is the number of token held, which is at least one before the current // transfer. // `_balances[to]` could overflow in the conditions described in `_mint`. That would require // all 2**256 token ids to be minted, which in practice is impossible. _balances[from] -= 1; _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll(address owner, address operator, bool approved) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Reverts if the `tokenId` has not been minted yet. */ function _requireMinted(uint256 tokenId) internal view virtual { require(_exists(tokenId), "ERC721: invalid token ID"); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`. * - When `from` is zero, the tokens will be minted for `to`. * - When `to` is zero, ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {} /** * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`. * - When `from` is zero, the tokens were minted for `to`. * - When `to` is zero, ``from``'s tokens were burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {} /** * @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override. * * WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant * being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such * that `ownerOf(tokenId)` is `a`. */ // solhint-disable-next-line func-name-mixedcase function __unsafe_increaseBalance(address account, uint256 amount) internal { _balances[account] += amount; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// 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); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; import "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toString(int256 value) internal pure returns (string memory) { return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value)))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.0; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
{ "remappings": [ "@openzeppelin/=lib/openzeppelin-contracts/", "@chainlink/=lib/chainlink/", "chainlink/=lib/chainlink/", "ds-test/=lib/forge-std/lib/ds-test/src/", "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/", "forge-std/=lib/forge-std/src/", "openzeppelin-contracts/=lib/openzeppelin-contracts/", "openzeppelin/=lib/openzeppelin-contracts/contracts/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "paris", "viaIR": false, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"have","type":"address"}],"name":"OnlyCoordinatorCanFulfill","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"creator","type":"address"},{"indexed":true,"internalType":"uint256","name":"gameId","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"subgame","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"numRounds","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"bucketCount","type":"uint8"},{"indexed":false,"internalType":"address","name":"referrer","type":"address"},{"indexed":false,"internalType":"uint256","name":"betPerRound","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rakePerRound","type":"uint256"},{"indexed":false,"internalType":"enum GameVRF.FulfillmentMethod","name":"method","type":"uint8"}],"name":"GameStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","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":true,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":true,"internalType":"address","name":"vrfCoordinator","type":"address"},{"indexed":true,"internalType":"uint256","name":"gameId","type":"uint256"}],"name":"RequestedGameWinner","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"gameId","type":"uint256"},{"components":[{"internalType":"enum CentralGameBase.RoundState","name":"state","type":"uint8"},{"internalType":"uint256","name":"sent","type":"uint256"},{"internalType":"uint8","name":"selected","type":"uint8"}],"indexed":false,"internalType":"struct Plinko.RoundInfo[]","name":"results","type":"tuple[]"}],"name":"WinnerPicked","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"betMultiplePerRound","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"bucketCountByGameId","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"","type":"uint8"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"bucketMultipliers","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"","type":"uint8"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"bucketProbabilities","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentGameId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"gameId","type":"uint256"},{"internalType":"enum GameVRF.FulfillmentMethod","name":"method","type":"uint8"}],"name":"forceRequestWinner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"gameById","outputs":[{"internalType":"uint256","name":"gameId","type":"uint256"},{"internalType":"uint256","name":"betPerRound","type":"uint256"},{"internalType":"uint256","name":"rakePerRound","type":"uint256"},{"internalType":"uint256","name":"numRounds","type":"uint256"},{"internalType":"address","name":"creator","type":"address"},{"internalType":"address","name":"referrer","type":"address"},{"internalType":"uint8","name":"subgame","type":"uint8"},{"internalType":"enum CentralGameBase.GameState","name":"state","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"gameIdByRequestId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"gameId","type":"uint256"}],"name":"getGameInfo","outputs":[{"components":[{"internalType":"uint256","name":"gameId","type":"uint256"},{"internalType":"uint256","name":"betPerRound","type":"uint256"},{"internalType":"uint256","name":"rakePerRound","type":"uint256"},{"internalType":"uint256","name":"numRounds","type":"uint256"},{"internalType":"address","name":"creator","type":"address"},{"internalType":"address","name":"referrer","type":"address"},{"internalType":"uint8","name":"subgame","type":"uint8"},{"internalType":"enum CentralGameBase.GameState","name":"state","type":"uint8"}],"internalType":"struct CentralGameBase.GameInfo","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"gameIds","type":"uint256[]"}],"name":"getManyGameInfo","outputs":[{"components":[{"internalType":"uint256","name":"gameId","type":"uint256"},{"internalType":"uint256","name":"betPerRound","type":"uint256"},{"internalType":"uint256","name":"rakePerRound","type":"uint256"},{"internalType":"uint256","name":"numRounds","type":"uint256"},{"internalType":"address","name":"creator","type":"address"},{"internalType":"address","name":"referrer","type":"address"},{"internalType":"uint8","name":"subgame","type":"uint8"},{"internalType":"enum CentralGameBase.GameState","name":"state","type":"uint8"}],"internalType":"struct CentralGameBase.GameInfo[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"bucketCount","type":"uint8"}],"name":"getMaxBetPerRound","outputs":[{"internalType":"uint256","name":"safeMaxPotentialBet","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNumWords","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"getRequestConfirmations","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxBetDivisor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxConsecutiveRounds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minBet","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"roundCount","type":"uint8"},{"internalType":"uint8","name":"bucketCount","type":"uint8"},{"internalType":"string","name":"referralCode","type":"string"},{"internalType":"enum GameVRF.FulfillmentMethod","name":"method","type":"uint8"}],"name":"playGame","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"rakeDistributorAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"},{"internalType":"uint256[]","name":"randomWords","type":"uint256[]"}],"name":"rawFulfillRandomWords","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"referralTrackerAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"}],"name":"rescueERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"rescueERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"rescueNative","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"betMultiplePerRound_","type":"uint256"}],"name":"setBetMultiplePerRound","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"gameId_","type":"uint256"}],"name":"setCurrentGameId","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"maxBetDivisor_","type":"uint256"}],"name":"setMaxBetDivisor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"maxConsecutiveRounds_","type":"uint256"}],"name":"setMaxConsecutiveRounds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"minBet_","type":"uint256"}],"name":"setMinBet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"paused_","type":"bool"}],"name":"setPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"rakeAddress","type":"address"}],"name":"setRakeDistributorAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_referralTrackerAddress","type":"address"}],"name":"setReferralTrackerAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"requestConfirmations","type":"uint16"}],"name":"setRequestConfirmations","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_treasuryAddress","type":"address"}],"name":"setTreasuryAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"coordinator","type":"address"},{"internalType":"bool","name":"active","type":"bool"}],"name":"setVRFCoordinator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum GameVRF.FulfillmentMethod","name":"method","type":"uint8"},{"internalType":"bytes32","name":"gasLane","type":"bytes32"},{"internalType":"address","name":"coordAddress","type":"address"},{"internalType":"uint64","name":"subscriptionId","type":"uint64"},{"internalType":"uint32","name":"callbackGasLimit","type":"uint32"}],"name":"setVRFCoordinatorInfoByMethod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasuryAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60806040526706f05b59d3b200006007556014600855600a6009819055662386f26fc100009055600d805461ffff19166002179055620f42406012553480156200004857600080fd5b506200005433620008cc565b670de0b6b3a76400006007908155606460098190556040805160e0810182526103e88082526020808301859052604693830184905260286060840152608083019390935260a082019390935260c08101929092526000839052600f9052620000df917f73dfc495eb54bd6713ffc079b9f5e40f2fecd3793d143759ba0128fbedb4025491906200093a565b506040805160e0810182526137ea81526202a45160208083019190915262054d47928201929092526209f4f96060820152620c9def6080820152620f0a5660a0820152620f424060c082015260076000819052601090925262000165917f4ef6145e44e4298293af15ae5f84f922a836b1d6db608fd5008f32a528b312a9919062000990565b5060408051610100810182526105dc80825260fa60208084018290526046948401859052602860608501819052608085015260a084019490945260c083015260e082015260086000819052600f909252620001e3917f49a9092dc5c03b26195f6621c97b5cf515cb77afe659e3fe008a73456354eb6891906200093a565b506040805161010081018252611d15815262010f6d602080830191909152620372f3928201929092526207a11e6060820152620bcf4d6080820152620e32d360a0820152620f252b60c0820152620f424060e082015260086000819052601090925262000273917f5f04e77c60ed37290f5789e2e9c5d396103f3c4b14614065cbb4c8362609d5a5919062000990565b5060408051610120810182526108028082526101906020808401829052605a948401859052603c606085018190526028608086015260a085015260c084019490945260e083015261010082015260096000819052600f909252620002fa917f3e674ca654b1063e821161bbf601452dd0f1671d575d614ba17ca7f3cdc7603991906200093a565b50604080516101208101825261126981526170dd60208083019190915262026c85928201929092526205660160608201526209dc3f6080820152620cd5bb60a0820152620ed16360c0820152620f2fd760e0820152620f424061010082015260096000819052601090925262000393917fa8197f9f3066d467dba941614f445cf878e0beb059ed920f6258667ed2470eb8919062000990565b5060408051610140810182526111948082526103206020808401829052605a948401859052603c6060850181905260286080860181905260a086015260c085015260e0840194909452610100830152610120820152600a6000819052600f90925262000422917fa13a7a52a9cbb6a90f40d40fbf35f68146be73226e0f48ff16963183fd5684ad91906200093a565b50604080516101408101825261075981526145636020808301919091526201d1f692820192909252620424d260608201526207a11d6080820152620b1d6e60a0820152620d704a60c0820152620efcdd60e0820152620f3ae7610100820152620f4240610120820152600a60008190526010909252620004c5917fbbe6df1631c6a5c37158096bc15825d83d22eaca9ac1e829be6dfcdebed1d2d7919062000990565b50604080516101608101825261125c808252610320602080840182905260c8948401859052605a60608501819052603c60808601819052602860a087015260c086015260e0850152610100840194909452610120830152610140820152600b6000819052600f9092526200055c917f0db0e9d5a07148aa3e0acc10f721b78526b53a3f4f3d07794be76568de7347c591906200093a565b5060408051610160810182526107448152611cc960208083019190915261abe69282019290925262028743606082015262056bd860808201526209d66860a0820152620cbafd60c0820152620e965a60e0820152620f2577610100820152620f3afc610120820152620f4240610140820152600b6000819052601090925262000608917f222281f8a778a50c678b18290b6f1f76b73341460456cd404319acd135fca477919062000990565b5060408051610180810182526119648082526106a46020808401829052610190948401859052605a60608501819052603c60808601819052602860a0870181905260c087015260e0860152610100850152610120840194909452610140830152610160820152600c6000819052600f909252620006a8917faed549f926a17a28853af2d56b17ad8ad8d799c48d325a734362b810173b772991906200093a565b5060408051610180810182526104a381526113aa602080830191909152615a1d928201929092526201e253606082015262042ea460808201526207a11d60a0820152620b139c60c0820152620d5fed60e0820152620ee823610100820152620f2e96610120820152620f3d9d610140820152620f4240610160820152600c600081905260109092526200075e917f1c47f412c035acfb11780222aae71bf1bbf164d6655f4eb426a4fdb92a17a323919062000990565b50604080516101a081018252611b58808252610640602080840182905261012c94840185905260c860608501819052605a60808601819052603c60a08701819052602860c088015260e0870152610100860152610120850152610140840194909452610160830152610180820152600d6000819052600f90925262000806917fe48c37f5ec5b77098fcb2a7935f0925fec1a69796c076c65ed90d9c90ef07dc591906200093a565b50604080516101a0810182526103378152610ff06020808301919091526155b79282019290925261a4936060820152620278eb6080820152620570c760a08201526209d17960c0820152620cc95560e0820152620e9dad610100820152620eec89610120820152620f3250610140820152620f3f09610160820152620f4240610180820152600d60008190526010909252620008c5917fdfb340902d3967fa50e8165d4f7a13c9cb160eea8fb21544939c9a839ac4b6c4919062000990565b50620009ec565b600180546001600160a01b0319169055620008e781620008ea565b50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b8280548282559060005260206000209081019282156200097e579160200282015b828111156200097e578251829061ffff169055916020019190600101906200095b565b506200098c929150620009d5565b5090565b8280548282559060005260206000209081019282156200097e579160200282015b828111156200097e578251829062ffffff16905591602001919060010190620009b1565b5b808211156200098c5760008155600101620009d6565b6129de80620009fc6000396000f3fe6080604052600436106102555760003560e01c80637b8812c511610139578063c20ee3fb116100b6578063d79818341161007a578063d798183414610779578063d9b61f6814610799578063e30c3978146107b9578063e427275b146107d7578063f2fde38b146107ea578063fe3273231461080a57600080fd5b8063c20ee3fb146106de578063c5f956af146106fe578063ccec37161461071e578063ccf1719f1461073e578063d39b5cbb1461075457600080fd5b80639d4b950c116100fd5780639d4b950c1461063b578063a7f360611461065b578063b497b3541461067b578063b4a91e1e14610691578063c072a4b8146106be57600080fd5b80637b8812c5146105715780638824f5a7146105b357806388ea41b9146105d35780638da5cb5b146105f35780639619367d1461062557600080fd5b8063454aa669116101d25780635c975abb116101965780635c975abb146104505780635f1b0fd81461047a5780636605bfda1461049d578063715018a6146104bd57806376623022146104d257806379ba50971461055c57600080fd5b8063454aa669146103ac57806347e1d550146103cc578063536a3ddc146103f957806353a2c19a1461040f5780635a3e2e8b1461042357600080fd5b80631fe543e3116102195780631fe543e31461031657806321154ec5146103365780632e35a302146103565780633984977114610376578063440741fa1461038c57600080fd5b806305287f0c14610261578063081ce7521461028357806316c38b3c146102b65780631bdb2d99146102d65780631fa33a2a146102f657600080fd5b3661025c57005b600080fd5b34801561026d57600080fd5b5061028161027c3660046121d5565b61082a565b005b34801561028f57600080fd5b506102a361029e366004612204565b610837565b6040519081526020015b60405180910390f35b3480156102c257600080fd5b506102816102d136600461223c565b610868565b3480156102e257600080fd5b506102816102f1366004612284565b610883565b34801561030257600080fd5b50610281610311366004612300565b61097a565b34801561032257600080fd5b50610281610331366004612400565b6109ad565b34801561034257600080fd5b506102816103513660046121d5565b6109f7565b34801561036257600080fd5b50610281610371366004612447565b610a04565b34801561038257600080fd5b506102a360085481565b34801561039857600080fd5b506102a36103a7366004612464565b610a34565b3480156103b857600080fd5b506102816103c73660046121d5565b610abd565b3480156103d857600080fd5b506103ec6103e73660046121d5565b610b1a565b6040516102ad919061250f565b34801561040557600080fd5b506102a360025481565b34801561041b57600080fd5b5060016102a3565b34801561042f57600080fd5b5061044361043e366004612524565b610bd1565b6040516102ad9190612559565b34801561045c57600080fd5b5060045461046a9060ff1681565b60405190151581526020016102ad565b34801561048657600080fd5b50600d5460405161ffff90911681526020016102ad565b3480156104a957600080fd5b506102816104b8366004612447565b610d2d565b3480156104c957600080fd5b50610281610d57565b3480156104de57600080fd5b506105486104ed3660046121d5565b600360208190526000918252604090912080546001820154600283015493830154600484015460059094015492949193919290916001600160a01b03908116919081169060ff600160a01b8204811691600160a81b90041688565b6040516102ad9897969594939291906125a8565b34801561056857600080fd5b50610281610d6b565b34801561057d57600080fd5b506105a161058c3660046121d5565b60116020526000908152604090205460ff1681565b60405160ff90911681526020016102ad565b3480156105bf57600080fd5b506102816105ce366004612601565b610de5565b3480156105df57600080fd5b506102816105ee3660046121d5565b610e05565b3480156105ff57600080fd5b506000546001600160a01b03165b6040516001600160a01b0390911681526020016102ad565b34801561063157600080fd5b506102a360075481565b34801561064757600080fd5b50610281610656366004612447565b610e12565b34801561066757600080fd5b50610281610676366004612625565b610e3c565b34801561068757600080fd5b506102a360095481565b34801561069d57600080fd5b506102a36106ac3660046121d5565b600e6020526000908152604090205481565b3480156106ca57600080fd5b506102816106d93660046121d5565b610ec3565b3480156106ea57600080fd5b506102816106f93660046121d5565b610ed0565b34801561070a57600080fd5b5060065461060d906001600160a01b031681565b34801561072a57600080fd5b50610281610739366004612447565b610edd565b34801561074a57600080fd5b506102a3600a5481565b34801561076057600080fd5b5060045461060d9061010090046001600160a01b031681565b34801561078557600080fd5b50610281610794366004612651565b610fc8565b3480156107a557600080fd5b5060055461060d906001600160a01b031681565b3480156107c557600080fd5b506001546001600160a01b031661060d565b6102816107e536600461266f565b61103d565b3480156107f657600080fd5b50610281610805366004612447565b611193565b34801561081657600080fd5b506102a3610825366004612204565b611204565b610832611220565b600255565b600f602052816000526040600020818154811061085357600080fd5b90600052602060002001600091509150505481565b610870611220565b6004805460ff1916911515919091179055565b61088b611220565b6040518060800160405280858152602001846001600160a01b031681526020018367ffffffffffffffff1681526020018263ffffffff16815250600c60008760028111156108db576108db61247f565b60028111156108ec576108ec61247f565b815260208082019290925260409081016000208351815591830151600192830180549285015160609095015163ffffffff16600160e01b026001600160e01b0367ffffffffffffffff909616600160a01b026001600160e01b03199094166001600160a01b039093169290921792909217939093169290921790915561097390849061097a565b5050505050565b610982611220565b6001600160a01b03919091166000908152600b60205260409020805460ff1916911515919091179055565b336000908152600b602052604090205460ff1615156001146109e957604051637885129b60e01b81523360048201526024015b60405180910390fd5b6109f3828261127a565b5050565b6109ff611220565b600855565b610a0c611220565b600480546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b6008546006546000918291610a5391906001600160a01b031631612762565b60ff84166000908152600f60205260408120805492935090918290610a7a57610a7a612776565b9060005260206000200154826064610a92919061278c565b610a9c9190612762565b9050605f610aab82606461278c565b610ab59190612762565b949350505050565b610ac5611220565b604051600090339083908381818185875af1925050503d8060008114610b07576040519150601f19603f3d011682016040523d82523d6000602084013e610b0c565b606091505b50509050806109f357600080fd5b610b22612193565b6000828152600360208181526040928390208351610100810185528154815260018201549281019290925260028101549382019390935282820154606082015260048301546001600160a01b039081166080830152600584015490811660a083015260ff600160a01b8204811660c084015291939260e0850192600160a81b90920490911690811115610bb757610bb761247f565b6003811115610bc857610bc861247f565b90525092915050565b805160609060008167ffffffffffffffff811115610bf157610bf1612339565b604051908082528060200260200182016040528015610c2a57816020015b610c17612193565b815260200190600190039081610c0f5790505b50905060005b82811015610d255760036000868381518110610c4e57610c4e612776565b602090810291909101810151825281810192909252604090810160002081516101008101835281548152600182015493810193909352600281015491830191909152600380820154606084015260048201546001600160a01b039081166080850152600583015490811660a085015260ff600160a01b8204811660c086015260e0850192600160a81b9092041690811115610ceb57610ceb61247f565b6003811115610cfc57610cfc61247f565b81525050828281518110610d1257610d12612776565b6020908102919091010152600101610c30565b509392505050565b610d35611220565b600680546001600160a01b0319166001600160a01b0392909216919091179055565b610d5f611220565b610d696000611701565b565b60015433906001600160a01b03168114610dd95760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b60648201526084016109e0565b610de281611701565b50565b610ded611220565b600d805461ffff191661ffff92909216919091179055565b610e0d611220565b600755565b610e1a611220565b600580546001600160a01b0319166001600160a01b0392909216919091179055565b610e44611220565b600082815260036020526040902060016005820154600160a81b900460ff166003811115610e7457610e7461247f565b03610eb25760405162461bcd60e51b815260206004820152600e60248201526d185b1c9958591e4818db1bdcd95960921b60448201526064016109e0565b8054610ebe908361171a565b505050565b610ecb611220565b600955565b610ed8611220565b600a55565b610ee5611220565b6040516370a0823160e01b815230600482015281906001600160a01b0382169063a9059cbb90339083906370a0823190602401602060405180830381865afa158015610f35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f5991906127a3565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303816000875af1158015610fa4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ebe91906127bc565b610fd0611220565b6040516323b872dd60e01b81523060048201523360248201526044810182905282906001600160a01b038216906323b872dd90606401600060405180830381600087803b15801561102057600080fd5b505af1158015611034573d6000803e3d6000fd5b50505050505050565b3233146110835760405162461bcd60e51b8152602060048201526014602482015273139bc818dbdb9d1c9858dd1cc8185b1b1bddd95960621b60448201526064016109e0565b60045460ff16156110c75760405162461bcd60e51b815260206004820152600e60248201526d11d85b59481a5cc81c185d5cd95960921b60448201526064016109e0565b600660009054906101000a90046001600160a01b03166001600160a01b031663344049676040518163ffffffff1660e01b81526004016020604051808303816000875af115801561111c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061114091906127bc565b156111845760405162461bcd60e51b8152602060048201526014602482015273547265617375727920697320746f6f206c6f772160601b60448201526064016109e0565b6109738460ff16848484611939565b61119b611220565b600180546001600160a01b0383166001600160a01b031990911681179091556111cc6000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6010602052816000526040600020818154811061085357600080fd5b6000546001600160a01b03163314610d695760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109e0565b6000828152600e6020526040812054908190036112d95760405162461bcd60e51b815260206004820152601960248201527f5265717565737420616c72656164792066756c66696c6c65640000000000000060448201526064016109e0565b6000818152600360205260408120906005820154600160a81b900460ff1660038111156113085761130861247f565b146113555760405162461bcd60e51b815260206004820152601c60248201527f47616d65206e6f742077616974696e6720666f7220726573756c74730000000060448201526064016109e0565b600381015460008381526011602052604081205460ff16908267ffffffffffffffff81111561138657611386612339565b6040519080825280602002602001820160405280156113d157816020015b60408051606081018252600080825260208083018290529282015282526000199092019101816113a45790505b5060ff83166000908152600f60209081526040808320805482518185028101850190935280835294955092938493919283018282801561143057602002820191906000526020600020905b81548152602001906001019080831161141c575b5050505060ff86166000908152601060209081526040808320805482518185028101850190935280835295965092949093509083018282801561149257602002820191906000526020600020905b81548152602001906001019080831161147e575b5050505050905060005b868110156115e55760008a6000815181106114b9576114b9612776565b6020026020010151826040516020016114dc929190918252602082015260400190565b6040516020818303038152906040528051906020012060001c905060006012548261150791906127d9565b905060005b8860ff168110156115d75784818151811061152957611529612776565b60200260200101518210156115cf578088858151811061154b5761154b612776565b60200260200101516040019060ff16908160ff16815250506000606487838151811061157957611579612776565b60200260200101518d60010154611590919061278c565b61159a9190612762565b9050808986815181106115af576115af612776565b60209081029190910181015101526115c781896127ed565b9750506115d7565b60010161150c565b50505080600101905061149c565b50877f63058c0e59927214eb2eb0e99a45f7f4864777d13d86a856486a8581a993080e856040516116169190612800565b60405180910390a260048088015460008a8152600360208181526040808420848155600181018590556002810185905592830184905594820180546001600160a01b0319169055600590910180546001600160b01b03191690558d8252600e9052918220919091556001600160a01b031683156116f45760065460405163cf8d133f60e01b81526001600160a01b038381166004830152602482018790529091169063cf8d133f90604401600060405180830381600087803b1580156116db57600080fd5b505af11580156116ef573d6000803e3d6000fd5b505050505b5050505050505050505050565b600180546001600160a01b0319169055610de281611e26565b6000600c60008360028111156117325761173261247f565b60028111156117435761174361247f565b81526020810191909152604001600020600101546001600160a01b03169050806117a55760405162461bcd60e51b8152602060048201526013602482015272496e76616c696420565246206164647265737360681b60448201526064016109e0565b8060006001600160a01b038216635d3b1d30600c838760028111156117cc576117cc61247f565b60028111156117dd576117dd61247f565b815260200190815260200160002060000154600c60008860028111156118055761180561247f565b60028111156118165761181661247f565b815260200190815260200160002060010160149054906101000a900467ffffffffffffffff16600d60009054906101000a900461ffff16600c60008a60028111156118635761186361247f565b60028111156118745761187461247f565b81526020810191909152604090810160002060019081015491516001600160e01b031960e088901b168152600481019590955267ffffffffffffffff909316602485015261ffff909116604484015263ffffffff600160e01b909104166064830152608482015260a4016020604051808303816000875af11580156118fd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061192191906127a3565b6000908152600e602052604090209490945550505050565b600480546006546040805163e54c9f6b60e01b815290516000946001600160a01b0361010090950485169486946119c29491163192869263e54c9f6b928082019260209290918290030181865afa158015611998573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119bc91906127a3565b89611e76565b90506064871115611a155760405162461bcd60e51b815260206004820152601c60248201527f4e6f206d6f7265207468616e203130302062616c6c732c206b696e670000000060448201526064016109e0565b60ff86166000908152600f6020526040902054611a445760405162461bcd60e51b81526004016109e090612865565b60ff8616600090815260106020526040902054611a735760405162461bcd60e51b81526004016109e090612865565b60ff86166000908152600f602052604081208054606491908390611a9957611a99612776565b90600052602060002001548360400151611ab3919061278c565b611abd9190612762565b600854600654919250611ad9916001600160a01b031631612762565b811115611b1c5760405162461bcd60e51b815260206004820152601160248201527047616d626c65206c6573732c206b696e6760781b60448201526064016109e0565b60028054906000611b2c836128a8565b9190505550611b39612193565b606081018990523360808201819052600560c0830152604051636431085f60e11b81526001600160a01b0386169163c86210be91611b7c91908b906004016128c1565b602060405180830381865afa158015611b99573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bbd9190612920565b6001600160a01b0390811660a08301526002548252600060e08301819052604085810151602085015260608601518185015260065486519151929316918381818185875af1925050503d8060008114611c32576040519150601f19603f3d011682016040523d82523d6000602084013e611c37565b606091505b5050905080611c4557600080fd5b5080516000908152600360208181526040928390208451815590840151600182015591830151600283015560608301518282015560808301516004830180546001600160a01b039283166001600160a01b031990911617905560a084015160058401805460c087015160ff16600160a01b026001600160a81b031990911692909316919091179190911780825560e085015185949390929160ff60a81b191690600160a81b908490811115611cfc57611cfc61247f565b021790555090505087601160008360000151815260200190815260200160002060006101000a81548160ff021916908360ff1602179055508060000151336001600160a01b03167f758ee7ccbf250272f61109c46cd1a1e69355278f18bb0eb9472f81e98235eceb8360c001518c8c8660a00151876020015188604001518e604051611d8e979695949392919061293d565b60405180910390a36020830151815160a083015160405163919ac7ff60e01b815260048101929092523360248301526001600160a01b03908116604483015286169163919ac7ff916064016000604051808303818588803b158015611df257600080fd5b505af1158015611e06573d6000803e3d6000fd5b5050505050611e1981600001518761171a565b5198975050505050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b611ea86040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b6000611eb6846127106127ed565b611ec23461271061278c565b611ecc9190612762565b90506000611eda8234612995565b9050600754821015611f225760405162461bcd60e51b815260206004820152601160248201527023b0b6b136329036b7b9329610383632b160791b60448201526064016109e0565b600854611f2f9087612762565b821115611f725760405162461bcd60e51b815260206004820152601160248201527047616d626c65206c6573732c206b696e6760781b60448201526064016109e0565b60008411611fc25760405162461bcd60e51b815260206004820152601a60248201527f47616d626c65206174206c65617374206f6e63652c20706c656200000000000060448201526064016109e0565b6009548411156120145760405162461bcd60e51b815260206004820152601860248201527f47616d626c652066657765722074696d65732c206b696e67000000000000000060448201526064016109e0565b60006120208584612762565b905061202c85846127d9565b1561208f5760405162461bcd60e51b815260206004820152602d60248201527f47616d626c6520616e20616d6f756e7420646976697369626c6520627920796f60448201526c3ab9103132ba399610383632b160991b60648201526084016109e0565b600a5461209c90826127d9565b156120f75760405162461bcd60e51b815260206004820152602560248201527f47616d626c652074686520726967687420616d6f756e7420706572206265742c60448201526410383632b160d91b60648201526084016109e0565b60006121038684612762565b905061210f86846127d9565b156121665760405162461bcd60e51b815260206004820152602160248201527f496e7465726e616c206572726f723b2077726f6e672072616b6520616d6f756e6044820152601d60fa1b60648201526084016109e0565b6040805160a081018252948552602085019390935291830152606082015260006080820152949350505050565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c081018290529060e082015290565b6000602082840312156121e757600080fd5b5035919050565b803560ff811681146121ff57600080fd5b919050565b6000806040838503121561221757600080fd5b612220836121ee565b946020939093013593505050565b8015158114610de257600080fd5b60006020828403121561224e57600080fd5b81356122598161222e565b9392505050565b8035600381106121ff57600080fd5b6001600160a01b0381168114610de257600080fd5b600080600080600060a0868803121561229c57600080fd5b6122a586612260565b94506020860135935060408601356122bc8161226f565b9250606086013567ffffffffffffffff811681146122d957600080fd5b9150608086013563ffffffff811681146122f257600080fd5b809150509295509295909350565b6000806040838503121561231357600080fd5b823561231e8161226f565b9150602083013561232e8161222e565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561237857612378612339565b604052919050565b600082601f83011261239157600080fd5b8135602067ffffffffffffffff8211156123ad576123ad612339565b8160051b6123bc82820161234f565b92835284810182019282810190878511156123d657600080fd5b83870192505b848310156123f5578235825291830191908301906123dc565b979650505050505050565b6000806040838503121561241357600080fd5b82359150602083013567ffffffffffffffff81111561243157600080fd5b61243d85828601612380565b9150509250929050565b60006020828403121561245957600080fd5b81356122598161226f565b60006020828403121561247657600080fd5b612259826121ee565b634e487b7160e01b600052602160045260246000fd5b60048110610de257610de261247f565b80518252602081015160208301526040810151604083015260608101516060830152608081015160018060a01b0380821660808501528060a08401511660a0850152505060ff60c08201511660c083015260e081015161250481612495565b8060e0840152505050565b610100810161251e82846124a5565b92915050565b60006020828403121561253657600080fd5b813567ffffffffffffffff81111561254d57600080fd5b610ab584828501612380565b6020808252825182820181905260009190848201906040850190845b8181101561259c576125888385516124a5565b928401926101009290920191600101612575565b50909695505050505050565b8881526020810188905260408101879052606081018690526001600160a01b038581166080830152841660a082015260ff831660c082015261010081016125ee83612495565b8260e08301529998505050505050505050565b60006020828403121561261357600080fd5b813561ffff8116811461225957600080fd5b6000806040838503121561263857600080fd5b8235915061264860208401612260565b90509250929050565b6000806040838503121561266457600080fd5b82356122208161226f565b6000806000806080858703121561268557600080fd5b61268e856121ee565b9350602061269d8187016121ee565b9350604086013567ffffffffffffffff808211156126ba57600080fd5b818801915088601f8301126126ce57600080fd5b8135818111156126e0576126e0612339565b6126f2601f8201601f1916850161234f565b9150808252898482850101111561270857600080fd5b808484018584013760008482840101525080945050505061272b60608601612260565b905092959194509250565b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60008261277157612771612736565b500490565b634e487b7160e01b600052603260045260246000fd5b808202811582820484141761251e5761251e61274c565b6000602082840312156127b557600080fd5b5051919050565b6000602082840312156127ce57600080fd5b81516122598161222e565b6000826127e8576127e8612736565b500690565b8082018082111561251e5761251e61274c565b602080825282518282018190526000919060409081850190868401855b82811015612858578151805161283281612495565b8552808701518786015285015160ff16858501526060909301929085019060010161281d565b5091979650505050505050565b60208082526023908201527f55736520616e20657870656374656420636f6e66696775726174696f6e2c20706040820152623632b160e91b606082015260800190565b6000600182016128ba576128ba61274c565b5060010190565b60018060a01b03831681526000602060406020840152835180604085015260005b818110156128fe578581018301518582016060015282016128e2565b506000606082860101526060601f19601f830116850101925050509392505050565b60006020828403121561293257600080fd5b81516122598161226f565b60ff888116825260208201889052861660408201526001600160a01b03851660608201526080810184905260a0810183905260e08101600383106129835761298361247f565b8260c083015298975050505050505050565b8181038181111561251e5761251e61274c56fea26469706673582212204dbc4cab83e929999d0e54c02b2590b11e06120a30a108ffcba4158dda588d7b64736f6c63430008160033
Deployed Bytecode
0x6080604052600436106102555760003560e01c80637b8812c511610139578063c20ee3fb116100b6578063d79818341161007a578063d798183414610779578063d9b61f6814610799578063e30c3978146107b9578063e427275b146107d7578063f2fde38b146107ea578063fe3273231461080a57600080fd5b8063c20ee3fb146106de578063c5f956af146106fe578063ccec37161461071e578063ccf1719f1461073e578063d39b5cbb1461075457600080fd5b80639d4b950c116100fd5780639d4b950c1461063b578063a7f360611461065b578063b497b3541461067b578063b4a91e1e14610691578063c072a4b8146106be57600080fd5b80637b8812c5146105715780638824f5a7146105b357806388ea41b9146105d35780638da5cb5b146105f35780639619367d1461062557600080fd5b8063454aa669116101d25780635c975abb116101965780635c975abb146104505780635f1b0fd81461047a5780636605bfda1461049d578063715018a6146104bd57806376623022146104d257806379ba50971461055c57600080fd5b8063454aa669146103ac57806347e1d550146103cc578063536a3ddc146103f957806353a2c19a1461040f5780635a3e2e8b1461042357600080fd5b80631fe543e3116102195780631fe543e31461031657806321154ec5146103365780632e35a302146103565780633984977114610376578063440741fa1461038c57600080fd5b806305287f0c14610261578063081ce7521461028357806316c38b3c146102b65780631bdb2d99146102d65780631fa33a2a146102f657600080fd5b3661025c57005b600080fd5b34801561026d57600080fd5b5061028161027c3660046121d5565b61082a565b005b34801561028f57600080fd5b506102a361029e366004612204565b610837565b6040519081526020015b60405180910390f35b3480156102c257600080fd5b506102816102d136600461223c565b610868565b3480156102e257600080fd5b506102816102f1366004612284565b610883565b34801561030257600080fd5b50610281610311366004612300565b61097a565b34801561032257600080fd5b50610281610331366004612400565b6109ad565b34801561034257600080fd5b506102816103513660046121d5565b6109f7565b34801561036257600080fd5b50610281610371366004612447565b610a04565b34801561038257600080fd5b506102a360085481565b34801561039857600080fd5b506102a36103a7366004612464565b610a34565b3480156103b857600080fd5b506102816103c73660046121d5565b610abd565b3480156103d857600080fd5b506103ec6103e73660046121d5565b610b1a565b6040516102ad919061250f565b34801561040557600080fd5b506102a360025481565b34801561041b57600080fd5b5060016102a3565b34801561042f57600080fd5b5061044361043e366004612524565b610bd1565b6040516102ad9190612559565b34801561045c57600080fd5b5060045461046a9060ff1681565b60405190151581526020016102ad565b34801561048657600080fd5b50600d5460405161ffff90911681526020016102ad565b3480156104a957600080fd5b506102816104b8366004612447565b610d2d565b3480156104c957600080fd5b50610281610d57565b3480156104de57600080fd5b506105486104ed3660046121d5565b600360208190526000918252604090912080546001820154600283015493830154600484015460059094015492949193919290916001600160a01b03908116919081169060ff600160a01b8204811691600160a81b90041688565b6040516102ad9897969594939291906125a8565b34801561056857600080fd5b50610281610d6b565b34801561057d57600080fd5b506105a161058c3660046121d5565b60116020526000908152604090205460ff1681565b60405160ff90911681526020016102ad565b3480156105bf57600080fd5b506102816105ce366004612601565b610de5565b3480156105df57600080fd5b506102816105ee3660046121d5565b610e05565b3480156105ff57600080fd5b506000546001600160a01b03165b6040516001600160a01b0390911681526020016102ad565b34801561063157600080fd5b506102a360075481565b34801561064757600080fd5b50610281610656366004612447565b610e12565b34801561066757600080fd5b50610281610676366004612625565b610e3c565b34801561068757600080fd5b506102a360095481565b34801561069d57600080fd5b506102a36106ac3660046121d5565b600e6020526000908152604090205481565b3480156106ca57600080fd5b506102816106d93660046121d5565b610ec3565b3480156106ea57600080fd5b506102816106f93660046121d5565b610ed0565b34801561070a57600080fd5b5060065461060d906001600160a01b031681565b34801561072a57600080fd5b50610281610739366004612447565b610edd565b34801561074a57600080fd5b506102a3600a5481565b34801561076057600080fd5b5060045461060d9061010090046001600160a01b031681565b34801561078557600080fd5b50610281610794366004612651565b610fc8565b3480156107a557600080fd5b5060055461060d906001600160a01b031681565b3480156107c557600080fd5b506001546001600160a01b031661060d565b6102816107e536600461266f565b61103d565b3480156107f657600080fd5b50610281610805366004612447565b611193565b34801561081657600080fd5b506102a3610825366004612204565b611204565b610832611220565b600255565b600f602052816000526040600020818154811061085357600080fd5b90600052602060002001600091509150505481565b610870611220565b6004805460ff1916911515919091179055565b61088b611220565b6040518060800160405280858152602001846001600160a01b031681526020018367ffffffffffffffff1681526020018263ffffffff16815250600c60008760028111156108db576108db61247f565b60028111156108ec576108ec61247f565b815260208082019290925260409081016000208351815591830151600192830180549285015160609095015163ffffffff16600160e01b026001600160e01b0367ffffffffffffffff909616600160a01b026001600160e01b03199094166001600160a01b039093169290921792909217939093169290921790915561097390849061097a565b5050505050565b610982611220565b6001600160a01b03919091166000908152600b60205260409020805460ff1916911515919091179055565b336000908152600b602052604090205460ff1615156001146109e957604051637885129b60e01b81523360048201526024015b60405180910390fd5b6109f3828261127a565b5050565b6109ff611220565b600855565b610a0c611220565b600480546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b6008546006546000918291610a5391906001600160a01b031631612762565b60ff84166000908152600f60205260408120805492935090918290610a7a57610a7a612776565b9060005260206000200154826064610a92919061278c565b610a9c9190612762565b9050605f610aab82606461278c565b610ab59190612762565b949350505050565b610ac5611220565b604051600090339083908381818185875af1925050503d8060008114610b07576040519150601f19603f3d011682016040523d82523d6000602084013e610b0c565b606091505b50509050806109f357600080fd5b610b22612193565b6000828152600360208181526040928390208351610100810185528154815260018201549281019290925260028101549382019390935282820154606082015260048301546001600160a01b039081166080830152600584015490811660a083015260ff600160a01b8204811660c084015291939260e0850192600160a81b90920490911690811115610bb757610bb761247f565b6003811115610bc857610bc861247f565b90525092915050565b805160609060008167ffffffffffffffff811115610bf157610bf1612339565b604051908082528060200260200182016040528015610c2a57816020015b610c17612193565b815260200190600190039081610c0f5790505b50905060005b82811015610d255760036000868381518110610c4e57610c4e612776565b602090810291909101810151825281810192909252604090810160002081516101008101835281548152600182015493810193909352600281015491830191909152600380820154606084015260048201546001600160a01b039081166080850152600583015490811660a085015260ff600160a01b8204811660c086015260e0850192600160a81b9092041690811115610ceb57610ceb61247f565b6003811115610cfc57610cfc61247f565b81525050828281518110610d1257610d12612776565b6020908102919091010152600101610c30565b509392505050565b610d35611220565b600680546001600160a01b0319166001600160a01b0392909216919091179055565b610d5f611220565b610d696000611701565b565b60015433906001600160a01b03168114610dd95760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b60648201526084016109e0565b610de281611701565b50565b610ded611220565b600d805461ffff191661ffff92909216919091179055565b610e0d611220565b600755565b610e1a611220565b600580546001600160a01b0319166001600160a01b0392909216919091179055565b610e44611220565b600082815260036020526040902060016005820154600160a81b900460ff166003811115610e7457610e7461247f565b03610eb25760405162461bcd60e51b815260206004820152600e60248201526d185b1c9958591e4818db1bdcd95960921b60448201526064016109e0565b8054610ebe908361171a565b505050565b610ecb611220565b600955565b610ed8611220565b600a55565b610ee5611220565b6040516370a0823160e01b815230600482015281906001600160a01b0382169063a9059cbb90339083906370a0823190602401602060405180830381865afa158015610f35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f5991906127a3565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303816000875af1158015610fa4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ebe91906127bc565b610fd0611220565b6040516323b872dd60e01b81523060048201523360248201526044810182905282906001600160a01b038216906323b872dd90606401600060405180830381600087803b15801561102057600080fd5b505af1158015611034573d6000803e3d6000fd5b50505050505050565b3233146110835760405162461bcd60e51b8152602060048201526014602482015273139bc818dbdb9d1c9858dd1cc8185b1b1bddd95960621b60448201526064016109e0565b60045460ff16156110c75760405162461bcd60e51b815260206004820152600e60248201526d11d85b59481a5cc81c185d5cd95960921b60448201526064016109e0565b600660009054906101000a90046001600160a01b03166001600160a01b031663344049676040518163ffffffff1660e01b81526004016020604051808303816000875af115801561111c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061114091906127bc565b156111845760405162461bcd60e51b8152602060048201526014602482015273547265617375727920697320746f6f206c6f772160601b60448201526064016109e0565b6109738460ff16848484611939565b61119b611220565b600180546001600160a01b0383166001600160a01b031990911681179091556111cc6000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6010602052816000526040600020818154811061085357600080fd5b6000546001600160a01b03163314610d695760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109e0565b6000828152600e6020526040812054908190036112d95760405162461bcd60e51b815260206004820152601960248201527f5265717565737420616c72656164792066756c66696c6c65640000000000000060448201526064016109e0565b6000818152600360205260408120906005820154600160a81b900460ff1660038111156113085761130861247f565b146113555760405162461bcd60e51b815260206004820152601c60248201527f47616d65206e6f742077616974696e6720666f7220726573756c74730000000060448201526064016109e0565b600381015460008381526011602052604081205460ff16908267ffffffffffffffff81111561138657611386612339565b6040519080825280602002602001820160405280156113d157816020015b60408051606081018252600080825260208083018290529282015282526000199092019101816113a45790505b5060ff83166000908152600f60209081526040808320805482518185028101850190935280835294955092938493919283018282801561143057602002820191906000526020600020905b81548152602001906001019080831161141c575b5050505060ff86166000908152601060209081526040808320805482518185028101850190935280835295965092949093509083018282801561149257602002820191906000526020600020905b81548152602001906001019080831161147e575b5050505050905060005b868110156115e55760008a6000815181106114b9576114b9612776565b6020026020010151826040516020016114dc929190918252602082015260400190565b6040516020818303038152906040528051906020012060001c905060006012548261150791906127d9565b905060005b8860ff168110156115d75784818151811061152957611529612776565b60200260200101518210156115cf578088858151811061154b5761154b612776565b60200260200101516040019060ff16908160ff16815250506000606487838151811061157957611579612776565b60200260200101518d60010154611590919061278c565b61159a9190612762565b9050808986815181106115af576115af612776565b60209081029190910181015101526115c781896127ed565b9750506115d7565b60010161150c565b50505080600101905061149c565b50877f63058c0e59927214eb2eb0e99a45f7f4864777d13d86a856486a8581a993080e856040516116169190612800565b60405180910390a260048088015460008a8152600360208181526040808420848155600181018590556002810185905592830184905594820180546001600160a01b0319169055600590910180546001600160b01b03191690558d8252600e9052918220919091556001600160a01b031683156116f45760065460405163cf8d133f60e01b81526001600160a01b038381166004830152602482018790529091169063cf8d133f90604401600060405180830381600087803b1580156116db57600080fd5b505af11580156116ef573d6000803e3d6000fd5b505050505b5050505050505050505050565b600180546001600160a01b0319169055610de281611e26565b6000600c60008360028111156117325761173261247f565b60028111156117435761174361247f565b81526020810191909152604001600020600101546001600160a01b03169050806117a55760405162461bcd60e51b8152602060048201526013602482015272496e76616c696420565246206164647265737360681b60448201526064016109e0565b8060006001600160a01b038216635d3b1d30600c838760028111156117cc576117cc61247f565b60028111156117dd576117dd61247f565b815260200190815260200160002060000154600c60008860028111156118055761180561247f565b60028111156118165761181661247f565b815260200190815260200160002060010160149054906101000a900467ffffffffffffffff16600d60009054906101000a900461ffff16600c60008a60028111156118635761186361247f565b60028111156118745761187461247f565b81526020810191909152604090810160002060019081015491516001600160e01b031960e088901b168152600481019590955267ffffffffffffffff909316602485015261ffff909116604484015263ffffffff600160e01b909104166064830152608482015260a4016020604051808303816000875af11580156118fd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061192191906127a3565b6000908152600e602052604090209490945550505050565b600480546006546040805163e54c9f6b60e01b815290516000946001600160a01b0361010090950485169486946119c29491163192869263e54c9f6b928082019260209290918290030181865afa158015611998573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119bc91906127a3565b89611e76565b90506064871115611a155760405162461bcd60e51b815260206004820152601c60248201527f4e6f206d6f7265207468616e203130302062616c6c732c206b696e670000000060448201526064016109e0565b60ff86166000908152600f6020526040902054611a445760405162461bcd60e51b81526004016109e090612865565b60ff8616600090815260106020526040902054611a735760405162461bcd60e51b81526004016109e090612865565b60ff86166000908152600f602052604081208054606491908390611a9957611a99612776565b90600052602060002001548360400151611ab3919061278c565b611abd9190612762565b600854600654919250611ad9916001600160a01b031631612762565b811115611b1c5760405162461bcd60e51b815260206004820152601160248201527047616d626c65206c6573732c206b696e6760781b60448201526064016109e0565b60028054906000611b2c836128a8565b9190505550611b39612193565b606081018990523360808201819052600560c0830152604051636431085f60e11b81526001600160a01b0386169163c86210be91611b7c91908b906004016128c1565b602060405180830381865afa158015611b99573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bbd9190612920565b6001600160a01b0390811660a08301526002548252600060e08301819052604085810151602085015260608601518185015260065486519151929316918381818185875af1925050503d8060008114611c32576040519150601f19603f3d011682016040523d82523d6000602084013e611c37565b606091505b5050905080611c4557600080fd5b5080516000908152600360208181526040928390208451815590840151600182015591830151600283015560608301518282015560808301516004830180546001600160a01b039283166001600160a01b031990911617905560a084015160058401805460c087015160ff16600160a01b026001600160a81b031990911692909316919091179190911780825560e085015185949390929160ff60a81b191690600160a81b908490811115611cfc57611cfc61247f565b021790555090505087601160008360000151815260200190815260200160002060006101000a81548160ff021916908360ff1602179055508060000151336001600160a01b03167f758ee7ccbf250272f61109c46cd1a1e69355278f18bb0eb9472f81e98235eceb8360c001518c8c8660a00151876020015188604001518e604051611d8e979695949392919061293d565b60405180910390a36020830151815160a083015160405163919ac7ff60e01b815260048101929092523360248301526001600160a01b03908116604483015286169163919ac7ff916064016000604051808303818588803b158015611df257600080fd5b505af1158015611e06573d6000803e3d6000fd5b5050505050611e1981600001518761171a565b5198975050505050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b611ea86040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b6000611eb6846127106127ed565b611ec23461271061278c565b611ecc9190612762565b90506000611eda8234612995565b9050600754821015611f225760405162461bcd60e51b815260206004820152601160248201527023b0b6b136329036b7b9329610383632b160791b60448201526064016109e0565b600854611f2f9087612762565b821115611f725760405162461bcd60e51b815260206004820152601160248201527047616d626c65206c6573732c206b696e6760781b60448201526064016109e0565b60008411611fc25760405162461bcd60e51b815260206004820152601a60248201527f47616d626c65206174206c65617374206f6e63652c20706c656200000000000060448201526064016109e0565b6009548411156120145760405162461bcd60e51b815260206004820152601860248201527f47616d626c652066657765722074696d65732c206b696e67000000000000000060448201526064016109e0565b60006120208584612762565b905061202c85846127d9565b1561208f5760405162461bcd60e51b815260206004820152602d60248201527f47616d626c6520616e20616d6f756e7420646976697369626c6520627920796f60448201526c3ab9103132ba399610383632b160991b60648201526084016109e0565b600a5461209c90826127d9565b156120f75760405162461bcd60e51b815260206004820152602560248201527f47616d626c652074686520726967687420616d6f756e7420706572206265742c60448201526410383632b160d91b60648201526084016109e0565b60006121038684612762565b905061210f86846127d9565b156121665760405162461bcd60e51b815260206004820152602160248201527f496e7465726e616c206572726f723b2077726f6e672072616b6520616d6f756e6044820152601d60fa1b60648201526084016109e0565b6040805160a081018252948552602085019390935291830152606082015260006080820152949350505050565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c081018290529060e082015290565b6000602082840312156121e757600080fd5b5035919050565b803560ff811681146121ff57600080fd5b919050565b6000806040838503121561221757600080fd5b612220836121ee565b946020939093013593505050565b8015158114610de257600080fd5b60006020828403121561224e57600080fd5b81356122598161222e565b9392505050565b8035600381106121ff57600080fd5b6001600160a01b0381168114610de257600080fd5b600080600080600060a0868803121561229c57600080fd5b6122a586612260565b94506020860135935060408601356122bc8161226f565b9250606086013567ffffffffffffffff811681146122d957600080fd5b9150608086013563ffffffff811681146122f257600080fd5b809150509295509295909350565b6000806040838503121561231357600080fd5b823561231e8161226f565b9150602083013561232e8161222e565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561237857612378612339565b604052919050565b600082601f83011261239157600080fd5b8135602067ffffffffffffffff8211156123ad576123ad612339565b8160051b6123bc82820161234f565b92835284810182019282810190878511156123d657600080fd5b83870192505b848310156123f5578235825291830191908301906123dc565b979650505050505050565b6000806040838503121561241357600080fd5b82359150602083013567ffffffffffffffff81111561243157600080fd5b61243d85828601612380565b9150509250929050565b60006020828403121561245957600080fd5b81356122598161226f565b60006020828403121561247657600080fd5b612259826121ee565b634e487b7160e01b600052602160045260246000fd5b60048110610de257610de261247f565b80518252602081015160208301526040810151604083015260608101516060830152608081015160018060a01b0380821660808501528060a08401511660a0850152505060ff60c08201511660c083015260e081015161250481612495565b8060e0840152505050565b610100810161251e82846124a5565b92915050565b60006020828403121561253657600080fd5b813567ffffffffffffffff81111561254d57600080fd5b610ab584828501612380565b6020808252825182820181905260009190848201906040850190845b8181101561259c576125888385516124a5565b928401926101009290920191600101612575565b50909695505050505050565b8881526020810188905260408101879052606081018690526001600160a01b038581166080830152841660a082015260ff831660c082015261010081016125ee83612495565b8260e08301529998505050505050505050565b60006020828403121561261357600080fd5b813561ffff8116811461225957600080fd5b6000806040838503121561263857600080fd5b8235915061264860208401612260565b90509250929050565b6000806040838503121561266457600080fd5b82356122208161226f565b6000806000806080858703121561268557600080fd5b61268e856121ee565b9350602061269d8187016121ee565b9350604086013567ffffffffffffffff808211156126ba57600080fd5b818801915088601f8301126126ce57600080fd5b8135818111156126e0576126e0612339565b6126f2601f8201601f1916850161234f565b9150808252898482850101111561270857600080fd5b808484018584013760008482840101525080945050505061272b60608601612260565b905092959194509250565b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60008261277157612771612736565b500490565b634e487b7160e01b600052603260045260246000fd5b808202811582820484141761251e5761251e61274c565b6000602082840312156127b557600080fd5b5051919050565b6000602082840312156127ce57600080fd5b81516122598161222e565b6000826127e8576127e8612736565b500690565b8082018082111561251e5761251e61274c565b602080825282518282018190526000919060409081850190868401855b82811015612858578151805161283281612495565b8552808701518786015285015160ff16858501526060909301929085019060010161281d565b5091979650505050505050565b60208082526023908201527f55736520616e20657870656374656420636f6e66696775726174696f6e2c20706040820152623632b160e91b606082015260800190565b6000600182016128ba576128ba61274c565b5060010190565b60018060a01b03831681526000602060406020840152835180604085015260005b818110156128fe578581018301518582016060015282016128e2565b506000606082860101526060601f19601f830116850101925050509392505050565b60006020828403121561293257600080fd5b81516122598161226f565b60ff888116825260208201889052861660408201526001600160a01b03851660608201526080810184905260a0810183905260e08101600383106129835761298361247f565b8260c083015298975050505050505050565b8181038181111561251e5761251e61274c56fea26469706673582212204dbc4cab83e929999d0e54c02b2590b11e06120a30a108ffcba4158dda588d7b64736f6c63430008160033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
Loading...
Loading
[ 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.