Polygon Sponsored slots available. Book your slot here!
More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 4,760 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Claim Bonus | 65166070 | 1 min ago | IN | 0 POL | 0.00139491 | ||||
Claim Bonus | 65165854 | 9 mins ago | IN | 0 POL | 0.00138655 | ||||
Claim Bonus | 65165591 | 18 mins ago | IN | 0 POL | 0.00141416 | ||||
Claim Bonus | 65165353 | 27 mins ago | IN | 0 POL | 0.00144203 | ||||
Claim Bonus | 65165229 | 32 mins ago | IN | 0 POL | 0.00140649 | ||||
Claim Bonus | 65165155 | 34 mins ago | IN | 0 POL | 0.0014227 | ||||
Claim Bonus | 65165128 | 35 mins ago | IN | 0 POL | 0.00141864 | ||||
Claim Bonus | 65164822 | 46 mins ago | IN | 0 POL | 0.00137043 | ||||
Claim Bonus | 65164588 | 55 mins ago | IN | 0 POL | 0.00137378 | ||||
Claim Bonus | 65164328 | 1 hr ago | IN | 0 POL | 0.00137333 | ||||
Claim Bonus | 65162788 | 2 hrs ago | IN | 0 POL | 0.0013326 | ||||
Claim Bonus | 65162616 | 2 hrs ago | IN | 0 POL | 0.00148848 | ||||
Claim Bonus | 65162560 | 2 hrs ago | IN | 0 POL | 0.00148305 | ||||
Claim Bonus | 65162186 | 2 hrs ago | IN | 0 POL | 0.00172383 | ||||
Claim Bonus | 65161957 | 2 hrs ago | IN | 0 POL | 0.00153866 | ||||
Claim Bonus | 65160994 | 3 hrs ago | IN | 0 POL | 0.00186385 | ||||
Claim Bonus | 65160916 | 3 hrs ago | IN | 0 POL | 0.00207921 | ||||
Claim Bonus | 65160365 | 3 hrs ago | IN | 0 POL | 0.0030111 | ||||
Claim Bonus | 65160229 | 3 hrs ago | IN | 0 POL | 0.00318132 | ||||
Claim Bonus | 65159985 | 3 hrs ago | IN | 0 POL | 0.00304754 | ||||
Claim Bonus | 65159439 | 4 hrs ago | IN | 0 POL | 0.00311253 | ||||
Claim Bonus | 65159161 | 4 hrs ago | IN | 0 POL | 0.00306067 | ||||
Claim Bonus | 65159002 | 4 hrs ago | IN | 0 POL | 0.00399218 | ||||
Claim Bonus | 65158882 | 4 hrs ago | IN | 0 POL | 0.00304819 | ||||
Claim Bonus | 65158666 | 4 hrs ago | IN | 0 POL | 0.00303564 |
Latest 25 internal transactions (View All)
Loading...
Loading
Contract Name:
LuckyRound
Compiler Version
v0.8.19+commit.7dd6d404
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.19; import "chainlink/vrf/dev/VRFCoordinatorV2_5.sol"; import "chainlink/vrf/dev/VRFConsumerBaseV2Plus.sol"; import "openzeppelin/access/AccessControl.sol"; import "openzeppelin/token/ERC20/IERC20.sol"; import "openzeppelin/token/ERC20/utils/SafeERC20.sol"; import "openzeppelin/security/ReentrancyGuard.sol"; import "./shared/CoreInterface.sol"; import "./shared/games/GameInterface.sol"; import "./LuckyRoundBet.sol"; /** * Errors used in this contract * * L01 - invalid staking contract * L02 - player address mismatch * L03 - amount mismatch * L04 - round mismatch * L05 - amount too low * L06 - new amount out of range * L07 - round is full * L08 - round already distributed * L09 - round not finished * L10 - round already requested * L11 - round is empty * L12 - round is not finished, * L13 - only core can place bets * L14 - error when tranfering tokens */ contract LuckyRound is AccessControl, GameInterface, VRFConsumerBaseV2Plus, ReentrancyGuard { using SafeERC20 for IERC20; bytes32 public constant TIMELOCK = keccak256("TIMELOCK"); bytes32 public constant SERVICE = keccak256("SERVICE"); uint256 public constant ROUND_DURATION = 5 minutes; uint256 public constant BETS_LIMIT = 1000; uint256 public constant BONUS = 5_00; uint256 public MIN_BET_AMOUNT = 1000 ether; uint256 public immutable created; address public immutable core; address public immutable token; address public immutable staking; uint256 private immutable subscriptionId; address public immutable vrfCoordinator; bytes32 public immutable keyHash; uint32 private constant callbackGasLimit = 2_500_000; uint16 public constant requestConfirmations = 3; uint32 private constant numWords = 1; uint256 internal immutable fee; mapping(uint256 => uint256) public roundBank; mapping(uint256 => uint256) public roundPlayersCount; mapping(uint256 => mapping(address => bool)) public isRoundPlayer; mapping(address => uint256[]) public playersRounds; mapping(uint256 => LuckyRoundBet[]) public roundBets; mapping(address => uint256) public claimableBonus; mapping(uint256 => uint256) public roundRequests; mapping(uint256 => uint256) public requestRounds; mapping(uint256 => uint256) public roundBonusShares; mapping(address => address) public betsPlayer; mapping(uint256 => mapping(address => uint256)) public roundPlayerVolume; mapping(uint256 => mapping(address => uint256)) public roundPlayerBetsCount; // 0 - pending // 1 - waiting result // 2 - finished mapping(uint256 => uint8) public roundStatus; mapping(uint256 => uint256) public roundWinners; mapping(uint256 => bool) public roundDistribution; mapping(uint256 => uint256) public distributedBetCount; mapping(uint256 => mapping(address => bool)) public roundBetDistributed; mapping(uint256 => uint256) public lastOffset; event RequestedCalculation( uint256 indexed round, uint256 indexed requestId ); event WinnerCalculated( uint256 indexed round, uint256 indexed winnerOffset, address indexed bet ); event BonusClaimed(address indexed player, uint256 indexed amount); event BetCreated( address indexed player, uint256 indexed round, uint256 amount ); event RoundStart(uint256 indexed round, uint256 indexed timestamp); constructor( address _core, address _staking, address _admin, uint256 _subscriptionId, address _vrfCoordinator, bytes32 _keyHash ) VRFConsumerBaseV2Plus(_vrfCoordinator) { require(_vrfCoordinator != address(0), "RO01"); vrfCoordinator = _vrfCoordinator; keyHash = _keyHash; subscriptionId = _subscriptionId; created = block.timestamp; core = _core; token = CoreInterface(_core).token(); require(CoreInterface(_core).isStaking(_staking), "L01"); staking = _staking; fee = CoreInterface(core).fee(); _grantRole(DEFAULT_ADMIN_ROLE, _admin); } function getBetsCount(uint round) public view returns (uint256) { return roundBets[round].length; } function getPlayersRoundsCount( address player ) public view returns (uint256) { return playersRounds[player].length; } function placeBet( address _player, uint256 _totalAmount, bytes calldata _data ) external override returns (address) { require(msg.sender == core, "L13"); // parse data (address player, uint256 amount, uint256 round) = abi.decode( _data, (address, uint256, uint256) ); // revert if player is not the same require(player == _player, "L02"); // revert if amount is not whole require(amount * 10 ** 18 == _totalAmount, "L03"); // revert if amount is too low require(_totalAmount >= MIN_BET_AMOUNT, "L05"); // revert if round is not the same require(round == getCurrentRound(), "L04"); // revert if round is full require((getBetsCount(round) + 1) <= BETS_LIMIT, "L07"); // revert if round is already started require(roundStatus[round] == 0, "L10"); // calculate startOffset uint256 prevOffset = lastOffset[round] + 1; // update lastOffset lastOffset[round] += amount; // create bet LuckyRoundBet bet = new LuckyRoundBet( player, address(this), _totalAmount, round, prevOffset, lastOffset[round] ); // push bet to roundBets roundBets[round].push(bet); // mark player as active in this round and increment roundPlayers if (!isRoundPlayer[round][player]) { isRoundPlayer[round][player] = true; roundPlayersCount[round]++; playersRounds[player].push(round); } // update player's volume on this round roundPlayerVolume[round][player] += _totalAmount; roundPlayerBetsCount[round][player]++; // update round's bank roundBank[round] += _totalAmount; roundBonusShares[round] += roundBank[round]; betsPlayer[address(bet)] = player; if (getBetsCount(round) == BETS_LIMIT) { requestCalculationInternal(round); } emit BetCreated(player, round, _totalAmount); if (getBetsCount(round) == 1) { emit RoundStart(round, block.timestamp); } return address(bet); } function requestCalculation(uint256 round) public { require(round < getCurrentRound(), "L09"); require(roundStatus[round] == 0, "L10"); require(getBetsCount(round) > 0, "L11"); requestCalculationInternal(round); } function requestCalculationInternal(uint256 round) internal nonReentrant { uint256 requestId = VRFCoordinatorV2_5(vrfCoordinator) .requestRandomWords( VRFV2PlusClient.RandomWordsRequest({ keyHash: keyHash, subId: subscriptionId, requestConfirmations: requestConfirmations, callbackGasLimit: callbackGasLimit, numWords: numWords, extraArgs: VRFV2PlusClient._argsToBytes( VRFV2PlusClient.ExtraArgsV1({nativePayment: false}) ) }) ); roundRequests[round] = requestId; requestRounds[requestId] = round; roundStatus[round] = 1; emit RequestedCalculation(round, requestId); } function fulfillRandomWords( uint256 requestId, uint256[] calldata randomWords ) internal override { uint256 round = requestRounds[requestId]; uint256 winnerOffset = (randomWords[0] % lastOffset[round]) + 1; // exclude 0 roundWinners[round] = winnerOffset; executeResult(round); roundStatus[round] = 2; } function executeResult(uint256 round) internal nonReentrant { uint256 winnerOffset = roundWinners[round]; LuckyRoundBet[] storage bets = roundBets[round]; // find using binary search uint256 low = 0; uint256 high = bets.length - 1; while (low <= high) { uint256 mid = (low + high) / 2; LuckyRoundBet bet = bets[mid]; uint256 start = bet.getStartOffset(); uint256 end = bet.getEndOffset(); if (start <= winnerOffset && end >= winnerOffset) { uint256 bank = roundBank[round]; // calculate bonus fee uint256 bonus = (bank * BONUS) / 100_00; // calculate reward uint reward = bank - ((bank * fee) / 100_00) - bonus; // transfer reward to player require(IERC20(token).transfer(bet.getPlayer(), reward), "L14"); emit WinnerCalculated(round, winnerOffset, address(bet)); break; } else if (end < winnerOffset) { low = mid + 1; } else { high = mid - 1; } } } function distribute(uint256 round, uint256 offset, uint256 limit) external { require(round < getCurrentRound(), "L09"); require(roundStatus[round] == 2, "L12"); require(roundDistribution[round] == false, "L08"); LuckyRoundBet[] storage bets = roundBets[round]; uint256 winnerOffset = roundWinners[round]; uint256 bonusShares = roundBonusShares[round]; uint256 bonus = (roundBank[round] * BONUS) / 100_00; for (uint256 i = offset; i < offset + limit; i++) { if (i >= bets.length) break; LuckyRoundBet bet = bets[i]; if (roundBetDistributed[round][address(bet)]) continue; address player = betsPlayer[address(bet)]; uint256 playerShare = bet.getAmount() * (bets.length - i); uint256 playerBonus = (bonus * playerShare) / bonusShares; claimableBonus[player] += playerBonus; roundBetDistributed[round][address(bet)] = true; bet.setResult(winnerOffset); distributedBetCount[round]++; } if (distributedBetCount[round] == roundBets[round].length) { roundDistribution[round] = true; } } function claimBonus(address player) external { require( _msgSender() == player || hasRole(SERVICE, _msgSender()), "L02" ); uint bonus = claimableBonus[player]; claimableBonus[player] = 0; require(IERC20(token).transfer(player, bonus), "L14"); emit BonusClaimed(player, bonus); } function addService(address _service) external onlyRole(TIMELOCK) { _grantRole(SERVICE, _service); } function getCurrentRound() public view returns (uint256) { return block.timestamp / ROUND_DURATION; } function getAddress() public view override returns (address) { return address(this); } function getVersion() public view override returns (uint256) { return created; } function getFeeType() public pure override returns (uint256) { return 0; } function getStaking() public view override returns (address) { return staking; } function setMinBetAmount(uint256 _amount) external onlyRole(TIMELOCK) { require(_amount > 1 ether && _amount < 1_000_000 ether, "L06"); MIN_BET_AMOUNT = _amount; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.19; import {BlockhashStoreInterface} from "../interfaces/BlockhashStoreInterface.sol"; import {VRF} from "../../vrf/VRF.sol"; import {VRFTypes} from "../VRFTypes.sol"; import {VRFConsumerBaseV2Plus, IVRFMigratableConsumerV2Plus} from "./VRFConsumerBaseV2Plus.sol"; import {ChainSpecificUtil} from "../../ChainSpecificUtil.sol"; import {SubscriptionAPI} from "./SubscriptionAPI.sol"; import {VRFV2PlusClient} from "./libraries/VRFV2PlusClient.sol"; import {IVRFCoordinatorV2PlusMigration} from "./interfaces/IVRFCoordinatorV2PlusMigration.sol"; // solhint-disable-next-line no-unused-import import {IVRFCoordinatorV2Plus, IVRFSubscriptionV2Plus} from "./interfaces/IVRFCoordinatorV2Plus.sol"; // solhint-disable-next-line contract-name-camelcase contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus { /// @dev should always be available // solhint-disable-next-line chainlink-solidity/prefix-immutable-variables-with-i BlockhashStoreInterface public immutable BLOCKHASH_STORE; // Set this maximum to 200 to give us a 56 block window to fulfill // the request before requiring the block hash feeder. uint16 public constant MAX_REQUEST_CONFIRMATIONS = 200; uint32 public constant MAX_NUM_WORDS = 500; // 5k is plenty for an EXTCODESIZE call (2600) + warm CALL (100) // and some arithmetic operations. uint256 private constant GAS_FOR_CALL_EXACT_CHECK = 5_000; // upper bound limit for premium percentages to make sure fee calculations don't overflow uint8 private constant PREMIUM_PERCENTAGE_MAX = 155; error InvalidRequestConfirmations(uint16 have, uint16 min, uint16 max); error GasLimitTooBig(uint32 have, uint32 want); error NumWordsTooBig(uint32 have, uint32 want); error MsgDataTooBig(uint256 have, uint32 max); error ProvingKeyAlreadyRegistered(bytes32 keyHash); error NoSuchProvingKey(bytes32 keyHash); error InvalidLinkWeiPrice(int256 linkWei); error LinkDiscountTooHigh(uint32 flatFeeLinkDiscountPPM, uint32 flatFeeNativePPM); error InvalidPremiumPercentage(uint8 premiumPercentage, uint8 max); error NoCorrespondingRequest(); error IncorrectCommitment(); error BlockhashNotInStore(uint256 blockNum); error PaymentTooLarge(); error InvalidExtraArgsTag(); error GasPriceExceeded(uint256 gasPrice, uint256 maxGas); struct ProvingKey { bool exists; // proving key exists uint64 maxGas; // gas lane max gas price for fulfilling requests } mapping(bytes32 => ProvingKey) /* keyHash */ /* provingKey */ public s_provingKeys; bytes32[] public s_provingKeyHashes; mapping(uint256 => bytes32) /* requestID */ /* commitment */ public s_requestCommitments; event ProvingKeyRegistered(bytes32 keyHash, uint64 maxGas); event ProvingKeyDeregistered(bytes32 keyHash, uint64 maxGas); event RandomWordsRequested( bytes32 indexed keyHash, uint256 requestId, uint256 preSeed, uint256 indexed subId, uint16 minimumRequestConfirmations, uint32 callbackGasLimit, uint32 numWords, bytes extraArgs, address indexed sender ); event RandomWordsFulfilled( uint256 indexed requestId, uint256 outputSeed, uint256 indexed subId, uint96 payment, bool nativePayment, bool success, bool onlyPremium ); int256 public s_fallbackWeiPerUnitLink; event ConfigSet( uint16 minimumRequestConfirmations, uint32 maxGasLimit, uint32 stalenessSeconds, uint32 gasAfterPaymentCalculation, int256 fallbackWeiPerUnitLink, uint32 fulfillmentFlatFeeNativePPM, uint32 fulfillmentFlatFeeLinkDiscountPPM, uint8 nativePremiumPercentage, uint8 linkPremiumPercentage ); event FallbackWeiPerUnitLinkUsed(uint256 requestId, int256 fallbackWeiPerUnitLink); constructor(address blockhashStore) SubscriptionAPI() { BLOCKHASH_STORE = BlockhashStoreInterface(blockhashStore); } /** * @notice Registers a proving key to. * @param publicProvingKey key that oracle can use to submit vrf fulfillments */ function registerProvingKey(uint256[2] calldata publicProvingKey, uint64 maxGas) external onlyOwner { bytes32 kh = hashOfKey(publicProvingKey); if (s_provingKeys[kh].exists) { revert ProvingKeyAlreadyRegistered(kh); } s_provingKeys[kh] = ProvingKey({exists: true, maxGas: maxGas}); s_provingKeyHashes.push(kh); emit ProvingKeyRegistered(kh, maxGas); } /** * @notice Deregisters a proving key. * @param publicProvingKey key that oracle can use to submit vrf fulfillments */ function deregisterProvingKey(uint256[2] calldata publicProvingKey) external onlyOwner { bytes32 kh = hashOfKey(publicProvingKey); ProvingKey memory key = s_provingKeys[kh]; if (!key.exists) { revert NoSuchProvingKey(kh); } delete s_provingKeys[kh]; uint256 s_provingKeyHashesLength = s_provingKeyHashes.length; for (uint256 i = 0; i < s_provingKeyHashesLength; ++i) { if (s_provingKeyHashes[i] == kh) { // Copy last element and overwrite kh to be deleted with it s_provingKeyHashes[i] = s_provingKeyHashes[s_provingKeyHashesLength - 1]; s_provingKeyHashes.pop(); break; } } emit ProvingKeyDeregistered(kh, key.maxGas); } /** * @notice Returns the proving key hash key associated with this public key * @param publicKey the key to return the hash of */ function hashOfKey(uint256[2] memory publicKey) public pure returns (bytes32) { return keccak256(abi.encode(publicKey)); } /** * @notice Sets the configuration of the vrfv2 coordinator * @param minimumRequestConfirmations global min for request confirmations * @param maxGasLimit global max for request gas limit * @param stalenessSeconds if the native/link feed is more stale then this, use the fallback price * @param gasAfterPaymentCalculation gas used in doing accounting after completing the gas measurement * @param fallbackWeiPerUnitLink fallback native/link price in the case of a stale feed * @param fulfillmentFlatFeeNativePPM flat fee in native for native payment * @param fulfillmentFlatFeeLinkDiscountPPM flat fee discount for link payment in native * @param nativePremiumPercentage native premium percentage * @param linkPremiumPercentage link premium percentage */ function setConfig( uint16 minimumRequestConfirmations, uint32 maxGasLimit, uint32 stalenessSeconds, uint32 gasAfterPaymentCalculation, int256 fallbackWeiPerUnitLink, uint32 fulfillmentFlatFeeNativePPM, uint32 fulfillmentFlatFeeLinkDiscountPPM, uint8 nativePremiumPercentage, uint8 linkPremiumPercentage ) external onlyOwner { if (minimumRequestConfirmations > MAX_REQUEST_CONFIRMATIONS) { revert InvalidRequestConfirmations( minimumRequestConfirmations, minimumRequestConfirmations, MAX_REQUEST_CONFIRMATIONS ); } if (fallbackWeiPerUnitLink <= 0) { revert InvalidLinkWeiPrice(fallbackWeiPerUnitLink); } if (fulfillmentFlatFeeLinkDiscountPPM > fulfillmentFlatFeeNativePPM) { revert LinkDiscountTooHigh(fulfillmentFlatFeeLinkDiscountPPM, fulfillmentFlatFeeNativePPM); } if (nativePremiumPercentage > PREMIUM_PERCENTAGE_MAX) { revert InvalidPremiumPercentage(nativePremiumPercentage, PREMIUM_PERCENTAGE_MAX); } if (linkPremiumPercentage > PREMIUM_PERCENTAGE_MAX) { revert InvalidPremiumPercentage(linkPremiumPercentage, PREMIUM_PERCENTAGE_MAX); } s_config = Config({ minimumRequestConfirmations: minimumRequestConfirmations, maxGasLimit: maxGasLimit, stalenessSeconds: stalenessSeconds, gasAfterPaymentCalculation: gasAfterPaymentCalculation, reentrancyLock: false, fulfillmentFlatFeeNativePPM: fulfillmentFlatFeeNativePPM, fulfillmentFlatFeeLinkDiscountPPM: fulfillmentFlatFeeLinkDiscountPPM, nativePremiumPercentage: nativePremiumPercentage, linkPremiumPercentage: linkPremiumPercentage }); s_fallbackWeiPerUnitLink = fallbackWeiPerUnitLink; emit ConfigSet( minimumRequestConfirmations, maxGasLimit, stalenessSeconds, gasAfterPaymentCalculation, fallbackWeiPerUnitLink, fulfillmentFlatFeeNativePPM, fulfillmentFlatFeeLinkDiscountPPM, nativePremiumPercentage, linkPremiumPercentage ); } /// @dev Convert the extra args bytes into a struct /// @param extraArgs The extra args bytes /// @return The extra args struct function _fromBytes(bytes calldata extraArgs) internal pure returns (VRFV2PlusClient.ExtraArgsV1 memory) { if (extraArgs.length == 0) { return VRFV2PlusClient.ExtraArgsV1({nativePayment: false}); } if (bytes4(extraArgs) != VRFV2PlusClient.EXTRA_ARGS_V1_TAG) revert InvalidExtraArgsTag(); return abi.decode(extraArgs[4:], (VRFV2PlusClient.ExtraArgsV1)); } /** * @notice Request a set of random words. * @param req - a struct containing following fiels for randomness request: * 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. * subId - The ID of the VRF subscription. Must be funded * with the minimum subscription balance required for the selected keyHash. * requestConfirmations - 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]. * 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] * 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. * extraArgs - Encoded extra arguments that has a boolean flag for whether payment * should be made in native or LINK. Payment in LINK is only available if the LINK token is available to this contract. * @return requestId - A unique identifier of the request. Can be used to match * a request to a response in fulfillRandomWords. */ function requestRandomWords( VRFV2PlusClient.RandomWordsRequest calldata req ) external override nonReentrant returns (uint256 requestId) { // Input validation using the subscription storage. uint256 subId = req.subId; if (s_subscriptionConfigs[subId].owner == address(0)) { revert InvalidSubscription(); } // Its important to ensure that the consumer is in fact who they say they // are, otherwise they could use someone else's subscription balance. mapping(uint256 => ConsumerConfig) storage consumerConfigs = s_consumers[msg.sender]; ConsumerConfig memory consumerConfig = consumerConfigs[subId]; if (!consumerConfig.active) { revert InvalidConsumer(subId, msg.sender); } // Input validation using the config storage word. if ( req.requestConfirmations < s_config.minimumRequestConfirmations || req.requestConfirmations > MAX_REQUEST_CONFIRMATIONS ) { revert InvalidRequestConfirmations( req.requestConfirmations, s_config.minimumRequestConfirmations, MAX_REQUEST_CONFIRMATIONS ); } // No lower bound on the requested gas limit. A user could request 0 // and they would simply be billed for the proof verification and wouldn't be // able to do anything with the random value. if (req.callbackGasLimit > s_config.maxGasLimit) { revert GasLimitTooBig(req.callbackGasLimit, s_config.maxGasLimit); } if (req.numWords > MAX_NUM_WORDS) { revert NumWordsTooBig(req.numWords, MAX_NUM_WORDS); } // Note we do not check whether the keyHash is valid to save gas. // The consequence for users is that they can send requests // for invalid keyHashes which will simply not be fulfilled. ++consumerConfig.nonce; ++consumerConfig.pendingReqCount; uint256 preSeed; (requestId, preSeed) = _computeRequestId(req.keyHash, msg.sender, subId, consumerConfig.nonce); bytes memory extraArgsBytes = VRFV2PlusClient._argsToBytes(_fromBytes(req.extraArgs)); s_requestCommitments[requestId] = keccak256( abi.encode( requestId, ChainSpecificUtil._getBlockNumber(), subId, req.callbackGasLimit, req.numWords, msg.sender, extraArgsBytes ) ); emit RandomWordsRequested( req.keyHash, requestId, preSeed, subId, req.requestConfirmations, req.callbackGasLimit, req.numWords, extraArgsBytes, msg.sender ); consumerConfigs[subId] = consumerConfig; return requestId; } function _computeRequestId( bytes32 keyHash, address sender, uint256 subId, uint64 nonce ) internal pure returns (uint256, uint256) { uint256 preSeed = uint256(keccak256(abi.encode(keyHash, sender, subId, nonce))); return (uint256(keccak256(abi.encode(keyHash, preSeed))), preSeed); } /** * @dev calls target address with exactly gasAmount gas and data as calldata * or reverts if at least gasAmount gas is not available. */ function _callWithExactGas(uint256 gasAmount, address target, bytes memory data) private returns (bool success) { assembly { let g := gas() // Compute g -= GAS_FOR_CALL_EXACT_CHECK and check for underflow // The gas actually passed to the callee is min(gasAmount, 63//64*gas available). // We want to ensure that we revert if gasAmount > 63//64*gas available // as we do not want to provide them with less, however that check itself costs // gas. GAS_FOR_CALL_EXACT_CHECK ensures we have at least enough gas to be able // to revert if gasAmount > 63//64*gas available. if lt(g, GAS_FOR_CALL_EXACT_CHECK) { revert(0, 0) } g := sub(g, GAS_FOR_CALL_EXACT_CHECK) // if g - g//64 <= gasAmount, revert // (we subtract g//64 because of EIP-150) if iszero(gt(sub(g, div(g, 64)), gasAmount)) { revert(0, 0) } // solidity calls check that a contract actually exists at the destination, so we do the same if iszero(extcodesize(target)) { revert(0, 0) } // call and return whether we succeeded. ignore return data // call(gas,addr,value,argsOffset,argsLength,retOffset,retLength) success := call(gasAmount, target, 0, add(data, 0x20), mload(data), 0, 0) } return success; } struct Output { ProvingKey provingKey; uint256 requestId; uint256 randomness; } function _getRandomnessFromProof( Proof memory proof, VRFTypes.RequestCommitmentV2Plus memory rc ) internal view returns (Output memory) { bytes32 keyHash = hashOfKey(proof.pk); ProvingKey memory key = s_provingKeys[keyHash]; // Only registered proving keys are permitted. if (!key.exists) { revert NoSuchProvingKey(keyHash); } uint256 requestId = uint256(keccak256(abi.encode(keyHash, proof.seed))); bytes32 commitment = s_requestCommitments[requestId]; if (commitment == 0) { revert NoCorrespondingRequest(); } if ( commitment != keccak256(abi.encode(requestId, rc.blockNum, rc.subId, rc.callbackGasLimit, rc.numWords, rc.sender, rc.extraArgs)) ) { revert IncorrectCommitment(); } bytes32 blockHash = ChainSpecificUtil._getBlockhash(rc.blockNum); if (blockHash == bytes32(0)) { blockHash = BLOCKHASH_STORE.getBlockhash(rc.blockNum); if (blockHash == bytes32(0)) { revert BlockhashNotInStore(rc.blockNum); } } // The seed actually used by the VRF machinery, mixing in the blockhash uint256 actualSeed = uint256(keccak256(abi.encodePacked(proof.seed, blockHash))); uint256 randomness = VRF._randomValueFromVRFProof(proof, actualSeed); // Reverts on failure return Output(key, requestId, randomness); } function _getValidatedGasPrice(bool onlyPremium, uint64 gasLaneMaxGas) internal view returns (uint256 gasPrice) { if (tx.gasprice > gasLaneMaxGas) { if (onlyPremium) { // if only the premium amount needs to be billed, then the premium is capped by the gas lane max return uint256(gasLaneMaxGas); } else { // Ensure gas price does not exceed the gas lane max gas price revert GasPriceExceeded(tx.gasprice, gasLaneMaxGas); } } return tx.gasprice; } function _deliverRandomness( uint256 requestId, VRFTypes.RequestCommitmentV2Plus memory rc, uint256[] memory randomWords ) internal returns (bool success) { VRFConsumerBaseV2Plus v; bytes memory resp = abi.encodeWithSelector(v.rawFulfillRandomWords.selector, requestId, randomWords); // Call with explicitly the amount of callback gas requested // Important to not let them exhaust the gas budget and avoid oracle payment. // Do not allow any non-view/non-pure coordinator functions to be called // during the consumers callback code via reentrancyLock. // Note that _callWithExactGas will revert if we do not have sufficient gas // to give the callee their requested amount. s_config.reentrancyLock = true; success = _callWithExactGas(rc.callbackGasLimit, rc.sender, resp); s_config.reentrancyLock = false; return success; } /* * @notice Fulfill a randomness request. * @param proof contains the proof and randomness * @param rc request commitment pre-image, committed to at request time * @param onlyPremium only charge premium * @return payment amount billed to the subscription * @dev simulated offchain to determine if sufficient balance is present to fulfill the request */ function fulfillRandomWords( Proof memory proof, VRFTypes.RequestCommitmentV2Plus memory rc, bool onlyPremium ) external nonReentrant returns (uint96 payment) { uint256 startGas = gasleft(); // fulfillRandomWords msg.data has 772 bytes and with an additional // buffer of 32 bytes, we get 804 bytes. /* Data size split: * fulfillRandomWords function signature - 4 bytes * proof - 416 bytes * pk - 64 bytes * gamma - 64 bytes * c - 32 bytes * s - 32 bytes * seed - 32 bytes * uWitness - 32 bytes * cGammaWitness - 64 bytes * sHashWitness - 64 bytes * zInv - 32 bytes * requestCommitment - 320 bytes * blockNum - 32 bytes * subId - 32 bytes * callbackGasLimit - 32 bytes * numWords - 32 bytes * sender - 32 bytes * extraArgs - 128 bytes * onlyPremium - 32 bytes */ if (msg.data.length > 804) { revert MsgDataTooBig(msg.data.length, 804); } Output memory output = _getRandomnessFromProof(proof, rc); uint256 gasPrice = _getValidatedGasPrice(onlyPremium, output.provingKey.maxGas); uint256[] memory randomWords; uint256 randomness = output.randomness; // stack too deep error { uint256 numWords = rc.numWords; randomWords = new uint256[](numWords); for (uint256 i = 0; i < numWords; ++i) { randomWords[i] = uint256(keccak256(abi.encode(randomness, i))); } } delete s_requestCommitments[output.requestId]; bool success = _deliverRandomness(output.requestId, rc, randomWords); // Increment the req count for the subscription. ++s_subscriptions[rc.subId].reqCount; // Decrement the pending req count for the consumer. --s_consumers[rc.sender][rc.subId].pendingReqCount; bool nativePayment = uint8(rc.extraArgs[rc.extraArgs.length - 1]) == 1; // stack too deep error { // We want to charge users exactly for how much gas they use in their callback with // an additional premium. If onlyPremium is true, only premium is charged without // the gas cost. The gasAfterPaymentCalculation is meant to cover these additional // operations where we decrement the subscription balance and increment the // withdrawable balance. bool isFeedStale; (payment, isFeedStale) = _calculatePaymentAmount(startGas, gasPrice, nativePayment, onlyPremium); if (isFeedStale) { emit FallbackWeiPerUnitLinkUsed(output.requestId, s_fallbackWeiPerUnitLink); } } _chargePayment(payment, nativePayment, rc.subId); // Include payment in the event for tracking costs. emit RandomWordsFulfilled(output.requestId, randomness, rc.subId, payment, nativePayment, success, onlyPremium); return payment; } function _chargePayment(uint96 payment, bool nativePayment, uint256 subId) internal { Subscription storage subcription = s_subscriptions[subId]; if (nativePayment) { uint96 prevBal = subcription.nativeBalance; if (prevBal < payment) { revert InsufficientBalance(); } subcription.nativeBalance = prevBal - payment; s_withdrawableNative += payment; } else { uint96 prevBal = subcription.balance; if (prevBal < payment) { revert InsufficientBalance(); } subcription.balance = prevBal - payment; s_withdrawableTokens += payment; } } function _calculatePaymentAmount( uint256 startGas, uint256 weiPerUnitGas, bool nativePayment, bool onlyPremium ) internal view returns (uint96, bool) { if (nativePayment) { return (_calculatePaymentAmountNative(startGas, weiPerUnitGas, onlyPremium), false); } return _calculatePaymentAmountLink(startGas, weiPerUnitGas, onlyPremium); } function _calculatePaymentAmountNative( uint256 startGas, uint256 weiPerUnitGas, bool onlyPremium ) internal view returns (uint96) { // Will return non-zero on chains that have this enabled uint256 l1CostWei = ChainSpecificUtil._getCurrentTxL1GasFees(msg.data); // calculate the payment without the premium uint256 baseFeeWei = weiPerUnitGas * (s_config.gasAfterPaymentCalculation + startGas - gasleft()); // calculate flat fee in native uint256 flatFeeWei = 1e12 * uint256(s_config.fulfillmentFlatFeeNativePPM); if (onlyPremium) { return uint96((((l1CostWei + baseFeeWei) * (s_config.nativePremiumPercentage)) / 100) + flatFeeWei); } else { return uint96((((l1CostWei + baseFeeWei) * (100 + s_config.nativePremiumPercentage)) / 100) + flatFeeWei); } } // Get the amount of gas used for fulfillment function _calculatePaymentAmountLink( uint256 startGas, uint256 weiPerUnitGas, bool onlyPremium ) internal view returns (uint96, bool) { (int256 weiPerUnitLink, bool isFeedStale) = _getFeedData(); if (weiPerUnitLink <= 0) { revert InvalidLinkWeiPrice(weiPerUnitLink); } // Will return non-zero on chains that have this enabled uint256 l1CostWei = ChainSpecificUtil._getCurrentTxL1GasFees(msg.data); // (1e18 juels/link) ((wei/gas * gas) + l1wei) / (wei/link) = juels uint256 paymentNoFee = (1e18 * (weiPerUnitGas * (s_config.gasAfterPaymentCalculation + startGas - gasleft()) + l1CostWei)) / uint256(weiPerUnitLink); // calculate the flat fee in wei uint256 flatFeeWei = 1e12 * uint256(s_config.fulfillmentFlatFeeNativePPM - s_config.fulfillmentFlatFeeLinkDiscountPPM); uint256 flatFeeJuels = (1e18 * flatFeeWei) / uint256(weiPerUnitLink); uint256 payment; if (onlyPremium) { payment = ((paymentNoFee * (s_config.linkPremiumPercentage)) / 100 + flatFeeJuels); } else { payment = ((paymentNoFee * (100 + s_config.linkPremiumPercentage)) / 100 + flatFeeJuels); } if (payment > 1e27) { revert PaymentTooLarge(); // Payment + fee cannot be more than all of the link in existence. } return (uint96(payment), isFeedStale); } function _getFeedData() private view returns (int256 weiPerUnitLink, bool isFeedStale) { uint32 stalenessSeconds = s_config.stalenessSeconds; uint256 timestamp; (, weiPerUnitLink, , timestamp, ) = LINK_NATIVE_FEED.latestRoundData(); // solhint-disable-next-line not-rely-on-time isFeedStale = stalenessSeconds > 0 && stalenessSeconds < block.timestamp - timestamp; if (isFeedStale) { weiPerUnitLink = s_fallbackWeiPerUnitLink; } return (weiPerUnitLink, isFeedStale); } /** * @inheritdoc IVRFSubscriptionV2Plus */ function pendingRequestExists(uint256 subId) public view override returns (bool) { address[] storage consumers = s_subscriptionConfigs[subId].consumers; uint256 consumersLength = consumers.length; if (consumersLength == 0) { return false; } for (uint256 i = 0; i < consumersLength; ++i) { if (s_consumers[consumers[i]][subId].pendingReqCount > 0) { return true; } } return false; } /** * @inheritdoc IVRFSubscriptionV2Plus */ function removeConsumer(uint256 subId, address consumer) external override onlySubOwner(subId) nonReentrant { if (pendingRequestExists(subId)) { revert PendingRequestExists(); } if (!s_consumers[consumer][subId].active) { revert InvalidConsumer(subId, consumer); } // Note bounded by MAX_CONSUMERS address[] memory consumers = s_subscriptionConfigs[subId].consumers; uint256 lastConsumerIndex = consumers.length - 1; for (uint256 i = 0; i < consumers.length; ++i) { if (consumers[i] == consumer) { address last = consumers[lastConsumerIndex]; // Storage write to preserve last element s_subscriptionConfigs[subId].consumers[i] = last; // Storage remove last element s_subscriptionConfigs[subId].consumers.pop(); break; } } s_consumers[consumer][subId].active = false; emit SubscriptionConsumerRemoved(subId, consumer); } /** * @inheritdoc IVRFSubscriptionV2Plus */ function cancelSubscription(uint256 subId, address to) external override onlySubOwner(subId) nonReentrant { if (pendingRequestExists(subId)) { revert PendingRequestExists(); } _cancelSubscriptionHelper(subId, to); } /*************************************************************************** * Section: Migration ***************************************************************************/ address[] internal s_migrationTargets; /// @dev Emitted when new coordinator is registered as migratable target event CoordinatorRegistered(address coordinatorAddress); /// @dev Emitted when new coordinator is deregistered event CoordinatorDeregistered(address coordinatorAddress); /// @notice emitted when migration to new coordinator completes successfully /// @param newCoordinator coordinator address after migration /// @param subId subscription ID event MigrationCompleted(address newCoordinator, uint256 subId); /// @notice emitted when migrate() is called and given coordinator is not registered as migratable target error CoordinatorNotRegistered(address coordinatorAddress); /// @notice emitted when migrate() is called and given coordinator is registered as migratable target error CoordinatorAlreadyRegistered(address coordinatorAddress); /// @dev encapsulates data to be migrated from current coordinator // solhint-disable-next-line gas-struct-packing struct V1MigrationData { uint8 fromVersion; uint256 subId; address subOwner; address[] consumers; uint96 linkBalance; uint96 nativeBalance; } function _isTargetRegistered(address target) internal view returns (bool) { uint256 migrationTargetsLength = s_migrationTargets.length; for (uint256 i = 0; i < migrationTargetsLength; ++i) { if (s_migrationTargets[i] == target) { return true; } } return false; } function registerMigratableCoordinator(address target) external onlyOwner { if (_isTargetRegistered(target)) { revert CoordinatorAlreadyRegistered(target); } s_migrationTargets.push(target); emit CoordinatorRegistered(target); } function deregisterMigratableCoordinator(address target) external onlyOwner { uint256 nTargets = s_migrationTargets.length; for (uint256 i = 0; i < nTargets; ++i) { if (s_migrationTargets[i] == target) { s_migrationTargets[i] = s_migrationTargets[nTargets - 1]; s_migrationTargets.pop(); emit CoordinatorDeregistered(target); return; } } revert CoordinatorNotRegistered(target); } function migrate(uint256 subId, address newCoordinator) external nonReentrant { if (!_isTargetRegistered(newCoordinator)) { revert CoordinatorNotRegistered(newCoordinator); } (uint96 balance, uint96 nativeBalance, , address subOwner, address[] memory consumers) = getSubscription(subId); // solhint-disable-next-line gas-custom-errors require(subOwner == msg.sender, "Not subscription owner"); // solhint-disable-next-line gas-custom-errors require(!pendingRequestExists(subId), "Pending request exists"); V1MigrationData memory migrationData = V1MigrationData({ fromVersion: 1, subId: subId, subOwner: subOwner, consumers: consumers, linkBalance: balance, nativeBalance: nativeBalance }); bytes memory encodedData = abi.encode(migrationData); _deleteSubscription(subId); IVRFCoordinatorV2PlusMigration(newCoordinator).onMigration{value: nativeBalance}(encodedData); // Only transfer LINK if the token is active and there is a balance. if (address(LINK) != address(0) && balance != 0) { // solhint-disable-next-line gas-custom-errors require(LINK.transfer(address(newCoordinator), balance), "insufficient funds"); } // despite the fact that we follow best practices this is still probably safest // to prevent any re-entrancy possibilities. s_config.reentrancyLock = true; for (uint256 i = 0; i < consumers.length; ++i) { IVRFMigratableConsumerV2Plus(consumers[i]).setCoordinator(newCoordinator); } s_config.reentrancyLock = false; emit MigrationCompleted(newCoordinator, subId); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import {IVRFCoordinatorV2Plus} from "./interfaces/IVRFCoordinatorV2Plus.sol"; import {IVRFMigratableConsumerV2Plus} from "./interfaces/IVRFMigratableConsumerV2Plus.sol"; import {ConfirmedOwner} from "../../shared/access/ConfirmedOwner.sol"; /** **************************************************************************** * @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 VRFCoordinatorV2Plus. * @dev 2. The consumer contract implements fulfillRandomWords. * ***************************************************************************** * @dev USAGE * * @dev Calling contracts must inherit from VRFConsumerBaseV2Plus, and can * @dev initialize VRFConsumerBaseV2Plus's attributes in their constructor as * @dev shown: * * @dev contract VRFConsumerV2Plus is VRFConsumerBaseV2Plus { * @dev constructor(<other arguments>, address _vrfCoordinator, address _subOwner) * @dev VRFConsumerBaseV2Plus(_vrfCoordinator, _subOwner) 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 a 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, extraArgs), * @dev see (IVRFCoordinatorV2Plus for a description of the arguments). * * @dev Once the VRFCoordinatorV2Plus 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 VRFConsumerBaseV2Plus.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 VRFConsumerBaseV2Plus is IVRFMigratableConsumerV2Plus, ConfirmedOwner { error OnlyCoordinatorCanFulfill(address have, address want); error OnlyOwnerOrCoordinator(address have, address owner, address coordinator); error ZeroAddress(); // s_vrfCoordinator should be used by consumers to make requests to vrfCoordinator // so that coordinator reference is updated after migration IVRFCoordinatorV2Plus public s_vrfCoordinator; /** * @param _vrfCoordinator address of VRFCoordinator contract */ constructor(address _vrfCoordinator) ConfirmedOwner(msg.sender) { if (_vrfCoordinator == address(0)) { revert ZeroAddress(); } s_vrfCoordinator = IVRFCoordinatorV2Plus(_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 VRFConsumerBaseV2Plus 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 */ // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore function fulfillRandomWords(uint256 requestId, uint256[] calldata 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[] calldata randomWords) external { if (msg.sender != address(s_vrfCoordinator)) { revert OnlyCoordinatorCanFulfill(msg.sender, address(s_vrfCoordinator)); } fulfillRandomWords(requestId, randomWords); } /** * @inheritdoc IVRFMigratableConsumerV2Plus */ function setCoordinator(address _vrfCoordinator) external override onlyOwnerOrCoordinator { if (_vrfCoordinator == address(0)) { revert ZeroAddress(); } s_vrfCoordinator = IVRFCoordinatorV2Plus(_vrfCoordinator); emit CoordinatorSet(_vrfCoordinator); } modifier onlyOwnerOrCoordinator() { if (msg.sender != owner() && msg.sender != address(s_vrfCoordinator)) { revert OnlyOwnerOrCoordinator(msg.sender, owner(), address(s_vrfCoordinator)); } _; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ```solidity * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ```solidity * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} * to enforce additional security measures for this role. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(account), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
// 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.3) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value)); } /** * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value)); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0)); _callOptionalReturn(token, approvalCall); } } /** * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`. * Revert on invalid signature. */ function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { return _status == _ENTERED; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.6; interface CoreInterface { function isStaking(address _staking) external view returns (bool); function fee() external view returns (uint256); function token() external view returns (address); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.6; interface GameInterface { function getAddress() external view returns (address gameAddress); // for most games - creation timestamp of the game function getVersion() external view returns (uint256 version); // 0 - fee from player's bet, 1 - fee from core's balance function getFeeType() external pure returns (uint256 feeType); // address to send fee to function getStaking() external view returns (address staking); // function to call when placing bet function placeBet(address player, uint256 amount, bytes calldata data) external returns (address betAddress); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import "openzeppelin/access/Ownable.sol"; import "./shared/BetInterface.sol"; contract LuckyRoundBet is Ownable, BetInterface { address private immutable player; address private immutable game; uint256 private immutable amount; uint256 private immutable created; // 1 - registered // 2 - won // 3 - lost uint256 private status; uint256 private result; uint256 private immutable round; uint256 private immutable startOffset; uint256 private immutable endOffset; constructor( address _player, address _game, uint256 _amount, uint256 _round, uint256 _startOffset, uint256 _endOffset ) { created = block.timestamp; player = _player; game = _game; amount = _amount; round = _round; status = 1; startOffset = _startOffset; endOffset = _endOffset; } function getRound() public view returns (uint256) { return round; } function getPlayer() external view override returns (address) { return player; } function getGame() external view override returns (address) { return game; } function getAmount() external view override returns (uint256) { return amount; } function getStatus() external view override returns (uint256) { return status; } function getCreated() external view override returns (uint256) { return created; } function getResult() external view override returns (uint256) { return result; } function getBetInfo() external view override returns (address, address, uint256, uint256, uint256, uint256) { return (player, game, amount, result, status, created); } function setResult(uint256 _result) external onlyOwner { result = _result; if (_result >= startOffset && _result <= endOffset) { status = 2; } else { status = 3; } } function getStartOffset() external view returns (uint256) { return startOffset; } function getEndOffset() external view returns (uint256) { return endOffset; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // solhint-disable-next-line interface-starts-with-i interface BlockhashStoreInterface { function getBlockhash(uint256 number) external view returns (bytes32); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** **************************************************************************** * @notice Verification of verifiable-random-function (VRF) proofs, following * @notice https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-vrf-05#section-5.3 * @notice See https://eprint.iacr.org/2017/099.pdf for security proofs. * @dev Bibliographic references: * @dev Goldberg, et al., "Verifiable Random Functions (VRFs)", Internet Draft * @dev draft-irtf-cfrg-vrf-05, IETF, Aug 11 2019, * @dev https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-vrf-05 * @dev Papadopoulos, et al., "Making NSEC5 Practical for DNSSEC", Cryptology * @dev ePrint Archive, Report 2017/099, https://eprint.iacr.org/2017/099.pdf * **************************************************************************** * @dev USAGE * @dev The main entry point is _randomValueFromVRFProof. See its docstring. * **************************************************************************** * @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 computationally indistinguishable to her from a uniform * @dev random sample from the output space. * @dev The purpose of this contract is to perform that verification. * **************************************************************************** * @dev DESIGN NOTES * @dev The VRF algorithm verified here satisfies the full uniqueness, full * @dev collision resistance, and full pseudo-randomness security properties. * @dev See "SECURITY PROPERTIES" below, and * @dev https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-vrf-05#section-3 * @dev An elliptic curve point is generally represented in the solidity code * @dev as a uint256[2], corresponding to its affine coordinates in * @dev GF(FIELD_SIZE). * @dev For the sake of efficiency, this implementation deviates from the spec * @dev in some minor ways: * @dev - Keccak hash rather than the SHA256 hash recommended in * @dev https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-vrf-05#section-5.5 * @dev Keccak costs much less gas on the EVM, and provides similar security. * @dev - Secp256k1 curve instead of the P-256 or ED25519 curves recommended in * @dev https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-vrf-05#section-5.5 * @dev For curve-point multiplication, it's much cheaper to abuse ECRECOVER * @dev - _hashToCurve recursively hashes until it finds a curve x-ordinate. On * @dev the EVM, this is slightly more efficient than the recommendation in * @dev https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-vrf-05#section-5.4.1.1 * @dev step 5, to concatenate with a nonce then hash, and rehash with the * @dev nonce updated until a valid x-ordinate is found. * @dev - _hashToCurve does not include a cipher version string or the byte 0x1 * @dev in the hash message, as recommended in step 5.B of the draft * @dev standard. They are unnecessary here because no variation in the * @dev cipher suite is allowed. * @dev - Similarly, the hash input in _scalarFromCurvePoints does not include a * @dev commitment to the cipher suite, either, which differs from step 2 of * @dev https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-vrf-05#section-5.4.3 * @dev . Also, the hash input is the concatenation of the uncompressed * @dev points, not the compressed points as recommended in step 3. * @dev - In the calculation of the challenge value "c", the "u" value (i.e. * @dev the value computed by Reggie as the nonce times the secp256k1 * @dev generator point, see steps 5 and 7 of * @dev https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-vrf-05#section-5.3 * @dev ) is replaced by its ethereum address, i.e. the lower 160 bits of the * @dev keccak hash of the original u. This is because we only verify the * @dev calculation of u up to its address, by abusing ECRECOVER. * **************************************************************************** * @dev SECURITY PROPERTIES * @dev Here are the security properties for this VRF: * @dev Full uniqueness: For any seed and valid VRF public key, there is * @dev exactly one VRF output which can be proved to come from that seed, in * @dev the sense that the proof will pass _verifyVRFProof. * @dev Full collision resistance: It's cryptographically infeasible to find * @dev two seeds with same VRF output from a fixed, valid VRF key * @dev Full pseudorandomness: Absent the proofs that the VRF outputs are * @dev derived from a given seed, the outputs are computationally * @dev indistinguishable from randomness. * @dev https://eprint.iacr.org/2017/099.pdf, Appendix B contains the proofs * @dev for these properties. * @dev For secp256k1, the key validation described in section * @dev https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-vrf-05#section-5.6 * @dev is unnecessary, because secp256k1 has cofactor 1, and the * @dev representation of the public key used here (affine x- and y-ordinates * @dev of the secp256k1 point on the standard y^2=x^3+7 curve) cannot refer to * @dev the point at infinity. * **************************************************************************** * @dev OTHER SECURITY CONSIDERATIONS * * @dev The seed input to the VRF could in principle force an arbitrary amount * @dev of work in _hashToCurve, by requiring extra rounds of hashing and * @dev checking whether that's yielded the x ordinate of a secp256k1 point. * @dev However, under the Random Oracle Model the probability of choosing a * @dev point which forces n extra rounds in _hashToCurve is 2⁻ⁿ. The base cost * @dev for calling _hashToCurve is about 25,000 gas, and each round of checking * @dev for a valid x ordinate costs about 15,555 gas, so to find a seed for * @dev which _hashToCurve would cost more than 2,017,000 gas, one would have to * @dev try, in expectation, about 2¹²⁸ seeds, which is infeasible for any * @dev foreseeable computational resources. (25,000 + 128 * 15,555 < 2,017,000.) * @dev Since the gas block limit for the Ethereum main net is 10,000,000 gas, * @dev this means it is infeasible for an adversary to prevent correct * @dev operation of this contract by choosing an adverse seed. * @dev (See TestMeasureHashToCurveGasCost for verification of the gas cost for * @dev _hashToCurve.) * @dev It may be possible to make a secure constant-time _hashToCurve function. * @dev See notes in _hashToCurve docstring. */ contract VRF { // See https://www.secg.org/sec2-v2.pdf, section 2.4.1, for these constants. // Number of points in Secp256k1 uint256 private constant GROUP_ORDER = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141; // Prime characteristic of the galois field over which Secp256k1 is defined uint256 private constant FIELD_SIZE = // solium-disable-next-line indentation 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F; uint256 private constant WORD_LENGTH_BYTES = 0x20; // (base^exponent) % FIELD_SIZE // Cribbed from https://medium.com/@rbkhmrcr/precompiles-solidity-e5d29bd428c4 function _bigModExp(uint256 base, uint256 exponent) internal view returns (uint256 exponentiation) { uint256 callResult; uint256[6] memory bigModExpContractInputs; bigModExpContractInputs[0] = WORD_LENGTH_BYTES; // Length of base bigModExpContractInputs[1] = WORD_LENGTH_BYTES; // Length of exponent bigModExpContractInputs[2] = WORD_LENGTH_BYTES; // Length of modulus bigModExpContractInputs[3] = base; bigModExpContractInputs[4] = exponent; bigModExpContractInputs[5] = FIELD_SIZE; uint256[1] memory output; assembly { callResult := staticcall( not(0), // Gas cost: no limit 0x05, // Bigmodexp contract address bigModExpContractInputs, 0xc0, // Length of input segment: 6*0x20-bytes output, 0x20 // Length of output segment ) } if (callResult == 0) { // solhint-disable-next-line gas-custom-errors revert("bigModExp failure!"); } return output[0]; } // Let q=FIELD_SIZE. q % 4 = 3, ∴ x≡r^2 mod q ⇒ x^SQRT_POWER≡±r mod q. See // https://en.wikipedia.org/wiki/Modular_square_root#Prime_or_prime_power_modulus uint256 private constant SQRT_POWER = (FIELD_SIZE + 1) >> 2; // Computes a s.t. a^2 = x in the field. Assumes a exists function _squareRoot(uint256 x) internal view returns (uint256) { return _bigModExp(x, SQRT_POWER); } // The value of y^2 given that (x,y) is on secp256k1. function _ySquared(uint256 x) internal pure returns (uint256) { // Curve is y^2=x^3+7. See section 2.4.1 of https://www.secg.org/sec2-v2.pdf uint256 xCubed = mulmod(x, mulmod(x, x, FIELD_SIZE), FIELD_SIZE); return addmod(xCubed, 7, FIELD_SIZE); } // True iff p is on secp256k1 function _isOnCurve(uint256[2] memory p) internal pure returns (bool) { // Section 2.3.6. in https://www.secg.org/sec1-v2.pdf // requires each ordinate to be in [0, ..., FIELD_SIZE-1] // solhint-disable-next-line gas-custom-errors require(p[0] < FIELD_SIZE, "invalid x-ordinate"); // solhint-disable-next-line gas-custom-errors require(p[1] < FIELD_SIZE, "invalid y-ordinate"); return _ySquared(p[0]) == mulmod(p[1], p[1], FIELD_SIZE); } // Hash x uniformly into {0, ..., FIELD_SIZE-1}. function _fieldHash(bytes memory b) internal pure returns (uint256 x_) { x_ = uint256(keccak256(b)); // Rejecting if x >= FIELD_SIZE corresponds to step 2.1 in section 2.3.4 of // http://www.secg.org/sec1-v2.pdf , which is part of the definition of // string_to_point in the IETF draft while (x_ >= FIELD_SIZE) { x_ = uint256(keccak256(abi.encodePacked(x_))); } return x_; } // Hash b to a random point which hopefully lies on secp256k1. The y ordinate // is always even, due to // https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-vrf-05#section-5.4.1.1 // step 5.C, which references arbitrary_string_to_point, defined in // https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-vrf-05#section-5.5 as // returning the point with given x ordinate, and even y ordinate. function _newCandidateSecp256k1Point(bytes memory b) internal view returns (uint256[2] memory p) { unchecked { p[0] = _fieldHash(b); p[1] = _squareRoot(_ySquared(p[0])); if (p[1] % 2 == 1) { // Note that 0 <= p[1] < FIELD_SIZE // so this cannot wrap, we use unchecked to save gas. p[1] = FIELD_SIZE - p[1]; } } return p; } // Domain-separation tag for initial hash in _hashToCurve. Corresponds to // vrf.go/hashToCurveHashPrefix uint256 internal constant HASH_TO_CURVE_HASH_PREFIX = 1; // Cryptographic hash function onto the curve. // // Corresponds to algorithm in section 5.4.1.1 of the draft standard. (But see // DESIGN NOTES above for slight differences.) // // TODO(alx): Implement a bounded-computation hash-to-curve, as described in // "Construction of Rational Points on Elliptic Curves over Finite Fields" // http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.831.5299&rep=rep1&type=pdf // and suggested by // https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-01#section-5.2.2 // (Though we can't used exactly that because secp256k1's j-invariant is 0.) // // This would greatly simplify the analysis in "OTHER SECURITY CONSIDERATIONS" // https://www.pivotaltracker.com/story/show/171120900 function _hashToCurve(uint256[2] memory pk, uint256 input) internal view returns (uint256[2] memory rv) { rv = _newCandidateSecp256k1Point(abi.encodePacked(HASH_TO_CURVE_HASH_PREFIX, pk, input)); while (!_isOnCurve(rv)) { rv = _newCandidateSecp256k1Point(abi.encodePacked(rv[0])); } return rv; } /** ********************************************************************* * @notice Check that product==scalar*multiplicand * * @dev Based on Vitalik Buterin's idea in ethresear.ch post cited below. * * @param multiplicand: secp256k1 point * @param scalar: non-zero GF(GROUP_ORDER) scalar * @param product: secp256k1 expected to be multiplier * multiplicand * @return verifies true iff product==scalar*multiplicand, with cryptographically high probability */ function _ecmulVerify( uint256[2] memory multiplicand, uint256 scalar, uint256[2] memory product ) internal pure returns (bool verifies) { // solhint-disable-next-line gas-custom-errors require(scalar != 0, "zero scalar"); // Rules out an ecrecover failure case uint256 x = multiplicand[0]; // x ordinate of multiplicand uint8 v = multiplicand[1] % 2 == 0 ? 27 : 28; // parity of y ordinate // https://ethresear.ch/t/you-can-kinda-abuse-ecrecover-to-do-ecmul-in-secp256k1-today/2384/9 // Point corresponding to address ecrecover(0, v, x, s=scalar*x) is // (x⁻¹ mod GROUP_ORDER) * (scalar * x * multiplicand - 0 * g), i.e. // scalar*multiplicand. See https://crypto.stackexchange.com/a/18106 bytes32 scalarTimesX = bytes32(mulmod(scalar, x, GROUP_ORDER)); address actual = ecrecover(bytes32(0), v, bytes32(x), scalarTimesX); // Explicit conversion to address takes bottom 160 bits address expected = address(uint160(uint256(keccak256(abi.encodePacked(product))))); return (actual == expected); } // Returns x1/z1-x2/z2=(x1z2-x2z1)/(z1z2) in projective coordinates on P¹(𝔽ₙ) function _projectiveSub( uint256 x1, uint256 z1, uint256 x2, uint256 z2 ) internal pure returns (uint256 x3, uint256 z3) { unchecked { uint256 num1 = mulmod(z2, x1, FIELD_SIZE); // Note this cannot wrap since x2 is a point in [0, FIELD_SIZE-1] // we use unchecked to save gas. uint256 num2 = mulmod(FIELD_SIZE - x2, z1, FIELD_SIZE); (x3, z3) = (addmod(num1, num2, FIELD_SIZE), mulmod(z1, z2, FIELD_SIZE)); } return (x3, z3); } // Returns x1/z1*x2/z2=(x1x2)/(z1z2), in projective coordinates on P¹(𝔽ₙ) function _projectiveMul( uint256 x1, uint256 z1, uint256 x2, uint256 z2 ) internal pure returns (uint256 x3, uint256 z3) { (x3, z3) = (mulmod(x1, x2, FIELD_SIZE), mulmod(z1, z2, FIELD_SIZE)); return (x3, z3); } /** ************************************************************************** @notice Computes elliptic-curve sum, in projective co-ordinates @dev Using projective coordinates avoids costly divisions @dev To use this with p and q in affine coordinates, call @dev _projectiveECAdd(px, py, qx, qy). This will return @dev the addition of (px, py, 1) and (qx, qy, 1), in the @dev secp256k1 group. @dev This can be used to calculate the z which is the inverse to zInv @dev in isValidVRFOutput. But consider using a faster @dev re-implementation such as ProjectiveECAdd in the golang vrf package. @dev This function assumes [px,py,1],[qx,qy,1] are valid projective coordinates of secp256k1 points. That is safe in this contract, because this method is only used by _linearCombination, which checks points are on the curve via ecrecover. ************************************************************************** @param px The first affine coordinate of the first summand @param py The second affine coordinate of the first summand @param qx The first affine coordinate of the second summand @param qy The second affine coordinate of the second summand (px,py) and (qx,qy) must be distinct, valid secp256k1 points. ************************************************************************** Return values are projective coordinates of [px,py,1]+[qx,qy,1] as points on secp256k1, in P²(𝔽ₙ) @return sx @return sy @return sz */ function _projectiveECAdd( uint256 px, uint256 py, uint256 qx, uint256 qy ) internal pure returns (uint256 sx, uint256 sy, uint256 sz) { unchecked { // See "Group law for E/K : y^2 = x^3 + ax + b", in section 3.1.2, p. 80, // "Guide to Elliptic Curve Cryptography" by Hankerson, Menezes and Vanstone // We take the equations there for (sx,sy), and homogenize them to // projective coordinates. That way, no inverses are required, here, and we // only need the one inverse in _affineECAdd. // We only need the "point addition" equations from Hankerson et al. Can // skip the "point doubling" equations because p1 == p2 is cryptographically // impossible, and required not to be the case in _linearCombination. // Add extra "projective coordinate" to the two points (uint256 z1, uint256 z2) = (1, 1); // (lx, lz) = (qy-py)/(qx-px), i.e., gradient of secant line. // Cannot wrap since px and py are in [0, FIELD_SIZE-1] uint256 lx = addmod(qy, FIELD_SIZE - py, FIELD_SIZE); uint256 lz = addmod(qx, FIELD_SIZE - px, FIELD_SIZE); uint256 dx; // Accumulates denominator from sx calculation // sx=((qy-py)/(qx-px))^2-px-qx (sx, dx) = _projectiveMul(lx, lz, lx, lz); // ((qy-py)/(qx-px))^2 (sx, dx) = _projectiveSub(sx, dx, px, z1); // ((qy-py)/(qx-px))^2-px (sx, dx) = _projectiveSub(sx, dx, qx, z2); // ((qy-py)/(qx-px))^2-px-qx uint256 dy; // Accumulates denominator from sy calculation // sy=((qy-py)/(qx-px))(px-sx)-py (sy, dy) = _projectiveSub(px, z1, sx, dx); // px-sx (sy, dy) = _projectiveMul(sy, dy, lx, lz); // ((qy-py)/(qx-px))(px-sx) (sy, dy) = _projectiveSub(sy, dy, py, z1); // ((qy-py)/(qx-px))(px-sx)-py if (dx != dy) { // Cross-multiply to put everything over a common denominator sx = mulmod(sx, dy, FIELD_SIZE); sy = mulmod(sy, dx, FIELD_SIZE); sz = mulmod(dx, dy, FIELD_SIZE); } else { // Already over a common denominator, use that for z ordinate sz = dx; } } return (sx, sy, sz); } // p1+p2, as affine points on secp256k1. // // invZ must be the inverse of the z returned by _projectiveECAdd(p1, p2). // It is computed off-chain to save gas. // // p1 and p2 must be distinct, because _projectiveECAdd doesn't handle // point doubling. function _affineECAdd( uint256[2] memory p1, uint256[2] memory p2, uint256 invZ ) internal pure returns (uint256[2] memory) { uint256 x; uint256 y; uint256 z; (x, y, z) = _projectiveECAdd(p1[0], p1[1], p2[0], p2[1]); // solhint-disable-next-line gas-custom-errors require(mulmod(z, invZ, FIELD_SIZE) == 1, "invZ must be inverse of z"); // Clear the z ordinate of the projective representation by dividing through // by it, to obtain the affine representation return [mulmod(x, invZ, FIELD_SIZE), mulmod(y, invZ, FIELD_SIZE)]; } // True iff address(c*p+s*g) == lcWitness, where g is generator. (With // cryptographically high probability.) function _verifyLinearCombinationWithGenerator( uint256 c, uint256[2] memory p, uint256 s, address lcWitness ) internal pure returns (bool) { // Rule out ecrecover failure modes which return address 0. unchecked { // solhint-disable-next-line gas-custom-errors require(lcWitness != address(0), "bad witness"); uint8 v = (p[1] % 2 == 0) ? 27 : 28; // parity of y-ordinate of p // Note this cannot wrap (X - Y % X), but we use unchecked to save // gas. bytes32 pseudoHash = bytes32(GROUP_ORDER - mulmod(p[0], s, GROUP_ORDER)); // -s*p[0] bytes32 pseudoSignature = bytes32(mulmod(c, p[0], GROUP_ORDER)); // c*p[0] // https://ethresear.ch/t/you-can-kinda-abuse-ecrecover-to-do-ecmul-in-secp256k1-today/2384/9 // The point corresponding to the address returned by // ecrecover(-s*p[0],v,p[0],c*p[0]) is // (p[0]⁻¹ mod GROUP_ORDER)*(c*p[0]-(-s)*p[0]*g)=c*p+s*g. // See https://crypto.stackexchange.com/a/18106 // https://bitcoin.stackexchange.com/questions/38351/ecdsa-v-r-s-what-is-v address computed = ecrecover(pseudoHash, v, bytes32(p[0]), pseudoSignature); return computed == lcWitness; } } // c*p1 + s*p2. Requires cp1Witness=c*p1 and sp2Witness=s*p2. Also // requires cp1Witness != sp2Witness (which is fine for this application, // since it is cryptographically impossible for them to be equal. In the // (cryptographically impossible) case that a prover accidentally derives // a proof with equal c*p1 and s*p2, they should retry with a different // proof nonce.) Assumes that all points are on secp256k1 // (which is checked in _verifyVRFProof below.) function _linearCombination( uint256 c, uint256[2] memory p1, uint256[2] memory cp1Witness, uint256 s, uint256[2] memory p2, uint256[2] memory sp2Witness, uint256 zInv ) internal pure returns (uint256[2] memory) { unchecked { // Note we are relying on the wrap around here // solhint-disable-next-line gas-custom-errors require((cp1Witness[0] % FIELD_SIZE) != (sp2Witness[0] % FIELD_SIZE), "points in sum must be distinct"); // solhint-disable-next-line gas-custom-errors require(_ecmulVerify(p1, c, cp1Witness), "First mul check failed"); // solhint-disable-next-line gas-custom-errors require(_ecmulVerify(p2, s, sp2Witness), "Second mul check failed"); return _affineECAdd(cp1Witness, sp2Witness, zInv); } } // Domain-separation tag for the hash taken in _scalarFromCurvePoints. // Corresponds to scalarFromCurveHashPrefix in vrf.go uint256 internal constant SCALAR_FROM_CURVE_POINTS_HASH_PREFIX = 2; // Pseudo-random number from inputs. Matches vrf.go/_scalarFromCurvePoints, and // https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-vrf-05#section-5.4.3 // The draft calls (in step 7, via the definition of string_to_int, in // https://datatracker.ietf.org/doc/html/rfc8017#section-4.2 ) for taking the // first hash without checking that it corresponds to a number less than the // group order, which will lead to a slight bias in the sample. // // TODO(alx): We could save a bit of gas by following the standard here and // using the compressed representation of the points, if we collated the y // parities into a single bytes32. // https://www.pivotaltracker.com/story/show/171120588 function _scalarFromCurvePoints( uint256[2] memory hash, uint256[2] memory pk, uint256[2] memory gamma, address uWitness, uint256[2] memory v ) internal pure returns (uint256 s) { return uint256(keccak256(abi.encodePacked(SCALAR_FROM_CURVE_POINTS_HASH_PREFIX, hash, pk, gamma, v, uWitness))); } // True if (gamma, c, s) is a correctly constructed randomness proof from pk // and seed. zInv must be the inverse of the third ordinate from // _projectiveECAdd applied to cGammaWitness and sHashWitness. Corresponds to // section 5.3 of the IETF draft. // // TODO(alx): Since I'm only using pk in the ecrecover call, I could only pass // the x ordinate, and the parity of the y ordinate in the top bit of uWitness // (which I could make a uint256 without using any extra space.) Would save // about 2000 gas. https://www.pivotaltracker.com/story/show/170828567 function _verifyVRFProof( uint256[2] memory pk, uint256[2] memory gamma, uint256 c, uint256 s, uint256 seed, address uWitness, uint256[2] memory cGammaWitness, uint256[2] memory sHashWitness, uint256 zInv ) internal view { unchecked { // solhint-disable-next-line gas-custom-errors require(_isOnCurve(pk), "public key is not on curve"); // solhint-disable-next-line gas-custom-errors require(_isOnCurve(gamma), "gamma is not on curve"); // solhint-disable-next-line gas-custom-errors require(_isOnCurve(cGammaWitness), "cGammaWitness is not on curve"); // solhint-disable-next-line gas-custom-errors require(_isOnCurve(sHashWitness), "sHashWitness is not on curve"); // Step 5. of IETF draft section 5.3 (pk corresponds to 5.3's Y, and here // we use the address of u instead of u itself. Also, here we add the // terms instead of taking the difference, and in the proof construction in // vrf.GenerateProof, we correspondingly take the difference instead of // taking the sum as they do in step 7 of section 5.1.) // solhint-disable-next-line gas-custom-errors require(_verifyLinearCombinationWithGenerator(c, pk, s, uWitness), "addr(c*pk+s*g)!=_uWitness"); // Step 4. of IETF draft section 5.3 (pk corresponds to Y, seed to alpha_string) uint256[2] memory hash = _hashToCurve(pk, seed); // Step 6. of IETF draft section 5.3, but see note for step 5 about +/- terms uint256[2] memory v = _linearCombination(c, gamma, cGammaWitness, s, hash, sHashWitness, zInv); // Steps 7. and 8. of IETF draft section 5.3 uint256 derivedC = _scalarFromCurvePoints(hash, pk, gamma, uWitness, v); // solhint-disable-next-line gas-custom-errors require(c == derivedC, "invalid proof"); } } // Domain-separation tag for the hash used as the final VRF output. // Corresponds to vrfRandomOutputHashPrefix in vrf.go uint256 internal constant VRF_RANDOM_OUTPUT_HASH_PREFIX = 3; struct Proof { uint256[2] pk; uint256[2] gamma; uint256 c; uint256 s; uint256 seed; address uWitness; uint256[2] cGammaWitness; uint256[2] sHashWitness; uint256 zInv; } /* *************************************************************************** * @notice Returns proof's output, if proof is valid. Otherwise reverts * @param proof vrf proof components * @param seed seed used to generate the vrf output * * Throws if proof is invalid, otherwise: * @return output i.e., the random output implied by the proof * *************************************************************************** */ function _randomValueFromVRFProof(Proof memory proof, uint256 seed) internal view returns (uint256 output) { _verifyVRFProof( proof.pk, proof.gamma, proof.c, proof.s, seed, proof.uWitness, proof.cGammaWitness, proof.sHashWitness, proof.zInv ); output = uint256(keccak256(abi.encode(VRF_RANDOM_OUTPUT_HASH_PREFIX, proof.gamma))); return output; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.6; /** * @title VRFTypes * @notice The VRFTypes library is a collection of types that is required to fulfill VRF requests * on-chain. They must be ABI-compatible with the types used by the coordinator contracts. */ library VRFTypes { // ABI-compatible with VRF.Proof. // This proof is used for VRF V2 and V2Plus. struct Proof { uint256[2] pk; uint256[2] gamma; uint256 c; uint256 s; uint256 seed; address uWitness; uint256[2] cGammaWitness; uint256[2] sHashWitness; uint256 zInv; } // ABI-compatible with VRFCoordinatorV2.RequestCommitment. // This is only used for VRF V2. struct RequestCommitment { uint64 blockNum; uint64 subId; uint32 callbackGasLimit; uint32 numWords; address sender; } // ABI-compatible with VRFCoordinatorV2Plus.RequestCommitment. // This is only used for VRF V2Plus. struct RequestCommitmentV2Plus { uint64 blockNum; uint256 subId; uint32 callbackGasLimit; uint32 numWords; address sender; bytes extraArgs; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; import {ArbSys} from "./vendor/@arbitrum/nitro-contracts/src/precompiles/ArbSys.sol"; import {ArbGasInfo} from "./vendor/@arbitrum/nitro-contracts/src/precompiles/ArbGasInfo.sol"; import {OVM_GasPriceOracle} from "./vendor/@eth-optimism/contracts/v0.8.9/contracts/L2/predeploys/OVM_GasPriceOracle.sol"; /// @dev A library that abstracts out opcodes that behave differently across chains. /// @dev The methods below return values that are pertinent to the given chain. /// @dev For instance, ChainSpecificUtil.getBlockNumber() returns L2 block number in L2 chains library ChainSpecificUtil { // ------------ Start Arbitrum Constants ------------ /// @dev ARBSYS_ADDR is the address of the ArbSys precompile on Arbitrum. /// @dev reference: https://github.com/OffchainLabs/nitro/blob/v2.0.14/contracts/src/precompiles/ArbSys.sol#L10 address private constant ARBSYS_ADDR = address(0x0000000000000000000000000000000000000064); ArbSys private constant ARBSYS = ArbSys(ARBSYS_ADDR); /// @dev ARBGAS_ADDR is the address of the ArbGasInfo precompile on Arbitrum. /// @dev reference: https://github.com/OffchainLabs/nitro/blob/v2.0.14/contracts/src/precompiles/ArbGasInfo.sol#L10 address private constant ARBGAS_ADDR = address(0x000000000000000000000000000000000000006C); ArbGasInfo private constant ARBGAS = ArbGasInfo(ARBGAS_ADDR); uint256 private constant ARB_MAINNET_CHAIN_ID = 42161; uint256 private constant ARB_GOERLI_TESTNET_CHAIN_ID = 421613; uint256 private constant ARB_SEPOLIA_TESTNET_CHAIN_ID = 421614; // ------------ End Arbitrum Constants ------------ // ------------ Start Optimism Constants ------------ /// @dev L1_FEE_DATA_PADDING includes 35 bytes for L1 data padding for Optimism bytes internal constant L1_FEE_DATA_PADDING = "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"; /// @dev OVM_GASPRICEORACLE_ADDR is the address of the OVM_GasPriceOracle precompile on Optimism. /// @dev reference: https://community.optimism.io/docs/developers/build/transaction-fees/#estimating-the-l1-data-fee address private constant OVM_GASPRICEORACLE_ADDR = address(0x420000000000000000000000000000000000000F); OVM_GasPriceOracle private constant OVM_GASPRICEORACLE = OVM_GasPriceOracle(OVM_GASPRICEORACLE_ADDR); uint256 private constant OP_MAINNET_CHAIN_ID = 10; uint256 private constant OP_GOERLI_CHAIN_ID = 420; uint256 private constant OP_SEPOLIA_CHAIN_ID = 11155420; /// @dev Base is a OP stack based rollup and follows the same L1 pricing logic as Optimism. uint256 private constant BASE_MAINNET_CHAIN_ID = 8453; uint256 private constant BASE_GOERLI_CHAIN_ID = 84531; uint256 private constant BASE_SEPOLIA_CHAIN_ID = 84532; // ------------ End Optimism Constants ------------ /** * @notice Returns the blockhash for the given blockNumber. * @notice If the blockNumber is more than 256 blocks in the past, returns the empty string. * @notice When on a known Arbitrum chain, it uses ArbSys.arbBlockHash to get the blockhash. * @notice Otherwise, it uses the blockhash opcode. * @notice Note that the blockhash opcode will return the L2 blockhash on Optimism. */ function _getBlockhash(uint64 blockNumber) internal view returns (bytes32) { uint256 chainid = block.chainid; if (_isArbitrumChainId(chainid)) { if ((_getBlockNumber() - blockNumber) > 256 || blockNumber >= _getBlockNumber()) { return ""; } return ARBSYS.arbBlockHash(blockNumber); } return blockhash(blockNumber); } /** * @notice Returns the block number of the current block. * @notice When on a known Arbitrum chain, it uses ArbSys.arbBlockNumber to get the block number. * @notice Otherwise, it uses the block.number opcode. * @notice Note that the block.number opcode will return the L2 block number on Optimism. */ function _getBlockNumber() internal view returns (uint256) { uint256 chainid = block.chainid; if (_isArbitrumChainId(chainid)) { return ARBSYS.arbBlockNumber(); } return block.number; } /** * @notice Returns the L1 fees that will be paid for the current transaction, given any calldata * @notice for the current transaction. * @notice When on a known Arbitrum chain, it uses ArbGas.getCurrentTxL1GasFees to get the fees. * @notice On Arbitrum, the provided calldata is not used to calculate the fees. * @notice On Optimism, the provided calldata is passed to the OVM_GasPriceOracle predeploy * @notice and getL1Fee is called to get the fees. */ function _getCurrentTxL1GasFees(bytes memory txCallData) internal view returns (uint256) { uint256 chainid = block.chainid; if (_isArbitrumChainId(chainid)) { return ARBGAS.getCurrentTxL1GasFees(); } else if (_isOptimismChainId(chainid)) { return OVM_GASPRICEORACLE.getL1Fee(bytes.concat(txCallData, L1_FEE_DATA_PADDING)); } return 0; } /** * @notice Returns the gas cost in wei of calldataSizeBytes of calldata being posted * @notice to L1. */ function _getL1CalldataGasCost(uint256 calldataSizeBytes) internal view returns (uint256) { uint256 chainid = block.chainid; if (_isArbitrumChainId(chainid)) { (, uint256 l1PricePerByte, , , , ) = ARBGAS.getPricesInWei(); // see https://developer.arbitrum.io/devs-how-tos/how-to-estimate-gas#where-do-we-get-all-this-information-from // for the justification behind the 140 number. return l1PricePerByte * (calldataSizeBytes + 140); } else if (_isOptimismChainId(chainid)) { return _calculateOptimismL1DataFee(calldataSizeBytes); } return 0; } /** * @notice Return true if and only if the provided chain ID is an Arbitrum chain ID. */ function _isArbitrumChainId(uint256 chainId) internal pure returns (bool) { return chainId == ARB_MAINNET_CHAIN_ID || chainId == ARB_GOERLI_TESTNET_CHAIN_ID || chainId == ARB_SEPOLIA_TESTNET_CHAIN_ID; } /** * @notice Return true if and only if the provided chain ID is an Optimism chain ID. * @notice Note that optimism chain id's are also OP stack chain id's (e.g. Base). */ function _isOptimismChainId(uint256 chainId) internal pure returns (bool) { return chainId == OP_MAINNET_CHAIN_ID || chainId == OP_GOERLI_CHAIN_ID || chainId == OP_SEPOLIA_CHAIN_ID || chainId == BASE_MAINNET_CHAIN_ID || chainId == BASE_GOERLI_CHAIN_ID || chainId == BASE_SEPOLIA_CHAIN_ID; } function _calculateOptimismL1DataFee(uint256 calldataSizeBytes) internal view returns (uint256) { // from: https://community.optimism.io/docs/developers/build/transaction-fees/#the-l1-data-fee // l1_data_fee = l1_gas_price * (tx_data_gas + fixed_overhead) * dynamic_overhead // tx_data_gas = count_zero_bytes(tx_data) * 4 + count_non_zero_bytes(tx_data) * 16 // note we conservatively assume all non-zero bytes. uint256 l1BaseFeeWei = OVM_GASPRICEORACLE.l1BaseFee(); uint256 numZeroBytes = 0; uint256 numNonzeroBytes = calldataSizeBytes - numZeroBytes; uint256 txDataGas = numZeroBytes * 4 + numNonzeroBytes * 16; uint256 fixedOverhead = OVM_GASPRICEORACLE.overhead(); // The scalar is some value like 0.684, but is represented as // that times 10 ^ number of scalar decimals. // e.g scalar = 0.684 * 10^6 // The divisor is used to divide that and have a net result of the true scalar. uint256 scalar = OVM_GASPRICEORACLE.scalar(); uint256 scalarDecimals = OVM_GASPRICEORACLE.decimals(); uint256 divisor = 10 ** scalarDecimals; uint256 l1DataFee = (l1BaseFeeWei * (txDataGas + fixedOverhead) * scalar) / divisor; return l1DataFee; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import {EnumerableSet} from "../../vendor/openzeppelin-solidity/v4.7.3/contracts/utils/structs/EnumerableSet.sol"; import {LinkTokenInterface} from "../../shared/interfaces/LinkTokenInterface.sol"; import {ConfirmedOwner} from "../../shared/access/ConfirmedOwner.sol"; import {AggregatorV3Interface} from "../../shared/interfaces/AggregatorV3Interface.sol"; import {IERC677Receiver} from "../../shared/interfaces/IERC677Receiver.sol"; import {IVRFSubscriptionV2Plus} from "./interfaces/IVRFSubscriptionV2Plus.sol"; abstract contract SubscriptionAPI is ConfirmedOwner, IERC677Receiver, IVRFSubscriptionV2Plus { using EnumerableSet for EnumerableSet.UintSet; /// @dev may not be provided upon construction on some chains due to lack of availability LinkTokenInterface public LINK; /// @dev may not be provided upon construction on some chains due to lack of availability AggregatorV3Interface public LINK_NATIVE_FEED; // We need to maintain a list of consuming addresses. // This bound ensures we are able to loop over them as needed. // Should a user require more consumers, they can use multiple subscriptions. uint16 public constant MAX_CONSUMERS = 100; error TooManyConsumers(); error InsufficientBalance(); error InvalidConsumer(uint256 subId, address consumer); error InvalidSubscription(); error OnlyCallableFromLink(); error InvalidCalldata(); error MustBeSubOwner(address owner); error PendingRequestExists(); error MustBeRequestedOwner(address proposedOwner); error BalanceInvariantViolated(uint256 internalBalance, uint256 externalBalance); // Should never happen event FundsRecovered(address to, uint256 amount); event NativeFundsRecovered(address to, uint256 amount); error LinkAlreadySet(); error FailedToSendNative(); error FailedToTransferLink(); error IndexOutOfRange(); error LinkNotSet(); // We use the subscription struct (1 word) // at fulfillment time. struct Subscription { // There are only 1e9*1e18 = 1e27 juels in existence, so the balance can fit in uint96 (2^96 ~ 7e28) uint96 balance; // Common link balance used for all consumer requests. // a uint96 is large enough to hold around ~8e28 wei, or 80 billion ether. // That should be enough to cover most (if not all) subscriptions. uint96 nativeBalance; // Common native balance used for all consumer requests. uint64 reqCount; } // We use the config for the mgmt APIs struct SubscriptionConfig { address owner; // Owner can fund/withdraw/cancel the sub. address requestedOwner; // For safely transferring sub ownership. // Maintains the list of keys in s_consumers. // We do this for 2 reasons: // 1. To be able to clean up all keys from s_consumers when canceling a subscription. // 2. To be able to return the list of all consumers in getSubscription. // Note that we need the s_consumers map to be able to directly check if a // consumer is valid without reading all the consumers from storage. address[] consumers; } struct ConsumerConfig { bool active; uint64 nonce; uint64 pendingReqCount; } // Note a nonce of 0 indicates the consumer is not assigned to that subscription. mapping(address => mapping(uint256 => ConsumerConfig)) /* consumerAddress */ /* subId */ /* consumerConfig */ internal s_consumers; mapping(uint256 => SubscriptionConfig) /* subId */ /* subscriptionConfig */ internal s_subscriptionConfigs; mapping(uint256 => Subscription) /* subId */ /* subscription */ internal s_subscriptions; // subscription nonce used to construct subId. Rises monotonically uint64 public s_currentSubNonce; // track all subscription id's that were created by this contract // note: access should be through the getActiveSubscriptionIds() view function // which takes a starting index and a max number to fetch in order to allow // "pagination" of the subscription ids. in the event a very large number of // subscription id's are stored in this set, they cannot be retrieved in a // single RPC call without violating various size limits. EnumerableSet.UintSet internal s_subIds; // s_totalBalance tracks the total link sent to/from // this contract through onTokenTransfer, cancelSubscription and oracleWithdraw. // A discrepancy with this contract's link balance indicates someone // sent tokens using transfer and so we may need to use recoverFunds. uint96 public s_totalBalance; // s_totalNativeBalance tracks the total native sent to/from // this contract through fundSubscription, cancelSubscription and oracleWithdrawNative. // A discrepancy with this contract's native balance indicates someone // sent native using transfer and so we may need to use recoverNativeFunds. uint96 public s_totalNativeBalance; uint96 internal s_withdrawableTokens; uint96 internal s_withdrawableNative; event SubscriptionCreated(uint256 indexed subId, address owner); event SubscriptionFunded(uint256 indexed subId, uint256 oldBalance, uint256 newBalance); event SubscriptionFundedWithNative(uint256 indexed subId, uint256 oldNativeBalance, uint256 newNativeBalance); event SubscriptionConsumerAdded(uint256 indexed subId, address consumer); event SubscriptionConsumerRemoved(uint256 indexed subId, address consumer); event SubscriptionCanceled(uint256 indexed subId, address to, uint256 amountLink, uint256 amountNative); event SubscriptionOwnerTransferRequested(uint256 indexed subId, address from, address to); event SubscriptionOwnerTransferred(uint256 indexed subId, address from, address to); struct Config { uint16 minimumRequestConfirmations; uint32 maxGasLimit; // Reentrancy protection. bool reentrancyLock; // stalenessSeconds is how long before we consider the feed price to be stale // and fallback to fallbackWeiPerUnitLink. uint32 stalenessSeconds; // Gas to cover oracle payment after we calculate the payment. // We make it configurable in case those operations are repriced. // The recommended number is below, though it may vary slightly // if certain chains do not implement certain EIP's. // 21000 + // base cost of the transaction // 100 + 5000 + // warm subscription balance read and update. See https://eips.ethereum.org/EIPS/eip-2929 // 2*2100 + 5000 - // cold read oracle address and oracle balance and first time oracle balance update, note first time will be 20k, but 5k subsequently // 4800 + // request delete refund (refunds happen after execution), note pre-london fork was 15k. See https://eips.ethereum.org/EIPS/eip-3529 // 6685 + // Positive static costs of argument encoding etc. note that it varies by +/- x*12 for every x bytes of non-zero data in the proof. // Total: 37,185 gas. uint32 gasAfterPaymentCalculation; // Flat fee charged per fulfillment in millionths of native. // So fee range is [0, 2^32/10^6]. uint32 fulfillmentFlatFeeNativePPM; // Discount relative to fulfillmentFlatFeeNativePPM for link payment in millionths of native // Should not exceed fulfillmentFlatFeeNativePPM // So fee range is [0, 2^32/10^6]. uint32 fulfillmentFlatFeeLinkDiscountPPM; // nativePremiumPercentage is the percentage of the total gas costs that is added to the final premium for native payment // nativePremiumPercentage = 10 means 10% of the total gas costs is added. only integral percentage is allowed uint8 nativePremiumPercentage; // linkPremiumPercentage is the percentage of total gas costs that is added to the final premium for link payment // linkPremiumPercentage = 10 means 10% of the total gas costs is added. only integral percentage is allowed uint8 linkPremiumPercentage; } Config public s_config; error Reentrant(); modifier nonReentrant() { _nonReentrant(); _; } function _nonReentrant() internal view { if (s_config.reentrancyLock) { revert Reentrant(); } } constructor() ConfirmedOwner(msg.sender) {} /** * @notice set the LINK token contract and link native feed to be * used by this coordinator * @param link - address of link token * @param linkNativeFeed address of the link native feed */ function setLINKAndLINKNativeFeed(address link, address linkNativeFeed) external onlyOwner { // Disallow re-setting link token because the logic wouldn't really make sense if (address(LINK) != address(0)) { revert LinkAlreadySet(); } LINK = LinkTokenInterface(link); LINK_NATIVE_FEED = AggregatorV3Interface(linkNativeFeed); } /** * @notice Owner cancel subscription, sends remaining link directly to the subscription owner. * @param subId subscription id * @dev notably can be called even if there are pending requests, outstanding ones may fail onchain */ function ownerCancelSubscription(uint256 subId) external onlyOwner { address subOwner = s_subscriptionConfigs[subId].owner; if (subOwner == address(0)) { revert InvalidSubscription(); } _cancelSubscriptionHelper(subId, subOwner); } /** * @notice Recover link sent with transfer instead of transferAndCall. * @param to address to send link to */ function recoverFunds(address to) external onlyOwner { // If LINK is not set, we cannot recover funds. // It is possible that this coordinator address was funded with LINK // by accident by a user but the LINK token needs to be set first // before we can recover it. if (address(LINK) == address(0)) { revert LinkNotSet(); } uint256 externalBalance = LINK.balanceOf(address(this)); uint256 internalBalance = uint256(s_totalBalance); if (internalBalance > externalBalance) { revert BalanceInvariantViolated(internalBalance, externalBalance); } if (internalBalance < externalBalance) { uint256 amount = externalBalance - internalBalance; if (!LINK.transfer(to, amount)) { revert FailedToTransferLink(); } emit FundsRecovered(to, amount); } // If the balances are equal, nothing to be done. } /** * @notice Recover native sent with transfer/call/send instead of fundSubscription. * @param to address to send native to */ function recoverNativeFunds(address payable to) external onlyOwner { uint256 externalBalance = address(this).balance; uint256 internalBalance = uint256(s_totalNativeBalance); if (internalBalance > externalBalance) { revert BalanceInvariantViolated(internalBalance, externalBalance); } if (internalBalance < externalBalance) { uint256 amount = externalBalance - internalBalance; (bool sent, ) = to.call{value: amount}(""); if (!sent) { revert FailedToSendNative(); } emit NativeFundsRecovered(to, amount); } // If the balances are equal, nothing to be done. } /* * @notice withdraw LINK earned through fulfilling requests * @param recipient where to send the funds * @param amount amount to withdraw */ function withdraw(address recipient) external nonReentrant onlyOwner { if (address(LINK) == address(0)) { revert LinkNotSet(); } if (s_withdrawableTokens == 0) { revert InsufficientBalance(); } uint96 amount = s_withdrawableTokens; s_withdrawableTokens -= amount; s_totalBalance -= amount; if (!LINK.transfer(recipient, amount)) { revert InsufficientBalance(); } } /* * @notice withdraw native earned through fulfilling requests * @param recipient where to send the funds * @param amount amount to withdraw */ function withdrawNative(address payable recipient) external nonReentrant onlyOwner { if (s_withdrawableNative == 0) { revert InsufficientBalance(); } // Prevent re-entrancy by updating state before transfer. uint96 amount = s_withdrawableNative; s_withdrawableNative -= amount; s_totalNativeBalance -= amount; (bool sent, ) = recipient.call{value: amount}(""); if (!sent) { revert FailedToSendNative(); } } function onTokenTransfer(address /* sender */, uint256 amount, bytes calldata data) external override nonReentrant { if (msg.sender != address(LINK)) { revert OnlyCallableFromLink(); } if (data.length != 32) { revert InvalidCalldata(); } uint256 subId = abi.decode(data, (uint256)); if (s_subscriptionConfigs[subId].owner == address(0)) { revert InvalidSubscription(); } // We do not check that the sender is the subscription owner, // anyone can fund a subscription. uint256 oldBalance = s_subscriptions[subId].balance; s_subscriptions[subId].balance += uint96(amount); s_totalBalance += uint96(amount); emit SubscriptionFunded(subId, oldBalance, oldBalance + amount); } /** * @inheritdoc IVRFSubscriptionV2Plus */ function fundSubscriptionWithNative(uint256 subId) external payable override nonReentrant { if (s_subscriptionConfigs[subId].owner == address(0)) { revert InvalidSubscription(); } // We do not check that the msg.sender is the subscription owner, // anyone can fund a subscription. // We also do not check that msg.value > 0, since that's just a no-op // and would be a waste of gas on the caller's part. uint256 oldNativeBalance = s_subscriptions[subId].nativeBalance; s_subscriptions[subId].nativeBalance += uint96(msg.value); s_totalNativeBalance += uint96(msg.value); emit SubscriptionFundedWithNative(subId, oldNativeBalance, oldNativeBalance + msg.value); } /** * @inheritdoc IVRFSubscriptionV2Plus */ function getSubscription( uint256 subId ) public view override returns (uint96 balance, uint96 nativeBalance, uint64 reqCount, address subOwner, address[] memory consumers) { subOwner = s_subscriptionConfigs[subId].owner; if (subOwner == address(0)) { revert InvalidSubscription(); } return ( s_subscriptions[subId].balance, s_subscriptions[subId].nativeBalance, s_subscriptions[subId].reqCount, subOwner, s_subscriptionConfigs[subId].consumers ); } /** * @inheritdoc IVRFSubscriptionV2Plus */ function getActiveSubscriptionIds( uint256 startIndex, uint256 maxCount ) external view override returns (uint256[] memory ids) { uint256 numSubs = s_subIds.length(); if (startIndex >= numSubs) revert IndexOutOfRange(); uint256 endIndex = startIndex + maxCount; endIndex = endIndex > numSubs || maxCount == 0 ? numSubs : endIndex; uint256 idsLength = endIndex - startIndex; ids = new uint256[](idsLength); for (uint256 idx = 0; idx < idsLength; ++idx) { ids[idx] = s_subIds.at(idx + startIndex); } return ids; } /** * @inheritdoc IVRFSubscriptionV2Plus */ function createSubscription() external override nonReentrant returns (uint256 subId) { // Generate a subscription id that is globally unique. uint64 currentSubNonce = s_currentSubNonce; subId = uint256( keccak256(abi.encodePacked(msg.sender, blockhash(block.number - 1), address(this), currentSubNonce)) ); // Increment the subscription nonce counter. s_currentSubNonce = currentSubNonce + 1; // Initialize storage variables. address[] memory consumers = new address[](0); s_subscriptions[subId] = Subscription({balance: 0, nativeBalance: 0, reqCount: 0}); s_subscriptionConfigs[subId] = SubscriptionConfig({ owner: msg.sender, requestedOwner: address(0), consumers: consumers }); // Update the s_subIds set, which tracks all subscription ids created in this contract. s_subIds.add(subId); emit SubscriptionCreated(subId, msg.sender); return subId; } /** * @inheritdoc IVRFSubscriptionV2Plus */ function requestSubscriptionOwnerTransfer( uint256 subId, address newOwner ) external override onlySubOwner(subId) nonReentrant { // Proposing to address(0) would never be claimable so don't need to check. SubscriptionConfig storage subscriptionConfig = s_subscriptionConfigs[subId]; if (subscriptionConfig.requestedOwner != newOwner) { subscriptionConfig.requestedOwner = newOwner; emit SubscriptionOwnerTransferRequested(subId, msg.sender, newOwner); } } /** * @inheritdoc IVRFSubscriptionV2Plus */ function acceptSubscriptionOwnerTransfer(uint256 subId) external override nonReentrant { address oldOwner = s_subscriptionConfigs[subId].owner; if (oldOwner == address(0)) { revert InvalidSubscription(); } if (s_subscriptionConfigs[subId].requestedOwner != msg.sender) { revert MustBeRequestedOwner(s_subscriptionConfigs[subId].requestedOwner); } s_subscriptionConfigs[subId].owner = msg.sender; s_subscriptionConfigs[subId].requestedOwner = address(0); emit SubscriptionOwnerTransferred(subId, oldOwner, msg.sender); } /** * @inheritdoc IVRFSubscriptionV2Plus */ function addConsumer(uint256 subId, address consumer) external override onlySubOwner(subId) nonReentrant { ConsumerConfig storage consumerConfig = s_consumers[consumer][subId]; if (consumerConfig.active) { // Idempotence - do nothing if already added. // Ensures uniqueness in s_subscriptions[subId].consumers. return; } // Already maxed, cannot add any more consumers. address[] storage consumers = s_subscriptionConfigs[subId].consumers; if (consumers.length == MAX_CONSUMERS) { revert TooManyConsumers(); } // consumerConfig.nonce is 0 if the consumer had never sent a request to this subscription // otherwise, consumerConfig.nonce is non-zero // in both cases, use consumerConfig.nonce as is and set active status to true consumerConfig.active = true; consumers.push(consumer); emit SubscriptionConsumerAdded(subId, consumer); } function _deleteSubscription(uint256 subId) internal returns (uint96 balance, uint96 nativeBalance) { address[] storage consumers = s_subscriptionConfigs[subId].consumers; balance = s_subscriptions[subId].balance; nativeBalance = s_subscriptions[subId].nativeBalance; // Note bounded by MAX_CONSUMERS; // If no consumers, does nothing. uint256 consumersLength = consumers.length; for (uint256 i = 0; i < consumersLength; ++i) { delete s_consumers[consumers[i]][subId]; } delete s_subscriptionConfigs[subId]; delete s_subscriptions[subId]; s_subIds.remove(subId); if (balance != 0) { s_totalBalance -= balance; } if (nativeBalance != 0) { s_totalNativeBalance -= nativeBalance; } return (balance, nativeBalance); } function _cancelSubscriptionHelper(uint256 subId, address to) internal { (uint96 balance, uint96 nativeBalance) = _deleteSubscription(subId); // Only withdraw LINK if the token is active and there is a balance. if (address(LINK) != address(0) && balance != 0) { if (!LINK.transfer(to, uint256(balance))) { revert InsufficientBalance(); } } // send native to the "to" address using call (bool success, ) = to.call{value: uint256(nativeBalance)}(""); if (!success) { revert FailedToSendNative(); } emit SubscriptionCanceled(subId, to, balance, nativeBalance); } modifier onlySubOwner(uint256 subId) { _onlySubOwner(subId); _; } function _onlySubOwner(uint256 subId) internal view { address subOwner = s_subscriptionConfigs[subId].owner; if (subOwner == address(0)) { revert InvalidSubscription(); } if (msg.sender != subOwner) { revert MustBeSubOwner(subOwner); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; // End consumer library. library VRFV2PlusClient { // extraArgs will evolve to support new features bytes4 public constant EXTRA_ARGS_V1_TAG = bytes4(keccak256("VRF ExtraArgsV1")); struct ExtraArgsV1 { bool nativePayment; } struct RandomWordsRequest { bytes32 keyHash; uint256 subId; uint16 requestConfirmations; uint32 callbackGasLimit; uint32 numWords; bytes extraArgs; } function _argsToBytes(ExtraArgsV1 memory extraArgs) internal pure returns (bytes memory bts) { return abi.encodeWithSelector(EXTRA_ARGS_V1_TAG, extraArgs); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; // Future versions of VRFCoordinatorV2Plus must implement IVRFCoordinatorV2PlusMigration // to support migrations from previous versions interface IVRFCoordinatorV2PlusMigration { /** * @notice called by older versions of coordinator for migration. * @notice only callable by older versions of coordinator * @notice supports transfer of native currency * @param encodedData - user data from older version of coordinator */ function onMigration(bytes calldata encodedData) external payable; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {VRFV2PlusClient} from "../libraries/VRFV2PlusClient.sol"; import {IVRFSubscriptionV2Plus} from "./IVRFSubscriptionV2Plus.sol"; // Interface that enables consumers of VRFCoordinatorV2Plus to be future-proof for upgrades // This interface is supported by subsequent versions of VRFCoordinatorV2Plus interface IVRFCoordinatorV2Plus is IVRFSubscriptionV2Plus { /** * @notice Request a set of random words. * @param req - a struct containing following fields for randomness request: * 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. * subId - The ID of the VRF subscription. Must be funded * with the minimum subscription balance required for the selected keyHash. * requestConfirmations - 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]. * 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] * 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. * extraArgs - abi-encoded extra args * @return requestId - A unique identifier of the request. Can be used to match * a request to a response in fulfillRandomWords. */ function requestRandomWords(VRFV2PlusClient.RandomWordsRequest calldata req) external returns (uint256 requestId); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @notice The IVRFMigratableConsumerV2Plus interface defines the /// @notice method required to be implemented by all V2Plus consumers. /// @dev This interface is designed to be used in VRFConsumerBaseV2Plus. interface IVRFMigratableConsumerV2Plus { event CoordinatorSet(address vrfCoordinator); /// @notice Sets the VRF Coordinator address /// @notice This method should only be callable by the coordinator or contract owner function setCoordinator(address vrfCoordinator) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {ConfirmedOwnerWithProposal} from "./ConfirmedOwnerWithProposal.sol"; /// @title The ConfirmedOwner contract /// @notice A contract with helpers for basic contract ownership. contract ConfirmedOwner is ConfirmedOwnerWithProposal { constructor(address newOwner) ConfirmedOwnerWithProposal(newOwner, address(0)) {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
// 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) (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 (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * CAUTION: See Security Considerations above. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// 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) (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: MIT pragma solidity ^0.8.6; interface BetInterface { /** * @return player - address of player */ function getPlayer() external view returns (address); /** * @return amount - amount of bet */ function getAmount() external view returns (uint256); /** * @return result - amount of payout */ function getResult() external view returns (uint256); /** * @return status - status of bet */ function getStatus() external view returns (uint256); /** * @return game - address of game */ function getGame() external view returns (address); /** * @return timestamp - created timestamp of bet */ function getCreated() external view returns (uint256); /** * @return data - all data at once (player, game, amount, result, status, created) */ function getBetInfo() external view returns (address, address, uint256, uint256, uint256, uint256); }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/nitro/blob/master/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.4.21 <0.9.0; /** * @title System level functionality * @notice For use by contracts to interact with core L2-specific functionality. * Precompiled contract that exists in every Arbitrum chain at address(100), 0x0000000000000000000000000000000000000064. */ interface ArbSys { /** * @notice Get Arbitrum block number (distinct from L1 block number; Arbitrum genesis block has block number 0) * @return block number as int */ function arbBlockNumber() external view returns (uint256); /** * @notice Get Arbitrum block hash (reverts unless currentBlockNum-256 <= arbBlockNum < currentBlockNum) * @return block hash */ function arbBlockHash(uint256 arbBlockNum) external view returns (bytes32); /** * @notice Gets the rollup's unique chain identifier * @return Chain identifier as int */ function arbChainID() external view returns (uint256); /** * @notice Get internal version number identifying an ArbOS build * @return version number as int */ function arbOSVersion() external view returns (uint256); /** * @notice Returns 0 since Nitro has no concept of storage gas * @return uint 0 */ function getStorageGasAvailable() external view returns (uint256); /** * @notice (deprecated) check if current call is top level (meaning it was triggered by an EoA or a L1 contract) * @dev this call has been deprecated and may be removed in a future release * @return true if current execution frame is not a call by another L2 contract */ function isTopLevelCall() external view returns (bool); /** * @notice map L1 sender contract address to its L2 alias * @param sender sender address * @param unused argument no longer used * @return aliased sender address */ function mapL1SenderContractAddressToL2Alias(address sender, address unused) external pure returns (address); /** * @notice check if the caller (of this caller of this) is an aliased L1 contract address * @return true iff the caller's address is an alias for an L1 contract address */ function wasMyCallersAddressAliased() external view returns (bool); /** * @notice return the address of the caller (of this caller of this), without applying L1 contract address aliasing * @return address of the caller's caller, without applying L1 contract address aliasing */ function myCallersAddressWithoutAliasing() external view returns (address); /** * @notice Send given amount of Eth to dest from sender. * This is a convenience function, which is equivalent to calling sendTxToL1 with empty data. * @param destination recipient address on L1 * @return unique identifier for this L2-to-L1 transaction. */ function withdrawEth(address destination) external payable returns (uint256); /** * @notice Send a transaction to L1 * @dev it is not possible to execute on the L1 any L2-to-L1 transaction which contains data * to a contract address without any code (as enforced by the Bridge contract). * @param destination recipient address on L1 * @param data (optional) calldata for L1 contract call * @return a unique identifier for this L2-to-L1 transaction. */ function sendTxToL1(address destination, bytes calldata data) external payable returns (uint256); /** * @notice Get send Merkle tree state * @return size number of sends in the history * @return root root hash of the send history * @return partials hashes of partial subtrees in the send history tree */ function sendMerkleTreeState() external view returns ( uint256 size, bytes32 root, bytes32[] memory partials ); /** * @notice creates a send txn from L2 to L1 * @param position = (level << 192) + leaf = (0 << 192) + leaf = leaf */ event L2ToL1Tx( address caller, address indexed destination, uint256 indexed hash, uint256 indexed position, uint256 arbBlockNum, uint256 ethBlockNum, uint256 timestamp, uint256 callvalue, bytes data ); /// @dev DEPRECATED in favour of the new L2ToL1Tx event above after the nitro upgrade event L2ToL1Transaction( address caller, address indexed destination, uint256 indexed uniqueId, uint256 indexed batchNumber, uint256 indexInBatch, uint256 arbBlockNum, uint256 ethBlockNum, uint256 timestamp, uint256 callvalue, bytes data ); /** * @notice logs a merkle branch for proof synthesis * @param reserved an index meant only to align the 4th index with L2ToL1Transaction's 4th event * @param hash the merkle hash * @param position = (level << 192) + leaf */ event SendMerkleUpdate( uint256 indexed reserved, bytes32 indexed hash, uint256 indexed position ); }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.4.21 <0.9.0; /// @title Provides insight into the cost of using the chain. /// @notice These methods have been adjusted to account for Nitro's heavy use of calldata compression. /// Of note to end-users, we no longer make a distinction between non-zero and zero-valued calldata bytes. /// Precompiled contract that exists in every Arbitrum chain at 0x000000000000000000000000000000000000006c. interface ArbGasInfo { /// @notice Get gas prices for a provided aggregator /// @return return gas prices in wei /// ( /// per L2 tx, /// per L1 calldata byte /// per storage allocation, /// per ArbGas base, /// per ArbGas congestion, /// per ArbGas total /// ) function getPricesInWeiWithAggregator(address aggregator) external view returns ( uint256, uint256, uint256, uint256, uint256, uint256 ); /// @notice Get gas prices. Uses the caller's preferred aggregator, or the default if the caller doesn't have a preferred one. /// @return return gas prices in wei /// ( /// per L2 tx, /// per L1 calldata byte /// per storage allocation, /// per ArbGas base, /// per ArbGas congestion, /// per ArbGas total /// ) function getPricesInWei() external view returns ( uint256, uint256, uint256, uint256, uint256, uint256 ); /// @notice Get prices in ArbGas for the supplied aggregator /// @return (per L2 tx, per L1 calldata byte, per storage allocation) function getPricesInArbGasWithAggregator(address aggregator) external view returns ( uint256, uint256, uint256 ); /// @notice Get prices in ArbGas. Assumes the callers preferred validator, or the default if caller doesn't have a preferred one. /// @return (per L2 tx, per L1 calldata byte, per storage allocation) function getPricesInArbGas() external view returns ( uint256, uint256, uint256 ); /// @notice Get the gas accounting parameters. `gasPoolMax` is always zero, as the exponential pricing model has no such notion. /// @return (speedLimitPerSecond, gasPoolMax, maxTxGasLimit) function getGasAccountingParams() external view returns ( uint256, uint256, uint256 ); /// @notice Get the minimum gas price needed for a tx to succeed function getMinimumGasPrice() external view returns (uint256); /// @notice Get ArbOS's estimate of the L1 basefee in wei function getL1BaseFeeEstimate() external view returns (uint256); /// @notice Get how slowly ArbOS updates its estimate of the L1 basefee function getL1BaseFeeEstimateInertia() external view returns (uint64); /// @notice Get the L1 pricer reward rate, in wei per unit /// Available in ArbOS version 11 function getL1RewardRate() external view returns (uint64); /// @notice Get the L1 pricer reward recipient /// Available in ArbOS version 11 function getL1RewardRecipient() external view returns (address); /// @notice Deprecated -- Same as getL1BaseFeeEstimate() function getL1GasPriceEstimate() external view returns (uint256); /// @notice Get L1 gas fees paid by the current transaction function getCurrentTxL1GasFees() external view returns (uint256); /// @notice Get the backlogged amount of gas burnt in excess of the speed limit function getGasBacklog() external view returns (uint64); /// @notice Get how slowly ArbOS updates the L2 basefee in response to backlogged gas function getPricingInertia() external view returns (uint64); /// @notice Get the forgivable amount of backlogged gas ArbOS will ignore when raising the basefee function getGasBacklogTolerance() external view returns (uint64); /// @notice Returns the surplus of funds for L1 batch posting payments (may be negative). function getL1PricingSurplus() external view returns (int256); /// @notice Returns the base charge (in L1 gas) attributed to each data batch in the calldata pricer function getPerBatchGasCharge() external view returns (int64); /// @notice Returns the cost amortization cap in basis points function getAmortizedCostCapBips() external view returns (uint64); /// @notice Returns the available funds from L1 fees function getL1FeesAvailable() external view returns (uint256); /// @notice Returns the equilibration units parameter for L1 price adjustment algorithm /// Available in ArbOS version 20 function getL1PricingEquilibrationUnits() external view returns (uint256); /// @notice Returns the last time the L1 calldata pricer was updated. /// Available in ArbOS version 20 function getLastL1PricingUpdateTime() external view returns (uint64); /// @notice Returns the amount of L1 calldata payments due for rewards (per the L1 reward rate) /// Available in ArbOS version 20 function getL1PricingFundsDueForRewards() external view returns (uint256); /// @notice Returns the amount of L1 calldata posted since the last update. /// Available in ArbOS version 20 function getL1PricingUnitsSinceUpdate() external view returns (uint64); /// @notice Returns the L1 pricing surplus as of the last update (may be negative). /// Available in ArbOS version 20 function getLastL1PricingSurplus() external view returns (int256); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; /* External Imports */ import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; /** * @title OVM_GasPriceOracle * @dev This contract exposes the current l2 gas price, a measure of how congested the network * currently is. This measure is used by the Sequencer to determine what fee to charge for * transactions. When the system is more congested, the l2 gas price will increase and fees * will also increase as a result. * * All public variables are set while generating the initial L2 state. The * constructor doesn't run in practice as the L2 state generation script uses * the deployed bytecode instead of running the initcode. */ contract OVM_GasPriceOracle is Ownable { /************* * Variables * *************/ // Current L2 gas price uint256 public gasPrice; // Current L1 base fee uint256 public l1BaseFee; // Amortized cost of batch submission per transaction uint256 public overhead; // Value to scale the fee up by uint256 public scalar; // Number of decimals of the scalar uint256 public decimals; /*************** * Constructor * ***************/ /** * @param _owner Address that will initially own this contract. */ constructor(address _owner) Ownable() { transferOwnership(_owner); } /********** * Events * **********/ event GasPriceUpdated(uint256); event L1BaseFeeUpdated(uint256); event OverheadUpdated(uint256); event ScalarUpdated(uint256); event DecimalsUpdated(uint256); /******************** * Public Functions * ********************/ /** * Allows the owner to modify the l2 gas price. * @param _gasPrice New l2 gas price. */ // slither-disable-next-line external-function function setGasPrice(uint256 _gasPrice) public onlyOwner { gasPrice = _gasPrice; emit GasPriceUpdated(_gasPrice); } /** * Allows the owner to modify the l1 base fee. * @param _baseFee New l1 base fee */ // slither-disable-next-line external-function function setL1BaseFee(uint256 _baseFee) public onlyOwner { l1BaseFee = _baseFee; emit L1BaseFeeUpdated(_baseFee); } /** * Allows the owner to modify the overhead. * @param _overhead New overhead */ // slither-disable-next-line external-function function setOverhead(uint256 _overhead) public onlyOwner { overhead = _overhead; emit OverheadUpdated(_overhead); } /** * Allows the owner to modify the scalar. * @param _scalar New scalar */ // slither-disable-next-line external-function function setScalar(uint256 _scalar) public onlyOwner { scalar = _scalar; emit ScalarUpdated(_scalar); } /** * Allows the owner to modify the decimals. * @param _decimals New decimals */ // slither-disable-next-line external-function function setDecimals(uint256 _decimals) public onlyOwner { decimals = _decimals; emit DecimalsUpdated(_decimals); } /** * Computes the L1 portion of the fee * based on the size of the RLP encoded tx * and the current l1BaseFee * @param _data Unsigned RLP encoded tx, 6 elements * @return L1 fee that should be paid for the tx */ // slither-disable-next-line external-function function getL1Fee(bytes memory _data) public view returns (uint256) { uint256 l1GasUsed = getL1GasUsed(_data); uint256 l1Fee = l1GasUsed * l1BaseFee; uint256 divisor = 10 ** decimals; uint256 unscaled = l1Fee * scalar; uint256 scaled = unscaled / divisor; return scaled; } // solhint-disable max-line-length /** * Computes the amount of L1 gas used for a transaction * The overhead represents the per batch gas overhead of * posting both transaction and state roots to L1 given larger * batch sizes. * 4 gas for 0 byte * https://github.com/ethereum/go-ethereum/blob/9ada4a2e2c415e6b0b51c50e901336872e028872/params/protocol_params.go#L33 * 16 gas for non zero byte * https://github.com/ethereum/go-ethereum/blob/9ada4a2e2c415e6b0b51c50e901336872e028872/params/protocol_params.go#L87 * This will need to be updated if calldata gas prices change * Account for the transaction being unsigned * Padding is added to account for lack of signature on transaction * 1 byte for RLP V prefix * 1 byte for V * 1 byte for RLP R prefix * 32 bytes for R * 1 byte for RLP S prefix * 32 bytes for S * Total: 68 bytes of padding * @param _data Unsigned RLP encoded tx, 6 elements * @return Amount of L1 gas used for a transaction */ // solhint-enable max-line-length function getL1GasUsed(bytes memory _data) public view returns (uint256) { uint256 total = 0; for (uint256 i = 0; i < _data.length; i++) { if (_data[i] == 0) { total += 4; } else { total += 16; } } uint256 unsigned = total + overhead; return unsigned + (68 * 16); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js. pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet. * ==== */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastValue; // Update the index for the moved value set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values in the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // solhint-disable-next-line interface-starts-with-i interface LinkTokenInterface { function allowance(address owner, address spender) external view returns (uint256 remaining); function approve(address spender, uint256 value) external returns (bool success); function balanceOf(address owner) external view returns (uint256 balance); function decimals() external view returns (uint8 decimalPlaces); function decreaseApproval(address spender, uint256 addedValue) external returns (bool success); function increaseApproval(address spender, uint256 subtractedValue) external; function name() external view returns (string memory tokenName); function symbol() external view returns (string memory tokenSymbol); function totalSupply() external view returns (uint256 totalTokensIssued); function transfer(address to, uint256 value) external returns (bool success); function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool success); function transferFrom(address from, address to, uint256 value) external returns (bool success); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // solhint-disable-next-line interface-starts-with-i interface AggregatorV3Interface { function decimals() external view returns (uint8); function description() external view returns (string memory); function version() external view returns (uint256); function getRoundData( uint80 _roundId ) external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound); function latestRoundData() external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.6; interface IERC677Receiver { function onTokenTransfer(address sender, uint256 amount, bytes calldata data) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @notice The IVRFSubscriptionV2Plus interface defines the subscription /// @notice related methods implemented by the V2Plus coordinator. interface IVRFSubscriptionV2Plus { /** * @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(uint256 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(uint256 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(uint256 subId, address to) external; /** * @notice Accept 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(uint256 subId) external; /** * @notice Request subscription owner transfer. * @param subId - ID of the subscription * @param newOwner - proposed new owner of the subscription */ function requestSubscriptionOwnerTransfer(uint256 subId, address newOwner) external; /** * @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 with LINK, use transferAndCall. For example * @dev LINKTOKEN.transferAndCall( * @dev address(COORDINATOR), * @dev amount, * @dev abi.encode(subId)); * @dev Note to fund the subscription with Native, use fundSubscriptionWithNative. Be sure * @dev to send Native with the call, for example: * @dev COORDINATOR.fundSubscriptionWithNative{value: amount}(subId); */ function createSubscription() external returns (uint256 subId); /** * @notice Get a VRF subscription. * @param subId - ID of the subscription * @return balance - LINK balance of the subscription in juels. * @return nativeBalance - native balance of the subscription in wei. * @return reqCount - Requests count of subscription. * @return owner - owner of the subscription. * @return consumers - list of consumer address which are able to use this subscription. */ function getSubscription( uint256 subId ) external view returns (uint96 balance, uint96 nativeBalance, uint64 reqCount, address owner, address[] memory consumers); /* * @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(uint256 subId) external view returns (bool); /** * @notice Paginate through all active VRF subscriptions. * @param startIndex index of the subscription to start from * @param maxCount maximum number of subscriptions to return, 0 to return all * @dev the order of IDs in the list is **not guaranteed**, therefore, if making successive calls, one * @dev should consider keeping the blockheight constant to ensure a holistic picture of the contract state */ function getActiveSubscriptionIds(uint256 startIndex, uint256 maxCount) external view returns (uint256[] memory); /** * @notice Fund a subscription with native. * @param subId - ID of the subscription * @notice This method expects msg.value to be greater than or equal to 0. */ function fundSubscriptionWithNative(uint256 subId) external payable; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {IOwnable} from "../interfaces/IOwnable.sol"; /// @title The ConfirmedOwner contract /// @notice A contract with helpers for basic contract ownership. contract ConfirmedOwnerWithProposal is IOwnable { address private s_owner; address private s_pendingOwner; event OwnershipTransferRequested(address indexed from, address indexed to); event OwnershipTransferred(address indexed from, address indexed to); constructor(address newOwner, address pendingOwner) { // solhint-disable-next-line gas-custom-errors require(newOwner != address(0), "Cannot set owner to zero"); s_owner = newOwner; if (pendingOwner != address(0)) { _transferOwnership(pendingOwner); } } /// @notice Allows an owner to begin transferring ownership to a new address. function transferOwnership(address to) public override onlyOwner { _transferOwnership(to); } /// @notice Allows an ownership transfer to be completed by the recipient. function acceptOwnership() external override { // solhint-disable-next-line gas-custom-errors require(msg.sender == s_pendingOwner, "Must be proposed owner"); address oldOwner = s_owner; s_owner = msg.sender; s_pendingOwner = address(0); emit OwnershipTransferred(oldOwner, msg.sender); } /// @notice Get the current owner function owner() public view override returns (address) { return s_owner; } /// @notice validate, transfer ownership, and emit relevant events function _transferOwnership(address to) private { // solhint-disable-next-line gas-custom-errors require(to != msg.sender, "Cannot transfer to self"); s_pendingOwner = to; emit OwnershipTransferRequested(s_owner, to); } /// @notice validate access function _validateOwnership() internal view { // solhint-disable-next-line gas-custom-errors require(msg.sender == s_owner, "Only callable by owner"); } /// @notice Reverts if called by anyone other than the contract owner. modifier onlyOwner() { _validateOwnership(); _; } }
// 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); } } }
// 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 pragma solidity ^0.8.0; interface IOwnable { function owner() external returns (address); function transferOwnership(address recipient) external; function acceptOwnership() external; }
{ "remappings": [ "ds-test/=lib/forge-std/lib/ds-test/src/", "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/", "forge-std/=lib/forge-std/src/", "openzeppelin/=lib/openzeppelin-contracts/contracts/", "chainlink/=lib/chainlink/contracts/src/v0.8/", "@openzeppelin/=lib/openzeppelin-contracts/", "openzeppelin-contracts/=lib/openzeppelin-contracts/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } }, "evmVersion": "paris", "viaIR": false, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_core","type":"address"},{"internalType":"address","name":"_staking","type":"address"},{"internalType":"address","name":"_admin","type":"address"},{"internalType":"uint256","name":"_subscriptionId","type":"uint256"},{"internalType":"address","name":"_vrfCoordinator","type":"address"},{"internalType":"bytes32","name":"_keyHash","type":"bytes32"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"have","type":"address"},{"internalType":"address","name":"want","type":"address"}],"name":"OnlyCoordinatorCanFulfill","type":"error"},{"inputs":[{"internalType":"address","name":"have","type":"address"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"coordinator","type":"address"}],"name":"OnlyOwnerOrCoordinator","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"player","type":"address"},{"indexed":true,"internalType":"uint256","name":"round","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"BetCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"player","type":"address"},{"indexed":true,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"BonusClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"vrfCoordinator","type":"address"}],"name":"CoordinatorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"OwnershipTransferRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"round","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"requestId","type":"uint256"}],"name":"RequestedCalculation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"round","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"RoundStart","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"round","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"winnerOffset","type":"uint256"},{"indexed":true,"internalType":"address","name":"bet","type":"address"}],"name":"WinnerCalculated","type":"event"},{"inputs":[],"name":"BETS_LIMIT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"BONUS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_BET_AMOUNT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ROUND_DURATION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SERVICE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TIMELOCK","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_service","type":"address"}],"name":"addService","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"betsPlayer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"player","type":"address"}],"name":"claimBonus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"claimableBonus","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"core","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"created","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"round","type":"uint256"},{"internalType":"uint256","name":"offset","type":"uint256"},{"internalType":"uint256","name":"limit","type":"uint256"}],"name":"distribute","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"distributedBetCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"round","type":"uint256"}],"name":"getBetsCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentRound","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getFeeType","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"player","type":"address"}],"name":"getPlayersRoundsCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStaking","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVersion","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"isRoundPlayer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"keyHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"lastOffset","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_player","type":"address"},{"internalType":"uint256","name":"_totalAmount","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"placeBet","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"playersRounds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"round","type":"uint256"}],"name":"requestCalculation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"requestConfirmations","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"requestRounds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"roundBank","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"roundBetDistributed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"roundBets","outputs":[{"internalType":"contract LuckyRoundBet","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"roundBonusShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"roundDistribution","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"roundPlayerBetsCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"roundPlayerVolume","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"roundPlayersCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"roundRequests","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"roundStatus","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"roundWinners","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"s_vrfCoordinator","outputs":[{"internalType":"contract IVRFCoordinatorV2Plus","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_vrfCoordinator","type":"address"}],"name":"setCoordinator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"setMinBetAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"staking","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"vrfCoordinator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
610180604052683635c9adc5dea000006005553480156200001f57600080fd5b50604051620038043803806200380483398101604081905262000042916200048a565b8133806000816200009a5760405162461bcd60e51b815260206004820152601860248201527f43616e6e6f7420736574206f776e657220746f207a65726f000000000000000060448201526064015b60405180910390fd5b600180546001600160a01b0319166001600160a01b0384811691909117909155811615620000cd57620000cd8162000320565b5050506001600160a01b038116620000f85760405163d92e233d60e01b815260040160405180910390fd5b600380546001600160a01b0319166001600160a01b0392831617905560016004558216620001525760405162461bcd60e51b81526004016200009190602080825260049082015263524f303160e01b604082015260600190565b6001600160a01b038083166101205261014082905261010084905242608052861660a081905260408051637e062a3560e11b8152905163fc0c546a916004808201926020929091908290030181865afa158015620001b4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001da9190620004f9565b6001600160a01b0390811660c052604051636f49712b60e01b8152868216600482015290871690636f49712b90602401602060405180830381865afa15801562000228573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200024e91906200051e565b620002825760405162461bcd60e51b81526020600482015260036024820152624c303160e81b604482015260640162000091565b846001600160a01b031660e0816001600160a01b03168152505060a0516001600160a01b031663ddca3f436040518163ffffffff1660e01b8152600401602060405180830381865afa158015620002dd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000303919062000542565b6101605262000314600085620003cc565b5050505050506200055c565b336001600160a01b038216036200037a5760405162461bcd60e51b815260206004820152601760248201527f43616e6e6f74207472616e7366657220746f2073656c66000000000000000000604482015260640162000091565b600280546001600160a01b0319166001600160a01b03838116918217909255600154604051919216907fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae127890600090a350565b6000828152602081815260408083206001600160a01b038516845290915290205460ff1662000469576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055620004283390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b80516001600160a01b03811681146200048557600080fd5b919050565b60008060008060008060c08789031215620004a457600080fd5b620004af876200046d565b9550620004bf602088016200046d565b9450620004cf604088016200046d565b935060608701519250620004e6608088016200046d565b915060a087015190509295509295509295565b6000602082840312156200050c57600080fd5b62000517826200046d565b9392505050565b6000602082840312156200053157600080fd5b815180151581146200051757600080fd5b6000602082840312156200055557600080fd5b5051919050565b60805160a05160c05160e05161010051610120516101405161016051613211620005f360003960006120810152600081816106ef0152611c050152600081816108b30152611bcb01526000611c2b0152600081816106570152610793015260008181610a7d01528181610b8a01526120cf015260008181610a270152610dcb015260008181610432015261059001526132116000f3fe60806040523480156200001157600080fd5b5060043610620003cd5760003560e01c80636c1885931162000205578063a32bf5971162000125578063c6c834ca11620000bb578063f2f4eb261162000086578063f2f4eb261462000a21578063f2fde38b1462000a49578063f678ef871462000a60578063fc0c546a1462000a7757600080fd5b8063c6c834ca146200098c578063d2de6ec514620009ba578063d547741f14620009d1578063e35154a514620009e857600080fd5b8063b0f733bd11620000fc578063b0f733bd14620008fb578063b0fb162f1462000929578063bae638161462000946578063c2ff1d9e146200096957600080fd5b8063a32bf59714620008a3578063a3e56fa814620008ad578063a5087f6814620008d557600080fd5b80638da5cb5b116200019b5780639a7e25cd11620001725780639a7e25cd14620008325780639c8c962914620008635780639eccacf61462000886578063a217fddf146200089a57600080fd5b80638da5cb5b14620007f25780638ea98117146200080457806391d14854146200081b57600080fd5b80637aadef8b11620001dc5780637aadef8b14620007695780637b1391a6146200079157806381b7926714620007b85780638b6f685514620007cf57600080fd5b80636c188593146200072557806376a4956c146200073c57806379ba5097146200075f57600080fd5b8063344a186d11620002f157806351a78c9f11620002875780635ef8ac19116200025e5780635ef8ac1914620006bd57806361728f3914620006e95780636475e3d314620007115780636641ea08146200071b57600080fd5b806351a78c9f14620006795780635372a9ce146200069c578063573cb42714620006b357600080fd5b80633ce9a40811620002c85780633ce9a408146200060157806349841b9314620006245780634b8624c414620006475780634cf088d9146200065157600080fd5b8063344a186d14620005b257806336568abe14620005e357806338cc483114620005fa57600080fd5b8063248a9ca311620003675780632f2ff15d116200033e5780632f2ff15d146200052c5780632f9d50351462000543578063317ed999146200055a578063325a19f1146200058a57600080fd5b8063248a9ca314620004d25780632af1272a14620004f85780632d760642146200052457600080fd5b80630e99f5e611620003a85780630e99f5e6146200045757806317b022fc14620004705780631fe543e314620004985780632100de5d14620004af57600080fd5b806301ffc9a714620003d257806305c4cb4514620003fe5780630d8e6e2c1462000430575b600080fd5b620003e9620003e3366004620025a8565b62000a9f565b60405190151581526020015b60405180910390f35b620004216200040f366004620025d4565b6000908152600a602052604090205490565b604051908152602001620003f5565b7f000000000000000000000000000000000000000000000000000000000000000062000421565b6200046e6200046836600462002604565b62000ad7565b005b620004217facbad678df5731cc63969722859e16a5c8f2854c5e50a0dbc23355ef474f97e281565b6200046e620004a936600462002624565b62000c68565b62000421620004c0366004620025d4565b60076020526000908152604090205481565b62000421620004e3366004620025d4565b60009081526020819052604090206001015490565b620004216200050936600462002604565b6001600160a01b031660009081526009602052604090205490565b600062000421565b6200046e6200053d366004620026a8565b62000cbc565b6200046e62000554366004620025d4565b62000ce5565b620005716200056b366004620026db565b62000dbe565b6040516001600160a01b039091168152602001620003f5565b620004217f000000000000000000000000000000000000000000000000000000000000000081565b620003e9620005c3366004620026a8565b600860209081526000928352604080842090915290825290205460ff1681565b6200046e620005f4366004620026a8565b62001322565b3062000571565b6200042162000612366004620025d4565b60156020526000908152604090205481565b620004216200063536600462002604565b600b6020526000908152604090205481565b620004216101f481565b620005717f000000000000000000000000000000000000000000000000000000000000000081565b620004216200068a366004620025d4565b600d6020526000908152604090205481565b6200046e620006ad36600462002604565b620013a4565b620004216103e881565b62000571620006ce36600462002604565b600f602052600090815260409020546001600160a01b031681565b620004217f000000000000000000000000000000000000000000000000000000000000000081565b6200042160055481565b6200042161012c81565b6200046e62000736366004620025d4565b620013fc565b620004216200074d366004620025d4565b60136020526000908152604090205481565b6200046e62001483565b620004217faefebe170cbaff0af052a32795af0e1b8afff9850f946ad2869be14f3553437181565b7f000000000000000000000000000000000000000000000000000000000000000062000571565b62000571620007c93660046200276b565b62001533565b62000421620007e0366004620025d4565b60066020526000908152604090205481565b6001546001600160a01b031662000571565b6200046e6200081536600462002604565b6200156c565b620003e96200082c366004620026a8565b62001663565b620003e962000843366004620026a8565b601660209081526000928352604080842090915290825290205460ff1681565b6200042162000874366004620025d4565b600c6020526000908152604090205481565b60035462000571906001600160a01b031681565b62000421600081565b620004216200168c565b620005717f000000000000000000000000000000000000000000000000000000000000000081565b620003e9620008e6366004620025d4565b60146020526000908152604090205460ff1681565b620004216200090c366004620026a8565b601060209081526000928352604080842090915290825290205481565b62000932600381565b60405161ffff9091168152602001620003f5565b6200042162000957366004620025d4565b60176020526000908152604090205481565b620004216200097a366004620025d4565b600e6020526000908152604090205481565b620004216200099d366004620026a8565b601160209081526000928352604080842090915290825290205481565b6200046e620009cb3660046200278e565b620016a1565b6200046e620009e2366004620026a8565b62001a29565b62000a0e620009f9366004620025d4565b60126020526000908152604090205460ff1681565b60405160ff9091168152602001620003f5565b620005717f000000000000000000000000000000000000000000000000000000000000000081565b6200046e62000a5a36600462002604565b62001a52565b6200042162000a71366004620027bb565b62001a67565b620005717f000000000000000000000000000000000000000000000000000000000000000081565b60006001600160e01b03198216637965db0b60e01b148062000ad157506301ffc9a760e01b6001600160e01b03198316145b92915050565b336001600160a01b038216148062000b16575062000b167facbad678df5731cc63969722859e16a5c8f2854c5e50a0dbc23355ef474f97e23362001663565b62000b4e5760405162461bcd60e51b815260206004820152600360248201526226181960e91b60448201526064015b60405180910390fd5b6001600160a01b038181166000818152600b602052604080822080549290555163a9059cbb60e01b8152600481019290925260248201819052917f0000000000000000000000000000000000000000000000000000000000000000169063a9059cbb906044016020604051808303816000875af115801562000bd4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000bfa9190620027ea565b62000c2e5760405162461bcd60e51b8152602060048201526003602482015262130c4d60ea1b604482015260640162000b45565b60405181906001600160a01b038416907f4e69fdc49495bcab2b4375781457ba16653a90eb4ffb6588351bdc39071433e290600090a35050565b6003546001600160a01b0316331462000caa5760035460405163073e64fd60e21b81523360048201526001600160a01b03909116602482015260440162000b45565b62000cb783838362001a99565b505050565b60008281526020819052604090206001015462000cd98162001b29565b62000cb7838362001b35565b62000cef6200168c565b811062000d255760405162461bcd60e51b81526020600482015260036024820152624c303960e81b604482015260640162000b45565b60008181526012602052604090205460ff161562000d6c5760405162461bcd60e51b815260206004820152600360248201526204c31360ec1b604482015260640162000b45565b6000818152600a60205260408120541162000db05760405162461bcd60e51b81526020600482015260036024820152624c313160e81b604482015260640162000b45565b62000dbb8162001bbd565b50565b6000336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161462000e205760405162461bcd60e51b81526020600482015260036024820152624c313360e81b604482015260640162000b45565b6000808062000e32858701876200280e565b925092509250876001600160a01b0316836001600160a01b03161462000e815760405162461bcd60e51b815260206004820152600360248201526226181960e91b604482015260640162000b45565b8662000e9683670de0b6b3a76400006200285c565b1462000ecb5760405162461bcd60e51b81526020600482015260036024820152624c303360e81b604482015260640162000b45565b60055487101562000f055760405162461bcd60e51b81526020600482015260036024820152624c303560e81b604482015260640162000b45565b62000f0f6200168c565b811462000f455760405162461bcd60e51b8152602060048201526003602482015262130c0d60ea1b604482015260640162000b45565b6000818152600a60205260409020546103e89062000f6590600162002876565b111562000f9b5760405162461bcd60e51b81526020600482015260036024820152624c303760e81b604482015260640162000b45565b60008181526012602052604090205460ff161562000fe25760405162461bcd60e51b815260206004820152600360248201526204c31360ec1b604482015260640162000b45565b60008181526017602052604081205462000ffe90600162002876565b90508260176000848152602001908152602001600020600082825462001025919062002876565b92505081905550600084308a8585601760008981526020019081526020016000205460405162001055906200259a565b6001600160a01b03968716815295909416602086015260408501929092526060840152608083015260a082015260c001604051809103906000f080158015620010a2573d6000803e3d6000fd5b506000848152600a6020908152604080832080546001810182559084528284200180546001600160a01b0319166001600160a01b038681169190911790915587845260088352818420908a16845290915290205490915060ff16620011775760008381526008602090815260408083206001600160a01b03891684528252808320805460ff191660011790558583526007909152812080549162001146836200288c565b90915550506001600160a01b0385166000908152600960209081526040822080546001810182559083529120018390555b60008381526010602090815260408083206001600160a01b0389168452909152812080548b9290620011ab90849062002876565b909155505060008381526011602090815260408083206001600160a01b03891684529091528120805491620011e0836200288c565b9091555050600083815260066020526040812080548b92906200120590849062002876565b9091555050600083815260066020908152604080832054600e90925282208054919290916200123690849062002876565b90915550506001600160a01b038181166000908152600f6020908152604080832080546001600160a01b031916948a1694909417909355858252600a905220546103e890036200128b576200128b8362001bbd565b82856001600160a01b03167faf103d0232378bce6bbef82b15d24edd12fed7effcec1f97252b2f2e45fe4a3b8b604051620012c891815260200190565b60405180910390a36000838152600a60205260409020546001036200131557604051429084907f63d859dfe6122a9b44f82878adcca8b281f61490464164bb5df15c3450e3e08c90600090a35b9998505050505050505050565b6001600160a01b0381163314620013945760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b606482015260840162000b45565b620013a0828262001d67565b5050565b7faefebe170cbaff0af052a32795af0e1b8afff9850f946ad2869be14f35534371620013d08162001b29565b620013a07facbad678df5731cc63969722859e16a5c8f2854c5e50a0dbc23355ef474f97e28362001b35565b7faefebe170cbaff0af052a32795af0e1b8afff9850f946ad2869be14f35534371620014288162001b29565b670de0b6b3a76400008211801562001449575069d3c21bcecceda100000082105b6200147d5760405162461bcd60e51b815260206004820152600360248201526226181b60e91b604482015260640162000b45565b50600555565b6002546001600160a01b03163314620014d85760405162461bcd60e51b815260206004820152601660248201527526bab9ba10313290383937b837b9b2b21037bbb732b960511b604482015260640162000b45565b600180546001600160a01b0319808216339081179093556002805490911690556040516001600160a01b03909116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a350565b600a60205281600052604060002081815481106200155057600080fd5b6000918252602090912001546001600160a01b03169150829050565b6001546001600160a01b031633148015906200159357506003546001600160a01b03163314155b15620015e75733620015ad6001546001600160a01b031690565b60035460405163061db9c160e01b81526001600160a01b039384166004820152918316602483015291909116604482015260640162000b45565b6001600160a01b0381166200160f5760405163d92e233d60e01b815260040160405180910390fd5b600380546001600160a01b0319166001600160a01b0383169081179091556040519081527fd1a6a14209a385a964d036e404cb5cfb71f4000cdb03c9366292430787261be69060200160405180910390a150565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b60006200169c61012c42620028be565b905090565b620016ab6200168c565b8310620016e15760405162461bcd60e51b81526020600482015260036024820152624c303960e81b604482015260640162000b45565b60008381526012602052604090205460ff166002146200172a5760405162461bcd60e51b815260206004820152600360248201526226189960e91b604482015260640162000b45565b60008381526014602052604090205460ff1615620017715760405162461bcd60e51b815260206004820152600360248201526209860760eb1b604482015260640162000b45565b6000838152600a602090815260408083206013835281842054600e84528285205460069094529184205490939192919061271090620017b4906101f4906200285c565b620017c09190620028be565b9050855b620017d0868862002876565b811015620019e4578454811015620019e4576000858281548110620017f957620017f9620028d5565b60009182526020808320909101548b83526016825260408084206001600160a01b039092168085529190925291205490915060ff16156200183b5750620019cf565b6001600160a01b038082166000908152600f6020526040812054885492169162001867908590620028eb565b836001600160a01b031663d321fe296040518163ffffffff1660e01b8152600401602060405180830381865afa158015620018a6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620018cc919062002901565b620018d891906200285c565b9050600086620018e983886200285c565b620018f59190620028be565b6001600160a01b0384166000908152600b60205260408120805492935083929091906200192490849062002876565b909155505060008c81526016602090815260408083206001600160a01b038816808552925291829020805460ff19166001179055905163812448a560e01b8152600481018a905263812448a590602401600060405180830381600087803b1580156200198f57600080fd5b505af1158015620019a4573d6000803e3d6000fd5b50505060008d81526015602052604081208054925090620019c5836200288c565b9190505550505050505b80620019db816200288c565b915050620017c4565b506000878152600a60209081526040808320546015909252909120540362001a20576000878152601460205260409020805460ff191660011790555b50505050505050565b60008281526020819052604090206001015462001a468162001b29565b62000cb7838362001d67565b62001a5c62001dcf565b62000dbb8162001e26565b6009602052816000526040600020818154811062001a8457600080fd5b90600052602060002001600091509150505481565b6000838152600d602090815260408083205480845260179092528220549091908484838162001acc5762001acc620028d5565b9050602002013562001adf91906200291b565b62001aec90600162002876565b6000838152601360205260409020819055905062001b0a8262001ed2565b506000908152601260205260409020805460ff19166002179055505050565b62000dbb813362002295565b62001b41828262001663565b620013a0576000828152602081815260408083206001600160a01b03851684529091529020805460ff1916600117905562001b793390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b62001bc7620022f9565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316639b1c385e6040518060c001604052807f000000000000000000000000000000000000000000000000000000000000000081526020017f00000000000000000000000000000000000000000000000000000000000000008152602001600361ffff168152602001622625a063ffffffff168152602001600163ffffffff16815260200162001c9260405180602001604052806000151581525062002354565b8152506040518263ffffffff1660e01b815260040162001cb3919062002986565b6020604051808303816000875af115801562001cd3573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001cf9919062002901565b6000838152600c60209081526040808320849055838352600d82528083208690558583526012909152808220805460ff1916600117905551919250829184917fca1a840a958890962f5385264bcf166eb5254ef65f4a241ce7c9635d4f65466491a35062000dbb6001600455565b62001d73828262001663565b15620013a0576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6001546001600160a01b0316331462001e245760405162461bcd60e51b815260206004820152601660248201527527b7363c9031b0b63630b1363290313c9037bbb732b960511b604482015260640162000b45565b565b336001600160a01b0382160362001e805760405162461bcd60e51b815260206004820152601760248201527f43616e6e6f74207472616e7366657220746f2073656c66000000000000000000604482015260640162000b45565b600280546001600160a01b0319166001600160a01b03838116918217909255600154604051919216907fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae127890600090a350565b62001edc620022f9565b600081815260136020908152604080832054600a9092528220805491929091819062001f0b90600190620028eb565b90505b80821162002286576000600262001f26838562002876565b62001f329190620028be565b9050600084828154811062001f4b5762001f4b620028d5565b60009182526020808320909101546040805163b79a751760e01b815290516001600160a01b039092169450849263b79a7517926004808401938290030181865afa15801562001f9e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001fc4919062002901565b90506000826001600160a01b0316635c88a6576040518163ffffffff1660e01b8152600401602060405180830381865afa15801562002007573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200202d919062002901565b9050878211158015620020405750878110155b156200224e5760008981526006602052604081205490612710620020676101f4846200285c565b620020739190620028be565b9050600081612710620020a77f0000000000000000000000000000000000000000000000000000000000000000866200285c565b620020b39190620028be565b620020bf9085620028eb565b620020cb9190620028eb565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663a9059cbb876001600160a01b0316633308f42d6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200213b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620021619190620029ed565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602481018490526044016020604051808303816000875af1158015620021af573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620021d59190620027ea565b620022095760405162461bcd60e51b8152602060048201526003602482015262130c4d60ea1b604482015260640162000b45565b856001600160a01b03168b8d7fc8aa5aac082dfa4d9ecbd022c327bca40a5bd58dde373da553268297d488e4bc60405160405180910390a45050505050505062002286565b878110156200226c576200226484600162002876565b95506200227c565b62002279600185620028eb565b94505b5050505062001f0e565b5050505062000dbb6001600455565b620022a1828262001663565b620013a057620022b181620023c6565b620022be836020620023d9565b604051602001620022d192919062002a0d565b60408051601f198184030181529082905262461bcd60e51b825262000b459160040162002a86565b6002600454036200234d5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640162000b45565b6002600455565b60607f92fd13387c7fe7befbc38d303d6468778fb9731bc4583f17d92989c6fcfdeaaa826040516024016200238e91511515815260200190565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915292915050565b606062000ad16001600160a01b03831660145b60606000620023ea8360026200285c565b620023f790600262002876565b67ffffffffffffffff81111562002412576200241262002a9b565b6040519080825280601f01601f1916602001820160405280156200243d576020820181803683370190505b509050600360fc1b816000815181106200245b576200245b620028d5565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106200248d576200248d620028d5565b60200101906001600160f81b031916908160001a9053506000620024b38460026200285c565b620024c090600162002876565b90505b600181111562002542576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110620024f857620024f8620028d5565b1a60f81b828281518110620025115762002511620028d5565b60200101906001600160f81b031916908160001a90535060049490941c936200253a8162002ab1565b9050620024c3565b508315620025935760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640162000b45565b9392505050565b6107108062002acc83390190565b600060208284031215620025bb57600080fd5b81356001600160e01b0319811681146200259357600080fd5b600060208284031215620025e757600080fd5b5035919050565b6001600160a01b038116811462000dbb57600080fd5b6000602082840312156200261757600080fd5b81356200259381620025ee565b6000806000604084860312156200263a57600080fd5b83359250602084013567ffffffffffffffff808211156200265a57600080fd5b818601915086601f8301126200266f57600080fd5b8135818111156200267f57600080fd5b8760208260051b85010111156200269557600080fd5b6020830194508093505050509250925092565b60008060408385031215620026bc57600080fd5b823591506020830135620026d081620025ee565b809150509250929050565b60008060008060608587031215620026f257600080fd5b8435620026ff81620025ee565b935060208501359250604085013567ffffffffffffffff808211156200272457600080fd5b818701915087601f8301126200273957600080fd5b8135818111156200274957600080fd5b8860208285010111156200275c57600080fd5b95989497505060200194505050565b600080604083850312156200277f57600080fd5b50508035926020909101359150565b600080600060608486031215620027a457600080fd5b505081359360208301359350604090920135919050565b60008060408385031215620027cf57600080fd5b8235620027dc81620025ee565b946020939093013593505050565b600060208284031215620027fd57600080fd5b815180151581146200259357600080fd5b6000806000606084860312156200282457600080fd5b83356200283181620025ee565b95602085013595506040909401359392505050565b634e487b7160e01b600052601160045260246000fd5b808202811582820484141762000ad15762000ad162002846565b8082018082111562000ad15762000ad162002846565b600060018201620028a157620028a162002846565b5060010190565b634e487b7160e01b600052601260045260246000fd5b600082620028d057620028d0620028a8565b500490565b634e487b7160e01b600052603260045260246000fd5b8181038181111562000ad15762000ad162002846565b6000602082840312156200291457600080fd5b5051919050565b6000826200292d576200292d620028a8565b500690565b60005b838110156200294f57818101518382015260200162002935565b50506000910152565b600081518084526200297281602086016020860162002932565b601f01601f19169290920160200192915050565b60208152815160208201526020820151604082015261ffff60408301511660608201526000606083015163ffffffff80821660808501528060808601511660a0850152505060a083015160c080840152620029e560e084018262002958565b949350505050565b60006020828403121562002a0057600080fd5b81516200259381620025ee565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835162002a4781601785016020880162002932565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835162002a7a81602884016020880162002932565b01602801949350505050565b60208152600062002593602083018462002958565b634e487b7160e01b600052604160045260246000fd5b60008162002ac35762002ac362002846565b50600019019056fe61016060405234801561001157600080fd5b50604051610710380380610710833981016040819052610030916100dc565b61003933610070565b4260e0526001600160a01b039586166080529390941660a05260c09190915261010052600180556101209190915261014052610134565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b03811681146100d757600080fd5b919050565b60008060008060008060c087890312156100f557600080fd5b6100fe876100c0565b955061010c602088016100c0565b945060408701519350606087015192506080870151915060a087015190509295509295509295565b60805160a05160c05160e0516101005161012051610140516105596101b760003960008181610168015261037c0152600081816102080152610351015260006101e20152600081816101bc01526102c101526000818161028c01526102ef015260008181610130015261026501526000818160f1015261024001526105596000f3fe608060405234801561001057600080fd5b50600436106100ea5760003560e01c80638ecf0d0b1161008c578063cfe7b77011610066578063cfe7b7701461022c578063d321fe29146102ed578063de29278914610313578063f2fde38b1461031b57600080fd5b80638ecf0d0b146101ba5780639f8743f7146101e0578063b79a75171461020657600080fd5b80635c88a657116100c85780635c88a65714610166578063715018a61461018c578063812448a5146101965780638da5cb5b146101a957600080fd5b80633308f42d146100ef5780634494fd9f1461012e5780634e69d56014610154575b600080fd5b7f00000000000000000000000000000000000000000000000000000000000000005b6040516001600160a01b0390911681526020015b60405180910390f35b7f0000000000000000000000000000000000000000000000000000000000000000610111565b6001545b604051908152602001610125565b7f0000000000000000000000000000000000000000000000000000000000000000610158565b61019461032e565b005b6101946101a43660046104da565b610342565b6000546001600160a01b0316610111565b7f0000000000000000000000000000000000000000000000000000000000000000610158565b7f0000000000000000000000000000000000000000000000000000000000000000610158565b7f0000000000000000000000000000000000000000000000000000000000000000610158565b600254600154604080516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811682527f00000000000000000000000000000000000000000000000000000000000000001660208201527f000000000000000000000000000000000000000000000000000000000000000091810191909152606081019290925260808201527f000000000000000000000000000000000000000000000000000000000000000060a082015260c001610125565b7f0000000000000000000000000000000000000000000000000000000000000000610158565b600254610158565b6101946103293660046104f3565b6103b5565b610336610430565b610340600061048a565b565b61034a610430565b60028190557f0000000000000000000000000000000000000000000000000000000000000000811080159061039f57507f00000000000000000000000000000000000000000000000000000000000000008111155b156103ac57600260015550565b60036001555b50565b6103bd610430565b6001600160a01b0381166104275760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b6103b28161048a565b6000546001600160a01b031633146103405760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161041e565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000602082840312156104ec57600080fd5b5035919050565b60006020828403121561050557600080fd5b81356001600160a01b038116811461051c57600080fd5b939250505056fea26469706673582212208f8bc9edbe8335978f831a27ddd3cda395e55e6e099db1bc01058f69c11edd1664736f6c63430008130033a26469706673582212209dbc66a9583cbccf7c13ff13ded3c8ff310a1486246fa9314244d9cbe35e28a464736f6c63430008130033000000000000000000000000bf87898c4e609598a393ccd765482bef80000000000000000000000000000000bff71fa4a5ac368e0ce8b45ca32adf1eb7555555000000000000000000000000105f6c2c4eaea9987090d6057932392558725360487183bf4e2022c47afeaa63449e91a2f3a00b71221ab96ae34f1045acdb22d3000000000000000000000000ec0ed46f36576541c75739e915adbcb3de24bd77719ed7d7664abc3001c18aac8130a2265e1e70b7e036ae20f3ca8b92b3154d86
Deployed Bytecode
0x60806040523480156200001157600080fd5b5060043610620003cd5760003560e01c80636c1885931162000205578063a32bf5971162000125578063c6c834ca11620000bb578063f2f4eb261162000086578063f2f4eb261462000a21578063f2fde38b1462000a49578063f678ef871462000a60578063fc0c546a1462000a7757600080fd5b8063c6c834ca146200098c578063d2de6ec514620009ba578063d547741f14620009d1578063e35154a514620009e857600080fd5b8063b0f733bd11620000fc578063b0f733bd14620008fb578063b0fb162f1462000929578063bae638161462000946578063c2ff1d9e146200096957600080fd5b8063a32bf59714620008a3578063a3e56fa814620008ad578063a5087f6814620008d557600080fd5b80638da5cb5b116200019b5780639a7e25cd11620001725780639a7e25cd14620008325780639c8c962914620008635780639eccacf61462000886578063a217fddf146200089a57600080fd5b80638da5cb5b14620007f25780638ea98117146200080457806391d14854146200081b57600080fd5b80637aadef8b11620001dc5780637aadef8b14620007695780637b1391a6146200079157806381b7926714620007b85780638b6f685514620007cf57600080fd5b80636c188593146200072557806376a4956c146200073c57806379ba5097146200075f57600080fd5b8063344a186d11620002f157806351a78c9f11620002875780635ef8ac19116200025e5780635ef8ac1914620006bd57806361728f3914620006e95780636475e3d314620007115780636641ea08146200071b57600080fd5b806351a78c9f14620006795780635372a9ce146200069c578063573cb42714620006b357600080fd5b80633ce9a40811620002c85780633ce9a408146200060157806349841b9314620006245780634b8624c414620006475780634cf088d9146200065157600080fd5b8063344a186d14620005b257806336568abe14620005e357806338cc483114620005fa57600080fd5b8063248a9ca311620003675780632f2ff15d116200033e5780632f2ff15d146200052c5780632f9d50351462000543578063317ed999146200055a578063325a19f1146200058a57600080fd5b8063248a9ca314620004d25780632af1272a14620004f85780632d760642146200052457600080fd5b80630e99f5e611620003a85780630e99f5e6146200045757806317b022fc14620004705780631fe543e314620004985780632100de5d14620004af57600080fd5b806301ffc9a714620003d257806305c4cb4514620003fe5780630d8e6e2c1462000430575b600080fd5b620003e9620003e3366004620025a8565b62000a9f565b60405190151581526020015b60405180910390f35b620004216200040f366004620025d4565b6000908152600a602052604090205490565b604051908152602001620003f5565b7f0000000000000000000000000000000000000000000000000000000066cde69d62000421565b6200046e6200046836600462002604565b62000ad7565b005b620004217facbad678df5731cc63969722859e16a5c8f2854c5e50a0dbc23355ef474f97e281565b6200046e620004a936600462002624565b62000c68565b62000421620004c0366004620025d4565b60076020526000908152604090205481565b62000421620004e3366004620025d4565b60009081526020819052604090206001015490565b620004216200050936600462002604565b6001600160a01b031660009081526009602052604090205490565b600062000421565b6200046e6200053d366004620026a8565b62000cbc565b6200046e62000554366004620025d4565b62000ce5565b620005716200056b366004620026db565b62000dbe565b6040516001600160a01b039091168152602001620003f5565b620004217f0000000000000000000000000000000000000000000000000000000066cde69d81565b620003e9620005c3366004620026a8565b600860209081526000928352604080842090915290825290205460ff1681565b6200046e620005f4366004620026a8565b62001322565b3062000571565b6200042162000612366004620025d4565b60156020526000908152604090205481565b620004216200063536600462002604565b600b6020526000908152604090205481565b620004216101f481565b620005717f000000000000000000000000bff71fa4a5ac368e0ce8b45ca32adf1eb755555581565b620004216200068a366004620025d4565b600d6020526000908152604090205481565b6200046e620006ad36600462002604565b620013a4565b620004216103e881565b62000571620006ce36600462002604565b600f602052600090815260409020546001600160a01b031681565b620004217f719ed7d7664abc3001c18aac8130a2265e1e70b7e036ae20f3ca8b92b3154d8681565b6200042160055481565b6200042161012c81565b6200046e62000736366004620025d4565b620013fc565b620004216200074d366004620025d4565b60136020526000908152604090205481565b6200046e62001483565b620004217faefebe170cbaff0af052a32795af0e1b8afff9850f946ad2869be14f3553437181565b7f000000000000000000000000bff71fa4a5ac368e0ce8b45ca32adf1eb755555562000571565b62000571620007c93660046200276b565b62001533565b62000421620007e0366004620025d4565b60066020526000908152604090205481565b6001546001600160a01b031662000571565b6200046e6200081536600462002604565b6200156c565b620003e96200082c366004620026a8565b62001663565b620003e962000843366004620026a8565b601660209081526000928352604080842090915290825290205460ff1681565b6200042162000874366004620025d4565b600c6020526000908152604090205481565b60035462000571906001600160a01b031681565b62000421600081565b620004216200168c565b620005717f000000000000000000000000ec0ed46f36576541c75739e915adbcb3de24bd7781565b620003e9620008e6366004620025d4565b60146020526000908152604090205460ff1681565b620004216200090c366004620026a8565b601060209081526000928352604080842090915290825290205481565b62000932600381565b60405161ffff9091168152602001620003f5565b6200042162000957366004620025d4565b60176020526000908152604090205481565b620004216200097a366004620025d4565b600e6020526000908152604090205481565b620004216200099d366004620026a8565b601160209081526000928352604080842090915290825290205481565b6200046e620009cb3660046200278e565b620016a1565b6200046e620009e2366004620026a8565b62001a29565b62000a0e620009f9366004620025d4565b60126020526000908152604090205460ff1681565b60405160ff9091168152602001620003f5565b620005717f000000000000000000000000bf87898c4e609598a393ccd765482bef8000000081565b6200046e62000a5a36600462002604565b62001a52565b6200042162000a71366004620027bb565b62001a67565b620005717f000000000000000000000000bf7970d56a150cd0b60bd08388a4a75a2777777781565b60006001600160e01b03198216637965db0b60e01b148062000ad157506301ffc9a760e01b6001600160e01b03198316145b92915050565b336001600160a01b038216148062000b16575062000b167facbad678df5731cc63969722859e16a5c8f2854c5e50a0dbc23355ef474f97e23362001663565b62000b4e5760405162461bcd60e51b815260206004820152600360248201526226181960e91b60448201526064015b60405180910390fd5b6001600160a01b038181166000818152600b602052604080822080549290555163a9059cbb60e01b8152600481019290925260248201819052917f000000000000000000000000bf7970d56a150cd0b60bd08388a4a75a27777777169063a9059cbb906044016020604051808303816000875af115801562000bd4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000bfa9190620027ea565b62000c2e5760405162461bcd60e51b8152602060048201526003602482015262130c4d60ea1b604482015260640162000b45565b60405181906001600160a01b038416907f4e69fdc49495bcab2b4375781457ba16653a90eb4ffb6588351bdc39071433e290600090a35050565b6003546001600160a01b0316331462000caa5760035460405163073e64fd60e21b81523360048201526001600160a01b03909116602482015260440162000b45565b62000cb783838362001a99565b505050565b60008281526020819052604090206001015462000cd98162001b29565b62000cb7838362001b35565b62000cef6200168c565b811062000d255760405162461bcd60e51b81526020600482015260036024820152624c303960e81b604482015260640162000b45565b60008181526012602052604090205460ff161562000d6c5760405162461bcd60e51b815260206004820152600360248201526204c31360ec1b604482015260640162000b45565b6000818152600a60205260408120541162000db05760405162461bcd60e51b81526020600482015260036024820152624c313160e81b604482015260640162000b45565b62000dbb8162001bbd565b50565b6000336001600160a01b037f000000000000000000000000bf87898c4e609598a393ccd765482bef80000000161462000e205760405162461bcd60e51b81526020600482015260036024820152624c313360e81b604482015260640162000b45565b6000808062000e32858701876200280e565b925092509250876001600160a01b0316836001600160a01b03161462000e815760405162461bcd60e51b815260206004820152600360248201526226181960e91b604482015260640162000b45565b8662000e9683670de0b6b3a76400006200285c565b1462000ecb5760405162461bcd60e51b81526020600482015260036024820152624c303360e81b604482015260640162000b45565b60055487101562000f055760405162461bcd60e51b81526020600482015260036024820152624c303560e81b604482015260640162000b45565b62000f0f6200168c565b811462000f455760405162461bcd60e51b8152602060048201526003602482015262130c0d60ea1b604482015260640162000b45565b6000818152600a60205260409020546103e89062000f6590600162002876565b111562000f9b5760405162461bcd60e51b81526020600482015260036024820152624c303760e81b604482015260640162000b45565b60008181526012602052604090205460ff161562000fe25760405162461bcd60e51b815260206004820152600360248201526204c31360ec1b604482015260640162000b45565b60008181526017602052604081205462000ffe90600162002876565b90508260176000848152602001908152602001600020600082825462001025919062002876565b92505081905550600084308a8585601760008981526020019081526020016000205460405162001055906200259a565b6001600160a01b03968716815295909416602086015260408501929092526060840152608083015260a082015260c001604051809103906000f080158015620010a2573d6000803e3d6000fd5b506000848152600a6020908152604080832080546001810182559084528284200180546001600160a01b0319166001600160a01b038681169190911790915587845260088352818420908a16845290915290205490915060ff16620011775760008381526008602090815260408083206001600160a01b03891684528252808320805460ff191660011790558583526007909152812080549162001146836200288c565b90915550506001600160a01b0385166000908152600960209081526040822080546001810182559083529120018390555b60008381526010602090815260408083206001600160a01b0389168452909152812080548b9290620011ab90849062002876565b909155505060008381526011602090815260408083206001600160a01b03891684529091528120805491620011e0836200288c565b9091555050600083815260066020526040812080548b92906200120590849062002876565b9091555050600083815260066020908152604080832054600e90925282208054919290916200123690849062002876565b90915550506001600160a01b038181166000908152600f6020908152604080832080546001600160a01b031916948a1694909417909355858252600a905220546103e890036200128b576200128b8362001bbd565b82856001600160a01b03167faf103d0232378bce6bbef82b15d24edd12fed7effcec1f97252b2f2e45fe4a3b8b604051620012c891815260200190565b60405180910390a36000838152600a60205260409020546001036200131557604051429084907f63d859dfe6122a9b44f82878adcca8b281f61490464164bb5df15c3450e3e08c90600090a35b9998505050505050505050565b6001600160a01b0381163314620013945760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b606482015260840162000b45565b620013a0828262001d67565b5050565b7faefebe170cbaff0af052a32795af0e1b8afff9850f946ad2869be14f35534371620013d08162001b29565b620013a07facbad678df5731cc63969722859e16a5c8f2854c5e50a0dbc23355ef474f97e28362001b35565b7faefebe170cbaff0af052a32795af0e1b8afff9850f946ad2869be14f35534371620014288162001b29565b670de0b6b3a76400008211801562001449575069d3c21bcecceda100000082105b6200147d5760405162461bcd60e51b815260206004820152600360248201526226181b60e91b604482015260640162000b45565b50600555565b6002546001600160a01b03163314620014d85760405162461bcd60e51b815260206004820152601660248201527526bab9ba10313290383937b837b9b2b21037bbb732b960511b604482015260640162000b45565b600180546001600160a01b0319808216339081179093556002805490911690556040516001600160a01b03909116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a350565b600a60205281600052604060002081815481106200155057600080fd5b6000918252602090912001546001600160a01b03169150829050565b6001546001600160a01b031633148015906200159357506003546001600160a01b03163314155b15620015e75733620015ad6001546001600160a01b031690565b60035460405163061db9c160e01b81526001600160a01b039384166004820152918316602483015291909116604482015260640162000b45565b6001600160a01b0381166200160f5760405163d92e233d60e01b815260040160405180910390fd5b600380546001600160a01b0319166001600160a01b0383169081179091556040519081527fd1a6a14209a385a964d036e404cb5cfb71f4000cdb03c9366292430787261be69060200160405180910390a150565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b60006200169c61012c42620028be565b905090565b620016ab6200168c565b8310620016e15760405162461bcd60e51b81526020600482015260036024820152624c303960e81b604482015260640162000b45565b60008381526012602052604090205460ff166002146200172a5760405162461bcd60e51b815260206004820152600360248201526226189960e91b604482015260640162000b45565b60008381526014602052604090205460ff1615620017715760405162461bcd60e51b815260206004820152600360248201526209860760eb1b604482015260640162000b45565b6000838152600a602090815260408083206013835281842054600e84528285205460069094529184205490939192919061271090620017b4906101f4906200285c565b620017c09190620028be565b9050855b620017d0868862002876565b811015620019e4578454811015620019e4576000858281548110620017f957620017f9620028d5565b60009182526020808320909101548b83526016825260408084206001600160a01b039092168085529190925291205490915060ff16156200183b5750620019cf565b6001600160a01b038082166000908152600f6020526040812054885492169162001867908590620028eb565b836001600160a01b031663d321fe296040518163ffffffff1660e01b8152600401602060405180830381865afa158015620018a6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620018cc919062002901565b620018d891906200285c565b9050600086620018e983886200285c565b620018f59190620028be565b6001600160a01b0384166000908152600b60205260408120805492935083929091906200192490849062002876565b909155505060008c81526016602090815260408083206001600160a01b038816808552925291829020805460ff19166001179055905163812448a560e01b8152600481018a905263812448a590602401600060405180830381600087803b1580156200198f57600080fd5b505af1158015620019a4573d6000803e3d6000fd5b50505060008d81526015602052604081208054925090620019c5836200288c565b9190505550505050505b80620019db816200288c565b915050620017c4565b506000878152600a60209081526040808320546015909252909120540362001a20576000878152601460205260409020805460ff191660011790555b50505050505050565b60008281526020819052604090206001015462001a468162001b29565b62000cb7838362001d67565b62001a5c62001dcf565b62000dbb8162001e26565b6009602052816000526040600020818154811062001a8457600080fd5b90600052602060002001600091509150505481565b6000838152600d602090815260408083205480845260179092528220549091908484838162001acc5762001acc620028d5565b9050602002013562001adf91906200291b565b62001aec90600162002876565b6000838152601360205260409020819055905062001b0a8262001ed2565b506000908152601260205260409020805460ff19166002179055505050565b62000dbb813362002295565b62001b41828262001663565b620013a0576000828152602081815260408083206001600160a01b03851684529091529020805460ff1916600117905562001b793390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b62001bc7620022f9565b60007f000000000000000000000000ec0ed46f36576541c75739e915adbcb3de24bd776001600160a01b0316639b1c385e6040518060c001604052807f719ed7d7664abc3001c18aac8130a2265e1e70b7e036ae20f3ca8b92b3154d8681526020017f487183bf4e2022c47afeaa63449e91a2f3a00b71221ab96ae34f1045acdb22d38152602001600361ffff168152602001622625a063ffffffff168152602001600163ffffffff16815260200162001c9260405180602001604052806000151581525062002354565b8152506040518263ffffffff1660e01b815260040162001cb3919062002986565b6020604051808303816000875af115801562001cd3573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001cf9919062002901565b6000838152600c60209081526040808320849055838352600d82528083208690558583526012909152808220805460ff1916600117905551919250829184917fca1a840a958890962f5385264bcf166eb5254ef65f4a241ce7c9635d4f65466491a35062000dbb6001600455565b62001d73828262001663565b15620013a0576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6001546001600160a01b0316331462001e245760405162461bcd60e51b815260206004820152601660248201527527b7363c9031b0b63630b1363290313c9037bbb732b960511b604482015260640162000b45565b565b336001600160a01b0382160362001e805760405162461bcd60e51b815260206004820152601760248201527f43616e6e6f74207472616e7366657220746f2073656c66000000000000000000604482015260640162000b45565b600280546001600160a01b0319166001600160a01b03838116918217909255600154604051919216907fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae127890600090a350565b62001edc620022f9565b600081815260136020908152604080832054600a9092528220805491929091819062001f0b90600190620028eb565b90505b80821162002286576000600262001f26838562002876565b62001f329190620028be565b9050600084828154811062001f4b5762001f4b620028d5565b60009182526020808320909101546040805163b79a751760e01b815290516001600160a01b039092169450849263b79a7517926004808401938290030181865afa15801562001f9e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001fc4919062002901565b90506000826001600160a01b0316635c88a6576040518163ffffffff1660e01b8152600401602060405180830381865afa15801562002007573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200202d919062002901565b9050878211158015620020405750878110155b156200224e5760008981526006602052604081205490612710620020676101f4846200285c565b620020739190620028be565b9050600081612710620020a77f0000000000000000000000000000000000000000000000000000000000000168866200285c565b620020b39190620028be565b620020bf9085620028eb565b620020cb9190620028eb565b90507f000000000000000000000000bf7970d56a150cd0b60bd08388a4a75a277777776001600160a01b031663a9059cbb876001600160a01b0316633308f42d6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200213b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620021619190620029ed565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602481018490526044016020604051808303816000875af1158015620021af573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620021d59190620027ea565b620022095760405162461bcd60e51b8152602060048201526003602482015262130c4d60ea1b604482015260640162000b45565b856001600160a01b03168b8d7fc8aa5aac082dfa4d9ecbd022c327bca40a5bd58dde373da553268297d488e4bc60405160405180910390a45050505050505062002286565b878110156200226c576200226484600162002876565b95506200227c565b62002279600185620028eb565b94505b5050505062001f0e565b5050505062000dbb6001600455565b620022a1828262001663565b620013a057620022b181620023c6565b620022be836020620023d9565b604051602001620022d192919062002a0d565b60408051601f198184030181529082905262461bcd60e51b825262000b459160040162002a86565b6002600454036200234d5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640162000b45565b6002600455565b60607f92fd13387c7fe7befbc38d303d6468778fb9731bc4583f17d92989c6fcfdeaaa826040516024016200238e91511515815260200190565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915292915050565b606062000ad16001600160a01b03831660145b60606000620023ea8360026200285c565b620023f790600262002876565b67ffffffffffffffff81111562002412576200241262002a9b565b6040519080825280601f01601f1916602001820160405280156200243d576020820181803683370190505b509050600360fc1b816000815181106200245b576200245b620028d5565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106200248d576200248d620028d5565b60200101906001600160f81b031916908160001a9053506000620024b38460026200285c565b620024c090600162002876565b90505b600181111562002542576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110620024f857620024f8620028d5565b1a60f81b828281518110620025115762002511620028d5565b60200101906001600160f81b031916908160001a90535060049490941c936200253a8162002ab1565b9050620024c3565b508315620025935760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640162000b45565b9392505050565b6107108062002acc83390190565b600060208284031215620025bb57600080fd5b81356001600160e01b0319811681146200259357600080fd5b600060208284031215620025e757600080fd5b5035919050565b6001600160a01b038116811462000dbb57600080fd5b6000602082840312156200261757600080fd5b81356200259381620025ee565b6000806000604084860312156200263a57600080fd5b83359250602084013567ffffffffffffffff808211156200265a57600080fd5b818601915086601f8301126200266f57600080fd5b8135818111156200267f57600080fd5b8760208260051b85010111156200269557600080fd5b6020830194508093505050509250925092565b60008060408385031215620026bc57600080fd5b823591506020830135620026d081620025ee565b809150509250929050565b60008060008060608587031215620026f257600080fd5b8435620026ff81620025ee565b935060208501359250604085013567ffffffffffffffff808211156200272457600080fd5b818701915087601f8301126200273957600080fd5b8135818111156200274957600080fd5b8860208285010111156200275c57600080fd5b95989497505060200194505050565b600080604083850312156200277f57600080fd5b50508035926020909101359150565b600080600060608486031215620027a457600080fd5b505081359360208301359350604090920135919050565b60008060408385031215620027cf57600080fd5b8235620027dc81620025ee565b946020939093013593505050565b600060208284031215620027fd57600080fd5b815180151581146200259357600080fd5b6000806000606084860312156200282457600080fd5b83356200283181620025ee565b95602085013595506040909401359392505050565b634e487b7160e01b600052601160045260246000fd5b808202811582820484141762000ad15762000ad162002846565b8082018082111562000ad15762000ad162002846565b600060018201620028a157620028a162002846565b5060010190565b634e487b7160e01b600052601260045260246000fd5b600082620028d057620028d0620028a8565b500490565b634e487b7160e01b600052603260045260246000fd5b8181038181111562000ad15762000ad162002846565b6000602082840312156200291457600080fd5b5051919050565b6000826200292d576200292d620028a8565b500690565b60005b838110156200294f57818101518382015260200162002935565b50506000910152565b600081518084526200297281602086016020860162002932565b601f01601f19169290920160200192915050565b60208152815160208201526020820151604082015261ffff60408301511660608201526000606083015163ffffffff80821660808501528060808601511660a0850152505060a083015160c080840152620029e560e084018262002958565b949350505050565b60006020828403121562002a0057600080fd5b81516200259381620025ee565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835162002a4781601785016020880162002932565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835162002a7a81602884016020880162002932565b01602801949350505050565b60208152600062002593602083018462002958565b634e487b7160e01b600052604160045260246000fd5b60008162002ac35762002ac362002846565b50600019019056fe61016060405234801561001157600080fd5b50604051610710380380610710833981016040819052610030916100dc565b61003933610070565b4260e0526001600160a01b039586166080529390941660a05260c09190915261010052600180556101209190915261014052610134565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b03811681146100d757600080fd5b919050565b60008060008060008060c087890312156100f557600080fd5b6100fe876100c0565b955061010c602088016100c0565b945060408701519350606087015192506080870151915060a087015190509295509295509295565b60805160a05160c05160e0516101005161012051610140516105596101b760003960008181610168015261037c0152600081816102080152610351015260006101e20152600081816101bc01526102c101526000818161028c01526102ef015260008181610130015261026501526000818160f1015261024001526105596000f3fe608060405234801561001057600080fd5b50600436106100ea5760003560e01c80638ecf0d0b1161008c578063cfe7b77011610066578063cfe7b7701461022c578063d321fe29146102ed578063de29278914610313578063f2fde38b1461031b57600080fd5b80638ecf0d0b146101ba5780639f8743f7146101e0578063b79a75171461020657600080fd5b80635c88a657116100c85780635c88a65714610166578063715018a61461018c578063812448a5146101965780638da5cb5b146101a957600080fd5b80633308f42d146100ef5780634494fd9f1461012e5780634e69d56014610154575b600080fd5b7f00000000000000000000000000000000000000000000000000000000000000005b6040516001600160a01b0390911681526020015b60405180910390f35b7f0000000000000000000000000000000000000000000000000000000000000000610111565b6001545b604051908152602001610125565b7f0000000000000000000000000000000000000000000000000000000000000000610158565b61019461032e565b005b6101946101a43660046104da565b610342565b6000546001600160a01b0316610111565b7f0000000000000000000000000000000000000000000000000000000000000000610158565b7f0000000000000000000000000000000000000000000000000000000000000000610158565b7f0000000000000000000000000000000000000000000000000000000000000000610158565b600254600154604080516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811682527f00000000000000000000000000000000000000000000000000000000000000001660208201527f000000000000000000000000000000000000000000000000000000000000000091810191909152606081019290925260808201527f000000000000000000000000000000000000000000000000000000000000000060a082015260c001610125565b7f0000000000000000000000000000000000000000000000000000000000000000610158565b600254610158565b6101946103293660046104f3565b6103b5565b610336610430565b610340600061048a565b565b61034a610430565b60028190557f0000000000000000000000000000000000000000000000000000000000000000811080159061039f57507f00000000000000000000000000000000000000000000000000000000000000008111155b156103ac57600260015550565b60036001555b50565b6103bd610430565b6001600160a01b0381166104275760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b6103b28161048a565b6000546001600160a01b031633146103405760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161041e565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000602082840312156104ec57600080fd5b5035919050565b60006020828403121561050557600080fd5b81356001600160a01b038116811461051c57600080fd5b939250505056fea26469706673582212208f8bc9edbe8335978f831a27ddd3cda395e55e6e099db1bc01058f69c11edd1664736f6c63430008130033a26469706673582212209dbc66a9583cbccf7c13ff13ded3c8ff310a1486246fa9314244d9cbe35e28a464736f6c63430008130033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000bf87898c4e609598a393ccd765482bef80000000000000000000000000000000bff71fa4a5ac368e0ce8b45ca32adf1eb7555555000000000000000000000000105f6c2c4eaea9987090d6057932392558725360487183bf4e2022c47afeaa63449e91a2f3a00b71221ab96ae34f1045acdb22d3000000000000000000000000ec0ed46f36576541c75739e915adbcb3de24bd77719ed7d7664abc3001c18aac8130a2265e1e70b7e036ae20f3ca8b92b3154d86
-----Decoded View---------------
Arg [0] : _core (address): 0xBf87898C4e609598a393cCD765482BeF80000000
Arg [1] : _staking (address): 0xBFF71fa4a5Ac368E0Ce8B45ca32Adf1EB7555555
Arg [2] : _admin (address): 0x105F6c2C4EAEA9987090d6057932392558725360
Arg [3] : _subscriptionId (uint256): 32767088102663959037577905450042035189101784858330162380188032292874878657235
Arg [4] : _vrfCoordinator (address): 0xec0Ed46f36576541C75739E915ADbCb3DE24bD77
Arg [5] : _keyHash (bytes32): 0x719ed7d7664abc3001c18aac8130a2265e1e70b7e036ae20f3ca8b92b3154d86
-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 000000000000000000000000bf87898c4e609598a393ccd765482bef80000000
Arg [1] : 000000000000000000000000bff71fa4a5ac368e0ce8b45ca32adf1eb7555555
Arg [2] : 000000000000000000000000105f6c2c4eaea9987090d6057932392558725360
Arg [3] : 487183bf4e2022c47afeaa63449e91a2f3a00b71221ab96ae34f1045acdb22d3
Arg [4] : 000000000000000000000000ec0ed46f36576541c75739e915adbcb3de24bd77
Arg [5] : 719ed7d7664abc3001c18aac8130a2265e1e70b7e036ae20f3ca8b92b3154d86
Deployed Bytecode Sourcemap
937:10821:36:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2732:202:22;;;;;;:::i;:::-;;:::i;:::-;;;470:14:41;;463:22;445:41;;433:2;418:18;2732:202:22;;;;;;;;4193:111:36;;;;;;:::i;:::-;4248:7;4274:16;;;:9;:16;;;;;:23;;4193:111;;;;828:25:41;;;816:2;801:18;4193:111:36;682:177:41;11285:92:36;11363:7;11285:92;;10584:354;;;;;;:::i;:::-;;:::i;:::-;;1146:54;;1180:20;1146:54;;7489:280:14;;;;;;:::i;:::-;;:::i;1920:52:36:-;;;;;;:::i;:::-;;;;;;;;;;;;;;4504:129:22;;;;;;:::i;:::-;4578:7;4604:12;;;;;;;;;;:22;;;;4504:129;4310:143:36;;;;;;:::i;:::-;-1:-1:-1;;;;;4418:21:36;4392:7;4418:21;;;:13;:21;;;;;:28;;4310:143;11383:86;11435:7;11383:86;;4929:145:22;;;;;;:::i;:::-;;:::i;6720:249:36:-;;;;;;:::i;:::-;;:::i;4459:2255::-;;;;;;:::i;:::-;;:::i;:::-;;;-1:-1:-1;;;;;3590:32:41;;;3572:51;;3560:2;3545:18;4459:2255:36;3426:203:41;1401:32:36;;;;;1978:65;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;6038:214:22;;;;;;:::i;:::-;;:::i;11181:98:36:-;11267:4;11181:98;;2817:54;;;;;;:::i;:::-;;;;;;;;;;;;;;2163:49;;;;;;:::i;:::-;;;;;;;;;;;;;;1309:36;;1341:4;1309:36;;1510:32;;;;;2272:48;;;;;;:::i;:::-;;;;;;;;;;;;;;10944:112;;;;;;:::i;:::-;;:::i;1262:41::-;;1299:4;1262:41;;2383:45;;;;;;:::i;:::-;;;;;;;;;;;;-1:-1:-1;;;;;2383:45:36;;;1640:32;;;;;1352:42;;;;;;1206:50;;1247:9;1206:50;;11573:183;;;;;;:::i;:::-;;:::i;2709:47::-;;;;;;:::i;:::-;;;;;;;;;;;;;;1026:316:2;;;:::i;1084:56:36:-;;1119:21;1084:56;;11475:92;11553:7;11475:92;;2105:52;;;;;;:::i;:::-;;:::i;1870:44::-;;;;;;:::i;:::-;;;;;;;;;;;;;;1382:81:2;1451:7;;-1:-1:-1;;;;;1451:7:2;1382:81;;7831:276:14;;;;;;:::i;:::-;;:::i;3021:145:22:-;;;;;;:::i;:::-;;:::i;2877:71:36:-;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;2218:48;;;;;;:::i;:::-;;;;;;;;;;;;;;6077:45:14;;;;;-1:-1:-1;;;;;6077:45:14;;;2153:49:22;;2198:4;2153:49;;11062:113:36;;;:::i;1595:39::-;;;;;2762:49;;;;;;:::i;:::-;;;;;;;;;;;;;;;;2434:72;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;1737:47;;1783:1;1737:47;;;;;4850:6:41;4838:19;;;4820:38;;4808:2;4793:18;1737:47:36;4676:188:41;2955:45:36;;;;;;:::i;:::-;;;;;;;;;;;;;;2326:51;;;;;;:::i;:::-;;;;;;;;;;;;;;2512:75;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;9376:1202;;;;;;:::i;:::-;;:::i;5354:147:22:-;;;;;;:::i;:::-;;:::i;2659:44:36:-;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;5362:4:41;5350:17;;;5332:36;;5320:2;5305:18;2659:44:36;5190:184:41;1439:29:36;;;;;847:98:2;;;;;;:::i;:::-;;:::i;2049:50:36:-;;;;;;:::i;:::-;;:::i;1474:30::-;;;;;2732:202:22;2817:4;-1:-1:-1;;;;;;2840:47:22;;-1:-1:-1;;;2840:47:22;;:87;;-1:-1:-1;;;;;;;;;;937:40:32;;;2891:36:22;2833:94;2732:202;-1:-1:-1;;2732:202:22:o;10584:354:36:-;734:10:30;-1:-1:-1;;;;;10660:22:36;;;;:56;;-1:-1:-1;10686:30:36;1180:20;734:10:30;3021:145:22;:::i;10686:30:36:-;10639:106;;;;-1:-1:-1;;;10639:106:36;;5901:2:41;10639:106:36;;;5883:21:41;5940:1;5920:18;;;5913:29;-1:-1:-1;;;5958:18:41;;;5951:33;6001:18;;10639:106:36;;;;;;;;;-1:-1:-1;;;;;10768:22:36;;;10755:10;10768:22;;;:14;:22;;;;;;;;10800:26;;;10844:37;-1:-1:-1;;;10844:37:36;;;;;6204:51:41;;;;6271:18;;;6264:34;;;10768:22:36;10851:5;10844:22;;;;6177:18:41;;10844:37:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;10836:53;;;;-1:-1:-1;;;10836:53:36;;6793:2:41;10836:53:36;;;6775:21:41;6832:1;6812:18;;;6805:29;-1:-1:-1;;;6850:18:41;;;6843:33;6893:18;;10836:53:36;6591:326:41;10836:53:36;10904:27;;10925:5;;-1:-1:-1;;;;;10904:27:36;;;;;;;;10629:309;10584:354;:::o;7489:280:14:-;7612:16;;-1:-1:-1;;;;;7612:16:14;7590:10;:39;7586:131;;7692:16;;7646:64;;-1:-1:-1;;;7646:64:14;;7672:10;7646:64;;;7134:34:41;-1:-1:-1;;;;;7692:16:14;;;7184:18:41;;;7177:43;7069:18;;7646:64:14;6922:304:41;7586:131:14;7722:42;7741:9;7752:11;;7722:18;:42::i;:::-;7489:280;;;:::o;4929:145:22:-;4578:7;4604:12;;;;;;;;;;:22;;;2631:16;2642:4;2631:10;:16::i;:::-;5042:25:::1;5053:4;5059:7;5042:10;:25::i;6720:249:36:-:0;6796:17;:15;:17::i;:::-;6788:5;:25;6780:41;;;;-1:-1:-1;;;6780:41:36;;7433:2:41;6780:41:36;;;7415:21:41;7472:1;7452:18;;;7445:29;-1:-1:-1;;;7490:18:41;;;7483:33;7533:18;;6780:41:36;7231:326:41;6780:41:36;6839:18;;;;:11;:18;;;;;;;;:23;6831:39;;;;-1:-1:-1;;;6831:39:36;;7764:2:41;6831:39:36;;;7746:21:41;7803:1;7783:18;;;7776:29;-1:-1:-1;;;7821:18:41;;;7814:33;7864:18;;6831:39:36;7562:326:41;6831:39:36;6910:1;4274:16;;;:9;:16;;;;;:23;6888;6880:39;;;;-1:-1:-1;;;6880:39:36;;8095:2:41;6880:39:36;;;8077:21:41;8134:1;8114:18;;;8107:29;-1:-1:-1;;;8152:18:41;;;8145:33;8195:18;;6880:39:36;7893:326:41;6880:39:36;6929:33;6956:5;6929:26;:33::i;:::-;6720:249;:::o;4459:2255::-;4595:7;4622:10;-1:-1:-1;;;;;4636:4:36;4622:18;;4614:34;;;;-1:-1:-1;;;4614:34:36;;8426:2:41;4614:34:36;;;8408:21:41;8465:1;8445:18;;;8438:29;-1:-1:-1;;;8483:18:41;;;8476:33;8526:18;;4614:34:36;8224:326:41;4614:34:36;4681:14;;;4730:80;;;;4754:5;4730:80;:::i;:::-;4680:130;;;;;;4882:7;-1:-1:-1;;;;;4872:17:36;:6;-1:-1:-1;;;;;4872:17:36;;4864:33;;;;-1:-1:-1;;;4864:33:36;;5901:2:41;4864:33:36;;;5883:21:41;5940:1;5920:18;;;5913:29;-1:-1:-1;;;5958:18:41;;;5951:33;6001:18;;4864:33:36;5699:326:41;4864:33:36;4977:12;4956:17;:6;4965:8;4956:17;:::i;:::-;:33;4948:49;;;;-1:-1:-1;;;4948:49:36;;9458:2:41;4948:49:36;;;9440:21:41;9497:1;9477:18;;;9470:29;-1:-1:-1;;;9515:18:41;;;9508:33;9558:18;;4948:49:36;9256:326:41;4948:49:36;5070:14;;5054:12;:30;;5046:46;;;;-1:-1:-1;;;5046:46:36;;9789:2:41;5046:46:36;;;9771:21:41;9828:1;9808:18;;;9801:29;-1:-1:-1;;;9846:18:41;;;9839:33;9889:18;;5046:46:36;9587:326:41;5046:46:36;5162:17;:15;:17::i;:::-;5153:5;:26;5145:42;;;;-1:-1:-1;;;5145:42:36;;10120:2:41;5145:42:36;;;10102:21:41;10159:1;10139:18;;;10132:29;-1:-1:-1;;;10177:18:41;;;10170:33;10220:18;;5145:42:36;9918:326:41;5145:42:36;4248:7;4274:16;;;:9;:16;;;;;:23;1299:4;;5241:23;;5263:1;5241:23;:::i;:::-;5240:39;;5232:55;;;;-1:-1:-1;;;5232:55:36;;10581:2:41;5232:55:36;;;10563:21:41;10620:1;10600:18;;;10593:29;-1:-1:-1;;;10638:18:41;;;10631:33;10681:18;;5232:55:36;10379:326:41;5232:55:36;5351:18;;;;:11;:18;;;;;;;;:23;5343:39;;;;-1:-1:-1;;;5343:39:36;;7764:2:41;5343:39:36;;;7746:21:41;7803:1;7783:18;;;7776:29;-1:-1:-1;;;7821:18:41;;;7814:33;7864:18;;5343:39:36;7562:326:41;5343:39:36;5425:18;5446:17;;;:10;:17;;;;;;:21;;5466:1;5446:21;:::i;:::-;5425:42;;5527:6;5506:10;:17;5517:5;5506:17;;;;;;;;;;;;:27;;;;;;;:::i;:::-;;;;;;;;5565:17;5616:6;5644:4;5663:12;5689:5;5708:10;5732;:17;5743:5;5732:17;;;;;;;;;;;;5585:174;;;;;:::i;:::-;-1:-1:-1;;;;;11053:15:41;;;11035:34;;11105:15;;;;11100:2;11085:18;;11078:43;11152:2;11137:18;;11130:34;;;;11195:2;11180:18;;11173:34;11238:3;11223:19;;11216:35;11015:3;11267:19;;11260:35;10984:3;10969:19;5585:174:36;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;5802:16:36;;;;:9;:16;;;;;;;;:26;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;5802:26:36;-1:-1:-1;;;;;5802:26:36;;;;;;;;;;5917:20;;;:13;:20;;;;;:28;;;;;;;;;;;5802:26;;-1:-1:-1;5917:28:36;;5912:182;;5961:20;;;;:13;:20;;;;;;;;-1:-1:-1;;;;;5961:28:36;;;;;;;;;:35;;-1:-1:-1;;5961:35:36;5992:4;5961:35;;;6010:24;;;:17;:24;;;;;:26;;;;;;:::i;:::-;;;;-1:-1:-1;;;;;;;6050:21:36;;;;;;:13;:21;;;;;;;:33;;;;;;;;;;;;;;;;5912:182;6151:24;;;;:17;:24;;;;;;;;-1:-1:-1;;;;;6151:32:36;;;;;;;;;:48;;6187:12;;6151:24;:48;;6187:12;;6151:48;:::i;:::-;;;;-1:-1:-1;;6209:27:36;;;;:20;:27;;;;;;;;-1:-1:-1;;;;;6209:35:36;;;;;;;;;:37;;;;;;:::i;:::-;;;;-1:-1:-1;;6287:16:36;;;;:9;:16;;;;;:32;;6307:12;;6287:16;:32;;6307:12;;6287:32;:::i;:::-;;;;-1:-1:-1;;6356:16:36;;;;:9;:16;;;;;;;;;6329;:23;;;;;:43;;6356:16;;6329:23;;:43;;6356:16;;6329:43;:::i;:::-;;;;-1:-1:-1;;;;;;;6382:24:36;;;;;;;:10;:24;;;;;;;;:33;;-1:-1:-1;;;;;;6382:33:36;;;;;;;;;;;4274:16;;;:9;:16;;;:23;1299:4;;6429:33;6425:97;;6478:33;6505:5;6478:26;:33::i;:::-;6555:5;6547:6;-1:-1:-1;;;;;6536:39:36;;6562:12;6536:39;;;;828:25:41;;816:2;801:18;;682:177;6536:39:36;;;;;;;;4248:7;4274:16;;;:9;:16;;;;;:23;6612:1;6589:24;6585:94;;6634:34;;6652:15;;6645:5;;6634:34;;;;;6585:94;6703:3;4459:2255;-1:-1:-1;;;;;;;;;4459:2255:36:o;6038:214:22:-;-1:-1:-1;;;;;6133:23:22;;734:10:30;6133:23:22;6125:83;;;;-1:-1:-1;;;6125:83:22;;11648:2:41;6125:83:22;;;11630:21:41;11687:2;11667:18;;;11660:30;11726:34;11706:18;;;11699:62;-1:-1:-1;;;11777:18:41;;;11770:45;11832:19;;6125:83:22;11446:411:41;6125:83:22;6219:26;6231:4;6237:7;6219:11;:26::i;:::-;6038:214;;:::o;10944:112:36:-;1119:21;2631:16:22;2642:4;2631:10;:16::i;:::-;11020:29:36::1;1180:20;11040:8;11020:10;:29::i;11573:183::-:0;1119:21;2631:16:22;2642:4;2631:10;:16::i;:::-;11671:7:36::1;11661;:17;:46;;;;;11692:15;11682:7;:25;11661:46;11653:62;;;::::0;-1:-1:-1;;;11653:62:36;;12064:2:41;11653:62:36::1;::::0;::::1;12046:21:41::0;12103:1;12083:18;;;12076:29;-1:-1:-1;;;12121:18:41;;;12114:33;12164:18;;11653:62:36::1;11862:326:41::0;11653:62:36::1;-1:-1:-1::0;11725:14:36::1;:24:::0;11573:183::o;1026:316:2:-;1150:14;;-1:-1:-1;;;;;1150:14:2;1136:10;:28;1128:63;;;;-1:-1:-1;;;1128:63:2;;12395:2:41;1128:63:2;;;12377:21:41;12434:2;12414:18;;;12407:30;-1:-1:-1;;;12453:18:41;;;12446:52;12515:18;;1128:63:2;12193:346:41;1128:63:2;1217:7;;;-1:-1:-1;;;;;;1230:20:2;;;1240:10;1230:20;;;;;;1256:14;:27;;;;;;;1295:42;;-1:-1:-1;;;;;1217:7:2;;;;1240:10;1217:7;;1295:42;;1198:16;;1295:42;1071:271;1026:316::o;2105:52:36:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;2105:52:36;;-1:-1:-1;2105:52:36;;-1:-1:-1;2105:52:36:o;7831:276:14:-;1451:7:2;;-1:-1:-1;;;;;1451:7:2;8155:10:14;:21;;;;:64;;-1:-1:-1;8202:16:14;;-1:-1:-1;;;;;8202:16:14;8180:10;:39;;8155:64;8151:162;;;8259:10;8271:7;1451::2;;-1:-1:-1;;;;;1451:7:2;;1382:81;8271:7:14;8288:16;;8236:70;;-1:-1:-1;;;8236:70:14;;-1:-1:-1;;;;;12802:15:41;;;8236:70:14;;;12784:34:41;12854:15;;;12834:18;;;12827:43;8288:16:14;;;;12886:18:41;;;12879:43;12719:18;;8236:70:14;12544:384:41;8151:162:14;-1:-1:-1;;;;;7931:29:14;::::1;7927:70;;7977:13;;-1:-1:-1::0;;;7977:13:14::1;;;;;;;;;;;7927:70;8002:16;:57:::0;;-1:-1:-1;;;;;;8002:57:14::1;-1:-1:-1::0;;;;;8002:57:14;::::1;::::0;;::::1;::::0;;;8071:31:::1;::::0;3572:51:41;;;8071:31:14::1;::::0;3560:2:41;3545:18;8071:31:14::1;;;;;;;7831:276:::0;:::o;3021:145:22:-;3107:4;3130:12;;;;;;;;;;;-1:-1:-1;;;;;3130:29:22;;;;;;;;;;;;;;;3021:145::o;11062:113:36:-;11110:7;11136:32;1247:9;11136:15;:32;:::i;:::-;11129:39;;11062:113;:::o;9376:1202::-;9477:17;:15;:17::i;:::-;9469:5;:25;9461:41;;;;-1:-1:-1;;;9461:41:36;;7433:2:41;9461:41:36;;;7415:21:41;7472:1;7452:18;;;7445:29;-1:-1:-1;;;7490:18:41;;;7483:33;7533:18;;9461:41:36;7231:326:41;9461:41:36;9520:18;;;;:11;:18;;;;;;;;9542:1;9520:23;9512:39;;;;-1:-1:-1;;;9512:39:36;;13392:2:41;9512:39:36;;;13374:21:41;13431:1;13411:18;;;13404:29;-1:-1:-1;;;13449:18:41;;;13442:33;13492:18;;9512:39:36;13190:326:41;9512:39:36;9569:24;;;;:17;:24;;;;;;;;:33;9561:49;;;;-1:-1:-1;;;9561:49:36;;13723:2:41;9561:49:36;;;13705:21:41;13762:1;13742:18;;;13735:29;-1:-1:-1;;;13780:18:41;;;13773:33;13823:18;;9561:49:36;13521:326:41;9561:49:36;9620:28;9651:16;;;:9;:16;;;;;;;;9700:12;:19;;;;;;9751:16;:23;;;;;;9801:9;:16;;;;;;;9651;;9700:19;;9751:23;9620:28;9829:6;;9801:24;;1341:4;;9801:24;:::i;:::-;9800:35;;;;:::i;:::-;9784:51;-1:-1:-1;9862:6:36;9845:603;9874:14;9883:5;9874:6;:14;:::i;:::-;9870:1;:18;9845:603;;;9918:11;;9913:16;;9909:27;9931:5;9909:27;9950:17;9970:4;9975:1;9970:7;;;;;;;;:::i;:::-;;;;;;;;;;;;;9995:26;;;:19;:26;;;;;;-1:-1:-1;;;;;9970:7:36;;;9995:40;;;;;;;;;;9970:7;;-1:-1:-1;9995:40:36;;9991:54;;;10037:8;;;9991:54;-1:-1:-1;;;;;10076:24:36;;;10059:14;10076:24;;;:10;:24;;;;;;10155:11;;10076:24;;;10155:15;;10169:1;;10155:15;:::i;:::-;10136:3;-1:-1:-1;;;;;10136:13:36;;:15;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;:35;;;;:::i;:::-;10114:57;-1:-1:-1;10185:19:36;10231:11;10208:19;10114:57;10208:5;:19;:::i;:::-;10207:35;;;;:::i;:::-;-1:-1:-1;;;;;10256:22:36;;;;;;:14;:22;;;;;:37;;10185:57;;-1:-1:-1;10185:57:36;;10256:22;;;:37;;10185:57;;10256:37;:::i;:::-;;;;-1:-1:-1;;10307:26:36;;;;:19;:26;;;;;;;;-1:-1:-1;;;;;10307:40:36;;;;;;;;;;;:47;;-1:-1:-1;;10307:47:36;10350:4;10307:47;;;10368:27;;-1:-1:-1;;;10368:27:36;;;;;828:25:41;;;10368:13:36;;801:18:41;;10368:27:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;10409:26:36;;;;:19;:26;;;;;:28;;;-1:-1:-1;10409:26:36;:28;;;:::i;:::-;;;;;;9895:553;;;;9845:603;9890:3;;;;:::i;:::-;;;;9845:603;;;-1:-1:-1;10491:16:36;;;;:9;:16;;;;;;;;:23;10461:19;:26;;;;;;;:53;10457:115;;10530:24;;;;:17;:24;;;;;:31;;-1:-1:-1;;10530:31:36;10557:4;10530:31;;;10457:115;9451:1127;;;;9376:1202;;;:::o;5354:147:22:-;4578:7;4604:12;;;;;;;;;;:22;;;2631:16;2642:4;2631:10;:16::i;:::-;5468:26:::1;5480:4;5486:7;5468:11;:26::i;847:98:2:-:0;2075:20;:18;:20::i;:::-;918:22:::1;937:2;918:18;:22::i;2049:50:36:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;7813:368::-;7942:13;7958:24;;;:13;:24;;;;;;;;;8033:17;;;:10;:17;;;;;;7958:24;;7942:13;8016:11;;7942:13;8016:14;;;;;:::i;:::-;;;;;;;:34;;;;:::i;:::-;8015:40;;8054:1;8015:40;:::i;:::-;8078:19;;;;:12;:19;;;;;:34;;;7992:63;-1:-1:-1;8122:20:36;8091:5;8122:13;:20::i;:::-;-1:-1:-1;8152:18:36;;;;:11;:18;;;;;:22;;-1:-1:-1;;8152:22:36;8173:1;8152:22;;;-1:-1:-1;;;7813:368:36:o;3460:103:22:-;3526:30;3537:4;734:10:30;3526::22;:30::i;7587:233::-;7670:22;7678:4;7684:7;7670;:22::i;:::-;7665:149;;7708:6;:12;;;;;;;;;;;-1:-1:-1;;;;;7708:29:22;;;;;;;;;:36;;-1:-1:-1;;7708:36:22;7740:4;7708:36;;;7790:12;734:10:30;;655:96;7790:12:22;-1:-1:-1;;;;;7763:40:22;7781:7;-1:-1:-1;;;;;7763:40:22;7775:4;7763:40;;;;;;;;;;7587:233;;:::o;6975:832:36:-;2261:21:25;:19;:21::i;:::-;7058:17:36::1;7097:14;-1:-1:-1::0;;;;;7078:66:36::1;;7162:455;;;;;;;;7228:7;7162:455;;;;7264:14;7162:455;;;;1783:1;7162:455;;;;;;1722:9;7162:455;;;;;;1825:1;7162:455;;;;;;7471:127;7525:51;;;;;;;;7569:5;7525:51;;;;::::0;7471:28:::1;:127::i;:::-;7162:455;;::::0;7078:553:::1;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;7641:20;::::0;;;:13:::1;:20;::::0;;;;;;;:32;;;7683:24;;;:13:::1;:24:::0;;;;;:32;;;7725:18;;;:11:::1;:18:::0;;;;;;:22;;-1:-1:-1;;7725:22:36::1;7746:1;7725:22;::::0;;7762:38;7058:573;;-1:-1:-1;7058:573:36;;7655:5;;7762:38:::1;::::0;::::1;7048:759;2303:20:25::0;1716:1;2809:7;:22;2629:209;7991:234:22;8074:22;8082:4;8088:7;8074;:22::i;:::-;8070:149;;;8144:5;8112:12;;;;;;;;;;;-1:-1:-1;;;;;8112:29:22;;;;;;;;;;:37;;-1:-1:-1;;8112:37:22;;;8168:40;734:10:30;;8112:12:22;;8168:40;;8144:5;8168:40;7991:234;;:::o;1809:162:2:-;1932:7;;-1:-1:-1;;;;;1932:7:2;1918:10;:21;1910:56;;;;-1:-1:-1;;;1910:56:2;;15927:2:41;1910:56:2;;;15909:21:41;15966:2;15946:18;;;15939:30;-1:-1:-1;;;15985:18:41;;;15978:52;16047:18;;1910:56:2;15725:346:41;1910:56:2;1809:162::o;1536:239::-;1655:10;-1:-1:-1;;;;;1649:16:2;;;1641:52;;;;-1:-1:-1;;;1641:52:2;;16278:2:41;1641:52:2;;;16260:21:41;16317:2;16297:18;;;16290:30;16356:25;16336:18;;;16329:53;16399:18;;1641:52:2;16076:347:41;1641:52:2;1700:14;:19;;-1:-1:-1;;;;;;1700:19:2;-1:-1:-1;;;;;1700:19:2;;;;;;;;;-1:-1:-1;1758:7:2;1731:39;;1700:19;;1758:7;;1731:39;;-1:-1:-1;;1731:39:2;1536:239;:::o;8187:1183:36:-;2261:21:25;:19;:21::i;:::-;8257:20:36::1;8280:19:::0;;;:12:::1;:19;::::0;;;;;;;;8340:9:::1;:16:::0;;;;;8442:11;;8280:19;;8340:16;;8257:20;;8442:15:::1;::::0;8456:1:::1;::::0;8442:15:::1;:::i;:::-;8427:30;;8468:896;8482:4;8475:3;:11;8468:896;;8502:11;8531:1;8517:10;8523:4:::0;8517:3;:10:::1;:::i;:::-;8516:16;;;;:::i;:::-;8502:30;;8546:17;8566:4;8571:3;8566:9;;;;;;;;:::i;:::-;;::::0;;;::::1;::::0;;;;;::::1;::::0;8605:20:::1;::::0;;-1:-1:-1;;;8605:20:36;;;;-1:-1:-1;;;;;8566:9:36;;::::1;::::0;-1:-1:-1;8566:9:36;;8605:18:::1;::::0;:20:::1;::::0;;::::1;::::0;;;;;;8566:9;8605:20:::1;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;8589:36;;8639:11;8653:3;-1:-1:-1::0;;;;;8653:16:36::1;;:18;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;8639:32;;8699:12;8690:5;:21;;:44;;;;;8722:12;8715:3;:19;;8690:44;8686:668;;;8754:12;8769:16:::0;;;:9:::1;:16;::::0;;;;;;8875:6:::1;8859:12;1341:4;8769:16:::0;8859:12:::1;:::i;:::-;8858:23;;;;:::i;:::-;8842:39:::0;-1:-1:-1;8935:11:36::1;8842:39:::0;8972:6:::1;8958:10;8965:3;8958:4:::0;:10:::1;:::i;:::-;8957:21;;;;:::i;:::-;8949:30;::::0;:4;:30:::1;:::i;:::-;:38;;;;:::i;:::-;8935:52;;9065:5;-1:-1:-1::0;;;;;9058:22:36::1;;9081:3;-1:-1:-1::0;;;;;9081:13:36::1;;:15;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;9058:47;::::0;-1:-1:-1;;;;;;9058:47:36::1;::::0;;;;;;-1:-1:-1;;;;;6222:32:41;;;9058:47:36::1;::::0;::::1;6204:51:41::0;6271:18;;;6264:34;;;6177:18;;9058:47:36::1;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;9050:63;;;::::0;-1:-1:-1;;;9050:63:36;;6793:2:41;9050:63:36::1;::::0;::::1;6775:21:41::0;6832:1;6812:18;;;6805:29;-1:-1:-1;;;6850:18:41;;;6843:33;6893:18;;9050:63:36::1;6591:326:41::0;9050:63:36::1;9182:3;-1:-1:-1::0;;;;;9136:51:36::1;9160:12;9153:5;9136:51;;;;;;;;;;9205:5;;;;;;;;;8686:668;9241:12;9235:3;:18;9231:123;;;9279:7;:3:::0;9285:1:::1;9279:7;:::i;:::-;9273:13;;9231:123;;;9332:7;9338:1;9332:3:::0;:7:::1;:::i;:::-;9325:14;;9231:123;8488:876;;;;8468:896;;;8247:1123;;;;2303:20:25::0;1716:1;2809:7;:22;2629:209;3844:479:22;3932:22;3940:4;3946:7;3932;:22::i;:::-;3927:390;;4115:28;4135:7;4115:19;:28::i;:::-;4214:38;4242:4;4249:2;4214:19;:38::i;:::-;4022:252;;;;;;;;;:::i;:::-;;;;-1:-1:-1;;4022:252:22;;;;;;;;;;-1:-1:-1;;;3970:336:22;;;;;;;:::i;2336:287:25:-;1759:1;2468:7;;:19;2460:63;;;;-1:-1:-1;;;2460:63:25;;17927:2:41;2460:63:25;;;17909:21:41;17966:2;17946:18;;;17939:30;18005:33;17985:18;;;17978:61;18056:18;;2460:63:25;17725:355:41;2460:63:25;1759:1;2598:7;:18;2336:287::o;475:163:20:-;550:16;211:28;623:9;581:52;;;;;;18321:13:41;18314:21;18307:29;18289:48;;18277:2;18262:18;;18085:258;581:52:20;;;;-1:-1:-1;;581:52:20;;;;;;;;;;;;;;-1:-1:-1;;;;;581:52:20;-1:-1:-1;;;;;;581:52:20;;;;;;;;;;;475:163;-1:-1:-1;;475:163:20:o;2407:149:31:-;2465:13;2497:52;-1:-1:-1;;;;;2509:22:31;;343:2;1818:437;1893:13;1918:19;1950:10;1954:6;1950:1;:10;:::i;:::-;:14;;1963:1;1950:14;:::i;:::-;1940:25;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1940:25:31;;1918:47;;-1:-1:-1;;;1975:6:31;1982:1;1975:9;;;;;;;;:::i;:::-;;;;:15;-1:-1:-1;;;;;1975:15:31;;;;;;;;;-1:-1:-1;;;2000:6:31;2007:1;2000:9;;;;;;;;:::i;:::-;;;;:15;-1:-1:-1;;;;;2000:15:31;;;;;;;;-1:-1:-1;2030:9:31;2042:10;2046:6;2042:1;:10;:::i;:::-;:14;;2055:1;2042:14;:::i;:::-;2030:26;;2025:128;2062:1;2058;:5;2025:128;;;-1:-1:-1;;;2105:5:31;2113:3;2105:11;2096:21;;;;;;;:::i;:::-;;;;2084:6;2091:1;2084:9;;;;;;;;:::i;:::-;;;;:33;-1:-1:-1;;;;;2084:33:31;;;;;;;;-1:-1:-1;2141:1:31;2131:11;;;;;2065:3;;;:::i;:::-;;;2025:128;;;-1:-1:-1;2170:10:31;;2162:55;;;;-1:-1:-1;;;2162:55:31;;18823:2:41;2162:55:31;;;18805:21:41;;;18842:18;;;18835:30;18901:34;18881:18;;;18874:62;18953:18;;2162:55:31;18621:356:41;2162:55:31;2241:6;1818:437;-1:-1:-1;;;1818:437:31:o;-1:-1:-1:-;;;;;;;;:::o;14:286:41:-;72:6;125:2;113:9;104:7;100:23;96:32;93:52;;;141:1;138;131:12;93:52;167:23;;-1:-1:-1;;;;;;219:32:41;;209:43;;199:71;;266:1;263;256:12;497:180;556:6;609:2;597:9;588:7;584:23;580:32;577:52;;;625:1;622;615:12;577:52;-1:-1:-1;648:23:41;;497:180;-1:-1:-1;497:180:41:o;864:131::-;-1:-1:-1;;;;;939:31:41;;929:42;;919:70;;985:1;982;975:12;1000:247;1059:6;1112:2;1100:9;1091:7;1087:23;1083:32;1080:52;;;1128:1;1125;1118:12;1080:52;1167:9;1154:23;1186:31;1211:5;1186:31;:::i;1434:683::-;1529:6;1537;1545;1598:2;1586:9;1577:7;1573:23;1569:32;1566:52;;;1614:1;1611;1604:12;1566:52;1650:9;1637:23;1627:33;;1711:2;1700:9;1696:18;1683:32;1734:18;1775:2;1767:6;1764:14;1761:34;;;1791:1;1788;1781:12;1761:34;1829:6;1818:9;1814:22;1804:32;;1874:7;1867:4;1863:2;1859:13;1855:27;1845:55;;1896:1;1893;1886:12;1845:55;1936:2;1923:16;1962:2;1954:6;1951:14;1948:34;;;1978:1;1975;1968:12;1948:34;2031:7;2026:2;2016:6;2013:1;2009:14;2005:2;2001:23;1997:32;1994:45;1991:65;;;2052:1;2049;2042:12;1991:65;2083:2;2079;2075:11;2065:21;;2105:6;2095:16;;;;;1434:683;;;;;:::o;2307:315::-;2375:6;2383;2436:2;2424:9;2415:7;2411:23;2407:32;2404:52;;;2452:1;2449;2442:12;2404:52;2488:9;2475:23;2465:33;;2548:2;2537:9;2533:18;2520:32;2561:31;2586:5;2561:31;:::i;:::-;2611:5;2601:15;;;2307:315;;;;;:::o;2627:794::-;2715:6;2723;2731;2739;2792:2;2780:9;2771:7;2767:23;2763:32;2760:52;;;2808:1;2805;2798:12;2760:52;2847:9;2834:23;2866:31;2891:5;2866:31;:::i;:::-;2916:5;-1:-1:-1;2968:2:41;2953:18;;2940:32;;-1:-1:-1;3023:2:41;3008:18;;2995:32;3046:18;3076:14;;;3073:34;;;3103:1;3100;3093:12;3073:34;3141:6;3130:9;3126:22;3116:32;;3186:7;3179:4;3175:2;3171:13;3167:27;3157:55;;3208:1;3205;3198:12;3157:55;3248:2;3235:16;3274:2;3266:6;3263:14;3260:34;;;3290:1;3287;3280:12;3260:34;3335:7;3330:2;3321:6;3317:2;3313:15;3309:24;3306:37;3303:57;;;3356:1;3353;3346:12;3303:57;2627:794;;;;-1:-1:-1;;3387:2:41;3379:11;;-1:-1:-1;;;2627:794:41:o;3954:248::-;4022:6;4030;4083:2;4071:9;4062:7;4058:23;4054:32;4051:52;;;4099:1;4096;4089:12;4051:52;-1:-1:-1;;4122:23:41;;;4192:2;4177:18;;;4164:32;;-1:-1:-1;3954:248:41:o;4869:316::-;4946:6;4954;4962;5015:2;5003:9;4994:7;4990:23;4986:32;4983:52;;;5031:1;5028;5021:12;4983:52;-1:-1:-1;;5054:23:41;;;5124:2;5109:18;;5096:32;;-1:-1:-1;5175:2:41;5160:18;;;5147:32;;4869:316;-1:-1:-1;4869:316:41:o;5379:315::-;5447:6;5455;5508:2;5496:9;5487:7;5483:23;5479:32;5476:52;;;5524:1;5521;5514:12;5476:52;5563:9;5550:23;5582:31;5607:5;5582:31;:::i;:::-;5632:5;5684:2;5669:18;;;;5656:32;;-1:-1:-1;;;5379:315:41:o;6309:277::-;6376:6;6429:2;6417:9;6408:7;6404:23;6400:32;6397:52;;;6445:1;6442;6435:12;6397:52;6477:9;6471:16;6530:5;6523:13;6516:21;6509:5;6506:32;6496:60;;6552:1;6549;6542:12;8555:391;8640:6;8648;8656;8709:2;8697:9;8688:7;8684:23;8680:32;8677:52;;;8725:1;8722;8715:12;8677:52;8764:9;8751:23;8783:31;8808:5;8783:31;:::i;:::-;8833:5;8885:2;8870:18;;8857:32;;-1:-1:-1;8936:2:41;8921:18;;;8908:32;;8555:391;-1:-1:-1;;;8555:391:41:o;8951:127::-;9012:10;9007:3;9003:20;9000:1;8993:31;9043:4;9040:1;9033:15;9067:4;9064:1;9057:15;9083:168;9156:9;;;9187;;9204:15;;;9198:22;;9184:37;9174:71;;9225:18;;:::i;10249:125::-;10314:9;;;10335:10;;;10332:36;;;10348:18;;:::i;11306:135::-;11345:3;11366:17;;;11363:43;;11386:18;;:::i;:::-;-1:-1:-1;11433:1:41;11422:13;;11306:135::o;12933:127::-;12994:10;12989:3;12985:20;12982:1;12975:31;13025:4;13022:1;13015:15;13049:4;13046:1;13039:15;13065:120;13105:1;13131;13121:35;;13136:18;;:::i;:::-;-1:-1:-1;13170:9:41;;13065:120::o;13852:127::-;13913:10;13908:3;13904:20;13901:1;13894:31;13944:4;13941:1;13934:15;13968:4;13965:1;13958:15;13984:128;14051:9;;;14072:11;;;14069:37;;;14086:18;;:::i;14117:184::-;14187:6;14240:2;14228:9;14219:7;14215:23;14211:32;14208:52;;;14256:1;14253;14246:12;14208:52;-1:-1:-1;14279:16:41;;14117:184;-1:-1:-1;14117:184:41:o;14306:112::-;14338:1;14364;14354:35;;14369:18;;:::i;:::-;-1:-1:-1;14403:9:41;;14306:112::o;14423:250::-;14508:1;14518:113;14532:6;14529:1;14526:13;14518:113;;;14608:11;;;14602:18;14589:11;;;14582:39;14554:2;14547:10;14518:113;;;-1:-1:-1;;14665:1:41;14647:16;;14640:27;14423:250::o;14678:270::-;14719:3;14757:5;14751:12;14784:6;14779:3;14772:19;14800:76;14869:6;14862:4;14857:3;14853:14;14846:4;14839:5;14835:16;14800:76;:::i;:::-;14930:2;14909:15;-1:-1:-1;;14905:29:41;14896:39;;;;14937:4;14892:50;;14678:270;-1:-1:-1;;14678:270:41:o;14953:767::-;15154:2;15143:9;15136:21;15199:6;15193:13;15188:2;15177:9;15173:18;15166:41;15261:2;15253:6;15249:15;15243:22;15238:2;15227:9;15223:18;15216:50;15330:6;15324:2;15316:6;15312:15;15306:22;15302:35;15297:2;15286:9;15282:18;15275:63;15117:4;15385:2;15377:6;15373:15;15367:22;15408:10;15473:2;15459:12;15455:21;15449:3;15438:9;15434:19;15427:50;15543:2;15536:3;15528:6;15524:16;15518:23;15514:32;15508:3;15497:9;15493:19;15486:61;;;15596:3;15588:6;15584:16;15578:23;15639:4;15632;15621:9;15617:20;15610:34;15661:53;15709:3;15698:9;15694:19;15678:14;15661:53;:::i;:::-;15653:61;14953:767;-1:-1:-1;;;;14953:767:41:o;16428:251::-;16498:6;16551:2;16539:9;16530:7;16526:23;16522:32;16519:52;;;16567:1;16564;16557:12;16519:52;16599:9;16593:16;16618:31;16643:5;16618:31;:::i;16684:812::-;17095:25;17090:3;17083:38;17065:3;17150:6;17144:13;17166:75;17234:6;17229:2;17224:3;17220:12;17213:4;17205:6;17201:17;17166:75;:::i;:::-;-1:-1:-1;;;17300:2:41;17260:16;;;17292:11;;;17285:40;17350:13;;17372:76;17350:13;17434:2;17426:11;;17419:4;17407:17;;17372:76;:::i;:::-;17468:17;17487:2;17464:26;;16684:812;-1:-1:-1;;;;16684:812:41:o;17501:219::-;17650:2;17639:9;17632:21;17613:4;17670:44;17710:2;17699:9;17695:18;17687:6;17670:44;:::i;18348:127::-;18409:10;18404:3;18400:20;18397:1;18390:31;18440:4;18437:1;18430:15;18464:4;18461:1;18454:15;18480:136;18519:3;18547:5;18537:39;;18556:18;;:::i;:::-;-1:-1:-1;;;18592:18:41;;18480:136::o
Swarm Source
ipfs://9dbc66a9583cbccf7c13ff13ded3c8ff310a1486246fa9314244d9cbe35e28a4
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
[ 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.