Transactions
Token Transfers
Tokens
Internal Transactions
Coin Balance History
Logs
Code
Read Contract
Write Contract
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- SoyLottery
- Optimization enabled
- true
- Compiler version
- v0.8.7+commit.e28d00a7
- Optimization runs
- 200
- EVM Version
- default
- Verified at
- 2024-09-26T15:34:21.990909Z
Constructor Arguments
0x0000000000000000000000009fae2529863bd691b4a7171bdfcf33c7ebb10a650000000000000000000000009bfa10ec7cbdfa029692c95e493f2fc1bdcb25af
Arg [0] (address) : 0x9fae2529863bd691b4a7171bdfcf33c7ebb10a65
Arg [1] (address) : 0x9bfa10ec7cbdfa029692c95e493f2fc1bdcb25af
Contract source code
/** *Submitted for verification at BscScan.com on 2021-07-02 */ // File: @openzeppelin/contracts/utils/Context.sol // SPDX-License-Identifier: MIT 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) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts/access/Ownable.sol pragma solidity ^0.8.0; /** * @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() { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = 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"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: @openzeppelin/contracts/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 make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // File: @openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @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 `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, 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 `sender` to `recipient` 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 sender, address recipient, uint256 amount ) external returns (bool); /** * @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); } // File: @openzeppelin/contracts/utils/Address.sol pragma solidity ^0.8.0; /** * @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 * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 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://diligence.consensys.net/posts/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.5.11/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"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (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 functionCall(target, data, "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"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{value: value}(data); return _verifyCallResult(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) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(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) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) private pure returns (bytes memory) { if (success) { return returndata; } else { // 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 // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol pragma solidity ^0.8.0; /** * @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; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } 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' // solhint-disable-next-line max-line-length 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)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } 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"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @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"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // File: contracts/interfaces/IRandomNumberGenerator.sol pragma solidity ^0.8.4; interface IRandomNumberGenerator { /** * Requests randomness from a user-provided seed */ function getRandomNumber(uint256 _seed) external; /** * View latest lotteryId numbers */ function viewLatestLotteryId() external view returns (uint256); /** * Views random result */ function viewRandomResult() external view returns (uint32); } // File: contracts/interfaces/ISoyLottery.sol pragma solidity ^0.8.4; interface ISoyLottery { /** * @notice Buy tickets for the current lottery * @param _lotteryId: lotteryId * @param _ticketNumbers: array of ticket numbers between 1,000,000 and 1,999,999 * @dev Callable by users */ function buyTickets(uint256 _lotteryId, uint32[] calldata _ticketNumbers) external; /** * @notice Claim a set of winning tickets for a lottery * @param _lotteryId: lottery id * @param _ticketIds: array of ticket ids * @param _brackets: array of brackets for the ticket ids * @dev Callable by users only, not contract! */ function claimTickets( uint256 _lotteryId, uint256[] calldata _ticketIds, uint32[] calldata _brackets ) external; /** * @notice Close lottery * @param _lotteryId: lottery id * @dev Callable by operator */ function closeLottery(uint256 _lotteryId) external; /** * @notice Draw the final number, calculate reward in SOY per group, and make lottery claimable * @param _lotteryId: lottery id * @param _autoInjection: reinjects funds into next lottery (vs. withdrawing all) * @dev Callable by operator */ function drawFinalNumberAndMakeLotteryClaimable(uint256 _lotteryId, bool _autoInjection) external; /** * @notice Inject funds * @param _lotteryId: lottery id * @param _amount: amount to inject in SOY token * @dev Callable by operator */ function injectFunds(uint256 _lotteryId, uint256 _amount) external; /** * @notice Start the lottery * @dev Callable by operator * @param _endTime: endTime of the lottery * @param _priceTicketInSoy: price of a ticket in SOY * @param _discountDivisor: the divisor to calculate the discount magnitude for bulks * @param _rewardsBreakdown: breakdown of rewards per bracket (must sum to 10,000) * @param _treasuryFee: treasury fee (10,000 = 100%, 100 = 1%) */ function startLottery( uint256 _endTime, uint256 _priceTicketInSoy, uint256 _discountDivisor, uint256[6] calldata _rewardsBreakdown, uint256 _treasuryFee ) external; /** * @notice View current lottery id */ function viewCurrentLotteryId() external returns (uint256); } // File: contracts/SoyLottery.sol pragma solidity ^0.8.4; pragma abicoder v2; /** @title Soy Lottery. * @notice It is a contract for a lottery system using * randomness provided externally. */ contract SoyLottery is ReentrancyGuard, ISoyLottery, Ownable { using SafeERC20 for IERC20; uint256 constant MAX_BRACKETS = 3; // maximum winning combination (i.e. first 1, first 2, first 3, ...). (Default: 6) address public injectorAddress; address public operatorAddress; address public treasuryAddress; uint256 public currentLotteryId; uint256 public currentTicketId; uint256 public maxNumberTicketsPerBuyOrClaim = 100; uint256 public maxPriceTicketInSoy = 50 ether; uint256 public minPriceTicketInSoy = 0.005 ether; uint256 public pendingInjectionNextLottery; uint256 public constant MIN_DISCOUNT_DIVISOR = 300; uint256 public MIN_LENGTH_LOTTERY = 20 hours - 5 minutes; // 4 hours uint256 public MAX_LENGTH_LOTTERY = 8 days + 5 minutes; // 4 days uint256 public constant MAX_TREASURY_FEE = 3000; // 30% IERC20 public soyToken; IRandomNumberGenerator public randomGenerator; enum Status { Pending, Open, Close, Claimable } struct Lottery { Status status; uint256 startTime; uint256 endTime; uint256 priceTicketInSoy; uint256 discountDivisor; uint256[6] rewardsBreakdown; // 0: 1 matching number // 5: 6 matching numbers uint256 treasuryFee; // 500: 5% // 200: 2% // 50: 0.5% uint256[6] soyPerBracket; uint256[6] countWinnersPerBracket; uint256 firstTicketId; uint256 firstTicketIdNextLottery; uint256 amountCollectedInSoy; uint32 finalNumber; } struct Ticket { uint32 number; address owner; } // Mapping are cheaper than arrays mapping(uint256 => Lottery) private _lotteries; mapping(uint256 => Ticket) private _tickets; // Bracket calculator is used for verifying claims for ticket prizes mapping(uint32 => uint32) private _bracketCalculator; // Keeps track of number of ticket per unique combination for each lotteryId mapping(uint256 => mapping(uint32 => uint256)) private _numberTicketsPerLotteryId; // Keep track of user ticket ids for a given lotteryId mapping(address => mapping(uint256 => uint256[])) private _userTicketIdsPerLotteryId; modifier notContract() { require(!_isContract(msg.sender), "Contract not allowed"); require(msg.sender == tx.origin, "Proxy contract not allowed"); _; } modifier onlyOperator() { require(msg.sender == operatorAddress, "Not operator"); _; } modifier onlyOwnerOrInjector() { require((msg.sender == owner()) || (msg.sender == injectorAddress), "Not owner or injector"); _; } event AdminTokenRecovery(address token, uint256 amount); event LotteryClose(uint256 indexed lotteryId, uint256 firstTicketIdNextLottery); event LotteryInjection(uint256 indexed lotteryId, uint256 injectedAmount); event LotteryOpen( uint256 indexed lotteryId, uint256 startTime, uint256 endTime, uint256 priceTicketInSoy, uint256 firstTicketId, uint256 injectedAmount ); event LotteryNumberDrawn(uint256 indexed lotteryId, uint256 finalNumber, uint256 countWinningTickets); event NewOperatorAndTreasuryAndInjectorAddresses(address operator, address treasury, address injector); event NewRandomGenerator(address indexed randomGenerator); event TicketsPurchase(address indexed buyer, uint256 indexed lotteryId, uint256 numberTickets); event TicketsClaim(address indexed claimer, uint256 amount, uint256 indexed lotteryId, uint256 numberTickets); /** * @notice Constructor * @dev RandomNumberGenerator must be deployed prior to this contract * @param _soyTokenAddress: address of the SOY token * @param _randomGeneratorAddress: address of the RandomGenerator contract used to work with ChainLink VRF */ constructor(address _soyTokenAddress, address _randomGeneratorAddress) { soyToken = IERC20(_soyTokenAddress); randomGenerator = IRandomNumberGenerator(_randomGeneratorAddress); // Initializes a mapping _bracketCalculator[0] = 1; _bracketCalculator[1] = 11; _bracketCalculator[2] = 111; _bracketCalculator[3] = 1111; _bracketCalculator[4] = 11111; _bracketCalculator[5] = 111111; } /** * @notice Buy tickets for the current lottery * @param _lotteryId: lotteryId * @param _ticketNumbers: array of ticket numbers between 1,000,000 and 1,999,999 * @dev Callable by users */ function buyTickets(uint256 _lotteryId, uint32[] calldata _ticketNumbers) external override notContract nonReentrant { require(_ticketNumbers.length != 0, "No ticket specified"); require(_ticketNumbers.length <= maxNumberTicketsPerBuyOrClaim, "Too many tickets"); require(_lotteries[_lotteryId].status == Status.Open, "Lottery is not open"); require(block.timestamp < _lotteries[_lotteryId].endTime, "Lottery is over"); // Calculate number of SOY to this contract uint256 amountSoyToTransfer = _calculateTotalPriceForBulkTickets( _lotteries[_lotteryId].discountDivisor, _lotteries[_lotteryId].priceTicketInSoy, _ticketNumbers.length ); // Transfer soy tokens to this contract soyToken.safeTransferFrom(address(msg.sender), address(this), amountSoyToTransfer); // Increment the total amount collected for the lottery round _lotteries[_lotteryId].amountCollectedInSoy += amountSoyToTransfer; for (uint256 i = 0; i < _ticketNumbers.length; i++) { uint32 thisTicketNumber = _ticketNumbers[i]; //require((thisTicketNumber >= 1000000) && (thisTicketNumber <= 1999999), "Outside range"); require((thisTicketNumber >= 1000) && (thisTicketNumber <= 1999), "Outside range"); _numberTicketsPerLotteryId[_lotteryId][1 + (thisTicketNumber % 10)]++; _numberTicketsPerLotteryId[_lotteryId][11 + (thisTicketNumber % 100)]++; _numberTicketsPerLotteryId[_lotteryId][111 + (thisTicketNumber % 1000)]++; //_numberTicketsPerLotteryId[_lotteryId][1111 + (thisTicketNumber % 10000)]++; //_numberTicketsPerLotteryId[_lotteryId][11111 + (thisTicketNumber % 100000)]++; //_numberTicketsPerLotteryId[_lotteryId][111111 + (thisTicketNumber % 1000000)]++; _userTicketIdsPerLotteryId[msg.sender][_lotteryId].push(currentTicketId); _tickets[currentTicketId] = Ticket({number: thisTicketNumber, owner: msg.sender}); // Increase lottery ticket number currentTicketId++; } emit TicketsPurchase(msg.sender, _lotteryId, _ticketNumbers.length); } /** * @notice Claim a set of winning tickets for a lottery * @param _lotteryId: lottery id * @param _ticketIds: array of ticket ids * @param _brackets: array of brackets for the ticket ids * @dev Callable by users only, not contract! */ function claimTickets( uint256 _lotteryId, uint256[] calldata _ticketIds, uint32[] calldata _brackets ) external override notContract nonReentrant { require(_ticketIds.length == _brackets.length, "Not same length"); require(_ticketIds.length != 0, "Length must be >0"); require(_ticketIds.length <= maxNumberTicketsPerBuyOrClaim, "Too many tickets"); require(_lotteries[_lotteryId].status == Status.Claimable, "Lottery not claimable"); // Initializes the rewardInSoyToTransfer uint256 rewardInSoyToTransfer; for (uint256 i = 0; i < _ticketIds.length; i++) { require(_brackets[i] < MAX_BRACKETS, "Bracket out of range"); // Must be between 0 and 5 uint256 thisTicketId = _ticketIds[i]; require(_lotteries[_lotteryId].firstTicketIdNextLottery > thisTicketId, "TicketId too high"); require(_lotteries[_lotteryId].firstTicketId <= thisTicketId, "TicketId too low"); require(msg.sender == _tickets[thisTicketId].owner, "Not the owner"); // Update the lottery ticket owner to 0x address _tickets[thisTicketId].owner = address(0); uint256 rewardForTicketId = _calculateRewardsForTicketId(_lotteryId, thisTicketId, _brackets[i]); // Check user is claiming the correct bracket require(rewardForTicketId != 0, "No prize for this bracket"); if (_brackets[i] != (MAX_BRACKETS-1)) { require( _calculateRewardsForTicketId(_lotteryId, thisTicketId, _brackets[i] + 1) == 0, "Bracket must be higher" ); } // Increment the reward to transfer rewardInSoyToTransfer += rewardForTicketId; } // Transfer money to msg.sender soyToken.safeTransfer(msg.sender, rewardInSoyToTransfer); emit TicketsClaim(msg.sender, rewardInSoyToTransfer, _lotteryId, _ticketIds.length); } /** * @notice Close lottery * @param _lotteryId: lottery id * * @dev Callable by operator */ function closeLottery(uint256 _lotteryId) external override onlyOperator nonReentrant { require(_lotteries[_lotteryId].status == Status.Open, "Lottery not open"); require(block.timestamp > _lotteries[_lotteryId].endTime, "Lottery not over"); _lotteries[_lotteryId].firstTicketIdNextLottery = currentTicketId; // Request a random number from the generator based on a seed randomGenerator.getRandomNumber(uint256(keccak256(abi.encodePacked(_lotteryId, currentTicketId)))); _lotteries[_lotteryId].status = Status.Close; emit LotteryClose(_lotteryId, currentTicketId); } /** * @notice Draw the final number, calculate reward in SOY per group, and make lottery claimable * @param _lotteryId: lottery id * @param _autoInjection: reinjects funds into next lottery (vs. withdrawing all) * @dev Callable by operator */ function drawFinalNumberAndMakeLotteryClaimable(uint256 _lotteryId, bool _autoInjection) external override onlyOperator nonReentrant { require(_lotteries[_lotteryId].status == Status.Close, "Lottery not close"); require(_lotteryId == randomGenerator.viewLatestLotteryId(), "Numbers not drawn"); // Calculate the finalNumber based on the randomResult generated by ChainLink's fallback uint32 finalNumber = randomGenerator.viewRandomResult(); // Initialize a number to count addresses in the previous bracket uint256 numberAddressesInPreviousBracket; // Calculate the amount to share post-treasury fee uint256 amountToShareToWinners = ( ((_lotteries[_lotteryId].amountCollectedInSoy) * (10000 - _lotteries[_lotteryId].treasuryFee)) ) / 10000; // Initializes the amount to withdraw to treasury uint256 amountToWithdrawToTreasury; // Calculate prizes in SOY for each bracket by starting from the highest one for (uint32 i = 0; i < MAX_BRACKETS; i++) { uint32 j = uint32(MAX_BRACKETS-1) - i; uint32 transformedWinningNumber = _bracketCalculator[j] + (finalNumber % (uint32(10)**(j + 1))); _lotteries[_lotteryId].countWinnersPerBracket[j] = _numberTicketsPerLotteryId[_lotteryId][transformedWinningNumber] - numberAddressesInPreviousBracket; // A. If number of users for this _bracket number is superior to 0 if ( (_numberTicketsPerLotteryId[_lotteryId][transformedWinningNumber] - numberAddressesInPreviousBracket) != 0 ) { // B. If rewards at this bracket are > 0, calculate, else, report the numberAddresses from previous bracket if (_lotteries[_lotteryId].rewardsBreakdown[j] != 0) { _lotteries[_lotteryId].soyPerBracket[j] = ((_lotteries[_lotteryId].rewardsBreakdown[j] * amountToShareToWinners) / (_numberTicketsPerLotteryId[_lotteryId][transformedWinningNumber] - numberAddressesInPreviousBracket)) / 10000; // Update numberAddressesInPreviousBracket numberAddressesInPreviousBracket = _numberTicketsPerLotteryId[_lotteryId][transformedWinningNumber]; } // A. No SOY to distribute, they are added to the amount to withdraw to treasury address } else { _lotteries[_lotteryId].soyPerBracket[j] = 0; amountToWithdrawToTreasury += (_lotteries[_lotteryId].rewardsBreakdown[j] * amountToShareToWinners) / 10000; } } // Update internal statuses for lottery _lotteries[_lotteryId].finalNumber = finalNumber; _lotteries[_lotteryId].status = Status.Claimable; if (_autoInjection) { pendingInjectionNextLottery = amountToWithdrawToTreasury; amountToWithdrawToTreasury = 0; } amountToWithdrawToTreasury += (_lotteries[_lotteryId].amountCollectedInSoy - amountToShareToWinners); // Transfer SOY to treasury address soyToken.safeTransfer(treasuryAddress, amountToWithdrawToTreasury); emit LotteryNumberDrawn(currentLotteryId, finalNumber, numberAddressesInPreviousBracket); } /** * @notice Change the random generator * @dev The calls to functions are used to verify the new generator implements them properly. * It is necessary to wait for the VRF response before starting a round. * Callable only by the contract owner * @param _randomGeneratorAddress: address of the random generator */ function changeRandomGenerator(address _randomGeneratorAddress) external onlyOwner { require(_lotteries[currentLotteryId].status == Status.Claimable, "Lottery not in claimable"); // Request a random number from the generator based on a seed IRandomNumberGenerator(_randomGeneratorAddress).getRandomNumber( uint256(keccak256(abi.encodePacked(currentLotteryId, currentTicketId))) ); // Calculate the finalNumber based on the randomResult generated by ChainLink's fallback IRandomNumberGenerator(_randomGeneratorAddress).viewRandomResult(); randomGenerator = IRandomNumberGenerator(_randomGeneratorAddress); emit NewRandomGenerator(_randomGeneratorAddress); } /** * @notice Inject funds * @param _lotteryId: lottery id * @param _amount: amount to inject in SOY token * @dev Callable by owner or injector address */ function injectFunds(uint256 _lotteryId, uint256 _amount) external override onlyOwnerOrInjector { require(_lotteries[_lotteryId].status == Status.Open, "Lottery not open"); soyToken.safeTransferFrom(address(msg.sender), address(this), _amount); _lotteries[_lotteryId].amountCollectedInSoy += _amount; emit LotteryInjection(_lotteryId, _amount); } /** * @notice Start the lottery * @dev Callable by operator * @param _endTime: endTime of the lottery * @param _priceTicketInSoy: price of a ticket in SOY * @param _discountDivisor: the divisor to calculate the discount magnitude for bulks * @param _rewardsBreakdown: breakdown of rewards per bracket (must sum to 10,000) * @param _treasuryFee: treasury fee (10,000 = 100%, 100 = 1%) */ function startLottery( uint256 _endTime, uint256 _priceTicketInSoy, uint256 _discountDivisor, uint256[6] calldata _rewardsBreakdown, uint256 _treasuryFee ) external override onlyOperator { require( (currentLotteryId == 0) || (_lotteries[currentLotteryId].status == Status.Claimable), "Not time to start lottery" ); require( ((_endTime - block.timestamp) > MIN_LENGTH_LOTTERY) && ((_endTime - block.timestamp) < MAX_LENGTH_LOTTERY), "Lottery length outside of range" ); require( (_priceTicketInSoy >= minPriceTicketInSoy) && (_priceTicketInSoy <= maxPriceTicketInSoy), "Outside of limits" ); require(_discountDivisor >= MIN_DISCOUNT_DIVISOR, "Discount divisor too low"); require(_treasuryFee <= MAX_TREASURY_FEE, "Treasury fee too high"); require( (_rewardsBreakdown[0] + _rewardsBreakdown[1] + _rewardsBreakdown[2] + _rewardsBreakdown[3] + _rewardsBreakdown[4] + _rewardsBreakdown[5]) == 10000, "Rewards must equal 10000" ); currentLotteryId++; _lotteries[currentLotteryId] = Lottery({ status: Status.Open, startTime: block.timestamp, endTime: _endTime, priceTicketInSoy: _priceTicketInSoy, discountDivisor: _discountDivisor, rewardsBreakdown: _rewardsBreakdown, treasuryFee: _treasuryFee, soyPerBracket: [uint256(0), uint256(0), uint256(0), uint256(0), uint256(0), uint256(0)], countWinnersPerBracket: [uint256(0), uint256(0), uint256(0), uint256(0), uint256(0), uint256(0)], firstTicketId: currentTicketId, firstTicketIdNextLottery: currentTicketId, amountCollectedInSoy: pendingInjectionNextLottery, finalNumber: 0 }); emit LotteryOpen( currentLotteryId, block.timestamp, _endTime, _priceTicketInSoy, currentTicketId, pendingInjectionNextLottery ); pendingInjectionNextLottery = 0; } /** * @notice It allows the admin to recover wrong tokens sent to the contract * @param _tokenAddress: the address of the token to withdraw * @param _tokenAmount: the number of token amount to withdraw * @dev Only callable by owner. */ function recoverWrongTokens(address _tokenAddress, uint256 _tokenAmount) external onlyOwner { require(_tokenAddress != address(soyToken), "Cannot be SOY token"); IERC20(_tokenAddress).safeTransfer(address(msg.sender), _tokenAmount); emit AdminTokenRecovery(_tokenAddress, _tokenAmount); } /** * @notice Set SOY price ticket upper/lower limit * @dev Only callable by owner * @param _minPriceTicketInSoy: minimum price of a ticket in SOY * @param _maxPriceTicketInSoy: maximum price of a ticket in SOY */ function setMinAndMaxTicketPriceInSoy(uint256 _minPriceTicketInSoy, uint256 _maxPriceTicketInSoy) external onlyOwner { require(_minPriceTicketInSoy <= _maxPriceTicketInSoy, "minPrice must be < maxPrice"); minPriceTicketInSoy = _minPriceTicketInSoy; maxPriceTicketInSoy = _maxPriceTicketInSoy; } /** * @notice Set duration of lottery round * @dev Only callable by owner * @param _minRoundDuration: minimum duration of lottery round * @param _maxRoundDuration: maximum duration of lottery round */ function setMinAndMaxRoundDuration(uint256 _minRoundDuration, uint256 _maxRoundDuration) external onlyOwner { require(_minRoundDuration < _maxRoundDuration, "min must be < max"); MIN_LENGTH_LOTTERY = _minRoundDuration; MAX_LENGTH_LOTTERY = _maxRoundDuration; } /** * @notice Set max number of tickets * @dev Only callable by owner */ function setMaxNumberTicketsPerBuy(uint256 _maxNumberTicketsPerBuy) external onlyOwner { require(_maxNumberTicketsPerBuy != 0, "Must be > 0"); maxNumberTicketsPerBuyOrClaim = _maxNumberTicketsPerBuy; } /** * @notice Set operator, treasury, and injector addresses * @dev Only callable by owner * @param _operatorAddress: address of the operator * @param _treasuryAddress: address of the treasury * @param _injectorAddress: address of the injector */ function setOperatorAndTreasuryAndInjectorAddresses( address _operatorAddress, address _treasuryAddress, address _injectorAddress ) external onlyOwner { require(_operatorAddress != address(0), "Cannot be zero address"); require(_treasuryAddress != address(0), "Cannot be zero address"); require(_injectorAddress != address(0), "Cannot be zero address"); operatorAddress = _operatorAddress; treasuryAddress = _treasuryAddress; injectorAddress = _injectorAddress; emit NewOperatorAndTreasuryAndInjectorAddresses(_operatorAddress, _treasuryAddress, _injectorAddress); } /** * @notice Calculate price of a set of tickets * @param _discountDivisor: divisor for the discount * @param _priceTicket price of a ticket (in SOY) * @param _numberTickets number of tickets to buy */ function calculateTotalPriceForBulkTickets( uint256 _discountDivisor, uint256 _priceTicket, uint256 _numberTickets ) external pure returns (uint256) { require(_discountDivisor >= MIN_DISCOUNT_DIVISOR, "Must be >= MIN_DISCOUNT_DIVISOR"); require(_numberTickets != 0, "Number of tickets must be > 0"); return _calculateTotalPriceForBulkTickets(_discountDivisor, _priceTicket, _numberTickets); } /** * @notice View current lottery id */ function viewCurrentLotteryId() external view override returns (uint256) { return currentLotteryId; } /** * @notice View lottery information * @param _lotteryId: lottery id */ function viewLottery(uint256 _lotteryId) external view returns (Lottery memory) { return _lotteries[_lotteryId]; } /** * @notice View ticker statuses and numbers for an array of ticket ids * @param _ticketIds: array of _ticketId */ function viewNumbersAndStatusesForTicketIds(uint256[] calldata _ticketIds) external view returns (uint32[] memory, bool[] memory) { uint256 length = _ticketIds.length; uint32[] memory ticketNumbers = new uint32[](length); bool[] memory ticketStatuses = new bool[](length); for (uint256 i = 0; i < length; i++) { ticketNumbers[i] = _tickets[_ticketIds[i]].number; if (_tickets[_ticketIds[i]].owner == address(0)) { ticketStatuses[i] = true; } else { ticketStatuses[i] = false; } } return (ticketNumbers, ticketStatuses); } /** * @notice View rewards for a given ticket, providing a bracket, and lottery id * @dev Computations are mostly offchain. This is used to verify a ticket! * @param _lotteryId: lottery id * @param _ticketId: ticket id * @param _bracket: bracket for the ticketId to verify the claim and calculate rewards */ function viewRewardsForTicketId( uint256 _lotteryId, uint256 _ticketId, uint32 _bracket ) external view returns (uint256) { // Check lottery is in claimable status if (_lotteries[_lotteryId].status != Status.Claimable) { return 0; } // Check ticketId is within range if ( (_lotteries[_lotteryId].firstTicketIdNextLottery < _ticketId) && (_lotteries[_lotteryId].firstTicketId >= _ticketId) ) { return 0; } return _calculateRewardsForTicketId(_lotteryId, _ticketId, _bracket); } /** * @notice View user ticket ids, numbers, and statuses of user for a given lottery * @param _user: user address * @param _lotteryId: lottery id * @param _cursor: cursor to start where to retrieve the tickets * @param _size: the number of tickets to retrieve */ function viewUserInfoForLotteryId( address _user, uint256 _lotteryId, uint256 _cursor, uint256 _size ) external view returns ( uint256[] memory, uint32[] memory, bool[] memory, uint256 ) { uint256 length = _size; uint256 numberTicketsBoughtAtLotteryId = _userTicketIdsPerLotteryId[_user][_lotteryId].length; if (length > (numberTicketsBoughtAtLotteryId - _cursor)) { length = numberTicketsBoughtAtLotteryId - _cursor; } uint256[] memory lotteryTicketIds = new uint256[](length); uint32[] memory ticketNumbers = new uint32[](length); bool[] memory ticketStatuses = new bool[](length); for (uint256 i = 0; i < length; i++) { lotteryTicketIds[i] = _userTicketIdsPerLotteryId[_user][_lotteryId][i + _cursor]; ticketNumbers[i] = _tickets[lotteryTicketIds[i]].number; // True = ticket claimed if (_tickets[lotteryTicketIds[i]].owner == address(0)) { ticketStatuses[i] = true; } else { // ticket not claimed (includes the ones that cannot be claimed) ticketStatuses[i] = false; } } return (lotteryTicketIds, ticketNumbers, ticketStatuses, _cursor + length); } /** * @notice Calculate rewards for a given ticket * @param _lotteryId: lottery id * @param _ticketId: ticket id * @param _bracket: bracket for the ticketId to verify the claim and calculate rewards */ function _calculateRewardsForTicketId( uint256 _lotteryId, uint256 _ticketId, uint32 _bracket ) internal view returns (uint256) { // Retrieve the winning number combination uint32 userNumber = _lotteries[_lotteryId].finalNumber; // Retrieve the user number combination from the ticketId uint32 winningTicketNumber = _tickets[_ticketId].number; // Apply transformation to verify the claim provided by the user is true uint32 transformedWinningNumber = _bracketCalculator[_bracket] + (winningTicketNumber % (uint32(10)**(_bracket + 1))); uint32 transformedUserNumber = _bracketCalculator[_bracket] + (userNumber % (uint32(10)**(_bracket + 1))); // Confirm that the two transformed numbers are the same, if not throw if (transformedWinningNumber == transformedUserNumber) { return _lotteries[_lotteryId].soyPerBracket[_bracket]; } else { return 0; } } /** * @notice Calculate final price for bulk of tickets * @param _discountDivisor: divisor for the discount (the smaller it is, the greater the discount is) * @param _priceTicket: price of a ticket * @param _numberTickets: number of tickets purchased */ function _calculateTotalPriceForBulkTickets( uint256 _discountDivisor, uint256 _priceTicket, uint256 _numberTickets ) internal pure returns (uint256) { return (_priceTicket * _numberTickets * (_discountDivisor + 1 - _numberTickets)) / _discountDivisor; } /** * @notice Check if an address is a contract */ function _isContract(address _addr) internal view returns (bool) { uint256 size; assembly { size := extcodesize(_addr) } return size > 0; } }
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_soyTokenAddress","internalType":"address"},{"type":"address","name":"_randomGeneratorAddress","internalType":"address"}]},{"type":"event","name":"AdminTokenRecovery","inputs":[{"type":"address","name":"token","internalType":"address","indexed":false},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"LotteryClose","inputs":[{"type":"uint256","name":"lotteryId","internalType":"uint256","indexed":true},{"type":"uint256","name":"firstTicketIdNextLottery","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"LotteryInjection","inputs":[{"type":"uint256","name":"lotteryId","internalType":"uint256","indexed":true},{"type":"uint256","name":"injectedAmount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"LotteryNumberDrawn","inputs":[{"type":"uint256","name":"lotteryId","internalType":"uint256","indexed":true},{"type":"uint256","name":"finalNumber","internalType":"uint256","indexed":false},{"type":"uint256","name":"countWinningTickets","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"LotteryOpen","inputs":[{"type":"uint256","name":"lotteryId","internalType":"uint256","indexed":true},{"type":"uint256","name":"startTime","internalType":"uint256","indexed":false},{"type":"uint256","name":"endTime","internalType":"uint256","indexed":false},{"type":"uint256","name":"priceTicketInSoy","internalType":"uint256","indexed":false},{"type":"uint256","name":"firstTicketId","internalType":"uint256","indexed":false},{"type":"uint256","name":"injectedAmount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"NewOperatorAndTreasuryAndInjectorAddresses","inputs":[{"type":"address","name":"operator","internalType":"address","indexed":false},{"type":"address","name":"treasury","internalType":"address","indexed":false},{"type":"address","name":"injector","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"NewRandomGenerator","inputs":[{"type":"address","name":"randomGenerator","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"TicketsClaim","inputs":[{"type":"address","name":"claimer","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false},{"type":"uint256","name":"lotteryId","internalType":"uint256","indexed":true},{"type":"uint256","name":"numberTickets","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"TicketsPurchase","inputs":[{"type":"address","name":"buyer","internalType":"address","indexed":true},{"type":"uint256","name":"lotteryId","internalType":"uint256","indexed":true},{"type":"uint256","name":"numberTickets","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"MAX_LENGTH_LOTTERY","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"MAX_TREASURY_FEE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"MIN_DISCOUNT_DIVISOR","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"MIN_LENGTH_LOTTERY","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"buyTickets","inputs":[{"type":"uint256","name":"_lotteryId","internalType":"uint256"},{"type":"uint32[]","name":"_ticketNumbers","internalType":"uint32[]"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"calculateTotalPriceForBulkTickets","inputs":[{"type":"uint256","name":"_discountDivisor","internalType":"uint256"},{"type":"uint256","name":"_priceTicket","internalType":"uint256"},{"type":"uint256","name":"_numberTickets","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"changeRandomGenerator","inputs":[{"type":"address","name":"_randomGeneratorAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"claimTickets","inputs":[{"type":"uint256","name":"_lotteryId","internalType":"uint256"},{"type":"uint256[]","name":"_ticketIds","internalType":"uint256[]"},{"type":"uint32[]","name":"_brackets","internalType":"uint32[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"closeLottery","inputs":[{"type":"uint256","name":"_lotteryId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"currentLotteryId","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"currentTicketId","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"drawFinalNumberAndMakeLotteryClaimable","inputs":[{"type":"uint256","name":"_lotteryId","internalType":"uint256"},{"type":"bool","name":"_autoInjection","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"injectFunds","inputs":[{"type":"uint256","name":"_lotteryId","internalType":"uint256"},{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"injectorAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"maxNumberTicketsPerBuyOrClaim","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"maxPriceTicketInSoy","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"minPriceTicketInSoy","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"operatorAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"pendingInjectionNextLottery","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IRandomNumberGenerator"}],"name":"randomGenerator","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"recoverWrongTokens","inputs":[{"type":"address","name":"_tokenAddress","internalType":"address"},{"type":"uint256","name":"_tokenAmount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMaxNumberTicketsPerBuy","inputs":[{"type":"uint256","name":"_maxNumberTicketsPerBuy","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMinAndMaxRoundDuration","inputs":[{"type":"uint256","name":"_minRoundDuration","internalType":"uint256"},{"type":"uint256","name":"_maxRoundDuration","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMinAndMaxTicketPriceInSoy","inputs":[{"type":"uint256","name":"_minPriceTicketInSoy","internalType":"uint256"},{"type":"uint256","name":"_maxPriceTicketInSoy","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setOperatorAndTreasuryAndInjectorAddresses","inputs":[{"type":"address","name":"_operatorAddress","internalType":"address"},{"type":"address","name":"_treasuryAddress","internalType":"address"},{"type":"address","name":"_injectorAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IERC20"}],"name":"soyToken","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"startLottery","inputs":[{"type":"uint256","name":"_endTime","internalType":"uint256"},{"type":"uint256","name":"_priceTicketInSoy","internalType":"uint256"},{"type":"uint256","name":"_discountDivisor","internalType":"uint256"},{"type":"uint256[6]","name":"_rewardsBreakdown","internalType":"uint256[6]"},{"type":"uint256","name":"_treasuryFee","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"treasuryAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"viewCurrentLotteryId","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"","internalType":"struct SoyLottery.Lottery","components":[{"type":"uint8","name":"status","internalType":"enum SoyLottery.Status"},{"type":"uint256","name":"startTime","internalType":"uint256"},{"type":"uint256","name":"endTime","internalType":"uint256"},{"type":"uint256","name":"priceTicketInSoy","internalType":"uint256"},{"type":"uint256","name":"discountDivisor","internalType":"uint256"},{"type":"uint256[6]","name":"rewardsBreakdown","internalType":"uint256[6]"},{"type":"uint256","name":"treasuryFee","internalType":"uint256"},{"type":"uint256[6]","name":"soyPerBracket","internalType":"uint256[6]"},{"type":"uint256[6]","name":"countWinnersPerBracket","internalType":"uint256[6]"},{"type":"uint256","name":"firstTicketId","internalType":"uint256"},{"type":"uint256","name":"firstTicketIdNextLottery","internalType":"uint256"},{"type":"uint256","name":"amountCollectedInSoy","internalType":"uint256"},{"type":"uint32","name":"finalNumber","internalType":"uint32"}]}],"name":"viewLottery","inputs":[{"type":"uint256","name":"_lotteryId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint32[]","name":"","internalType":"uint32[]"},{"type":"bool[]","name":"","internalType":"bool[]"}],"name":"viewNumbersAndStatusesForTicketIds","inputs":[{"type":"uint256[]","name":"_ticketIds","internalType":"uint256[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"viewRewardsForTicketId","inputs":[{"type":"uint256","name":"_lotteryId","internalType":"uint256"},{"type":"uint256","name":"_ticketId","internalType":"uint256"},{"type":"uint32","name":"_bracket","internalType":"uint32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256[]","name":"","internalType":"uint256[]"},{"type":"uint32[]","name":"","internalType":"uint32[]"},{"type":"bool[]","name":"","internalType":"bool[]"},{"type":"uint256","name":"","internalType":"uint256"}],"name":"viewUserInfoForLotteryId","inputs":[{"type":"address","name":"_user","internalType":"address"},{"type":"uint256","name":"_lotteryId","internalType":"uint256"},{"type":"uint256","name":"_cursor","internalType":"uint256"},{"type":"uint256","name":"_size","internalType":"uint256"}]}]
Contract Creation Code
0x608060405260646007556802b5e3af16b18800006008556611c37937e0800060095562011814600b55620a8d2c600c553480156200003c57600080fd5b5060405162003bd638038062003bd68339810160408190526200005f9162000207565b6001600081815581546001600160a01b031916339081179092556040518291907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350600d80546001600160a01b039384166001600160a01b031991821617909155600e805492909316911617905560116020527f4ad3b33220dddc71b994a52d72c06b10862965f7d926534c05c00fb7e819e7b7805463ffffffff199081166001179091557f17bc176d2408558f6e4111feebc3cab4e16b63e967be91cde721f4c8a488b55280548216600b1790557f08037d7b151cc412d25674a4e66b334d9ae9d2e5517a7feaae5cdb828bf1c62880548216606f1790557f9bfbaa59f8e10e7868f8b402de9d605a390c45ddaebd8c9de3c6f31e733c87ff805482166104571790557f251164fe1d8864fe5e86082eae9c288bc2b58695a4d28538dfe86e9e4f17558580548216612b6717905560056000527fc550213cee30afd5e67ccba7be3d381bbc169034ae08eb3ec9168caca9fe55e780549091166201b2071790556200023f565b80516001600160a01b03811681146200020257600080fd5b919050565b600080604083850312156200021b57600080fd5b6200022683620001ea565b91506200023660208401620001ea565b90509250929050565b613987806200024f6000396000f3fe608060405234801561001057600080fd5b506004361061021c5760003560e01c80638bb8458411610125578063c4937ab9116100ad578063da4ca0391161007c578063da4ca03914610462578063db19da0d14610475578063dcbad90d1461047e578063f2b3c80914610491578063f2fde38b1461049a57600080fd5b8063c4937ab914610420578063c5f956af14610433578063c914914f14610446578063ca9d740f1461045957600080fd5b80639c384653116100f45780639c384653146103c15780639d8ca531146103d4578063adb4aee8146103e7578063b1829b82146103fa578063c38de5391461040d57600080fd5b80638bb84584146103695780638da5cb5b1461037c5780638fc3539a1461038d57806398359fa1146103ae57600080fd5b8063456d66e3116101a85780636be4097c116101775780636be4097c14610334578063715018a61461033d5780637cb583bd1461034557806380a061601461034e57806388303dbd1461035657600080fd5b8063456d66e3146102f2578063471aeab414610305578063686465b8146103185780636b8737881461032157600080fd5b80631fe86c6b116101ef5780631fe86c6b146102985780632423807a146102a15780632d3eb68e146102c15780632e530cae146102ca5780633f138d4b146102dd57600080fd5b806305531eeb1461022157806307fb5a9c1461024d578063127effb21461026457806312a9769d1461028f575b600080fd5b61023461022f366004613055565b6104ad565b60405161024494939291906133f9565b60405180910390f35b610256600b5481565b604051908152602001610244565b600354610277906001600160a01b031681565b6040516001600160a01b039091168152602001610244565b610256600a5481565b61025660075481565b6102b46102af3660046130ed565b610799565b6040516102449190613590565b61025660095481565b6102566102d83660046132b2565b6108fa565b6102f06102eb36600461302b565b610981565b005b6102f0610300366004613215565b610a62565b6102f0610313366004613215565b610ada565b61025660065481565b6102f061032f3660046130ed565b610c1d565b61025660055481565b6102f0610c87565b61025661012c81565b600554610256565b6102f0610364366004613199565b610cfb565b600d54610277906001600160a01b031681565b6001546001600160a01b0316610277565b6103a061039b36600461308e565b6111cb565b60405161024492919061346d565b6102f06103bc366004612fcd565b611385565b600254610277906001600160a01b031681565b6102f06103e23660046130ed565b611573565b6102f06103f5366004613215565b61177b565b6102f0610408366004613263565b611800565b6102f061041b3660046131e5565b611ce9565b61025661042e366004613237565b61228b565b600454610277906001600160a01b031681565b6102f061045436600461311f565b612337565b61025660085481565b6102f0610470366004612fe8565b6128aa565b610256600c5481565b600e54610277906001600160a01b031681565b610256610bb881565b6102f06104a8366004612fcd565b6129ca565b6001600160a01b0384166000908152601360209081526040808320868452909152812054606091829182919085906104e588826137f6565b8211156104f9576104f688826137f6565b91505b60008267ffffffffffffffff81111561051457610514613918565b60405190808252806020026020018201604052801561053d578160200160208202803683370190505b50905060008367ffffffffffffffff81111561055b5761055b613918565b604051908082528060200260200182016040528015610584578160200160208202803683370190505b50905060008467ffffffffffffffff8111156105a2576105a2613918565b6040519080825280602002602001820160405280156105cb578160200160208202803683370190505b50905060005b8581101561077357601360008f6001600160a01b03166001600160a01b0316815260200190815260200160002060008e81526020019081526020016000208c8261061b9190613653565b8154811061062b5761062b613902565b906000526020600020015484828151811061064857610648613902565b6020026020010181815250506010600085838151811061066a5761066a613902565b6020026020010151815260200190815260200160002060000160009054906101000a900463ffffffff168382815181106106a6576106a6613902565b602002602001019063ffffffff16908163ffffffff168152505060006001600160a01b0316601060008684815181106106e1576106e1613902565b60209081029190910181015182528101919091526040016000205464010000000090046001600160a01b0316141561073c57600182828151811061072757610727613902565b91151560209283029190910190910152610761565b600082828151811061075057610750613902565b911515602092830291909101909101525b8061076b8161385e565b9150506105d1565b50828282610781888f613653565b98509850985098505050505050945094509450949050565b6107a1612e7a565b6000828152600f60205260409081902081516101a081019092528054829060ff1660038111156107d3576107d36138ec565b60038111156107e4576107e46138ec565b81526001820154602082015260028201546040808301919091526003830154606083015260048301546080830152805160c081019182905260a09092019190600584019060069082845b81548152602001906001019080831161082e575050509183525050600b82015460208201526040805160c081018252910190600c830160068282826020028201915b8154815260200190600101908083116108705750505091835250506040805160c081019182905260209092019190601284019060069082845b8154815260200190600101908083116108a95750505091835250506018820154602082015260198201546040820152601a8201546060820152601b9091015463ffffffff1660809091015292915050565b600060036000858152600f602052604090205460ff166003811115610921576109216138ec565b1461092e5750600061097a565b6000848152600f60205260409020601901548311801561095f57506000848152600f60205260409020601801548311155b1561096c5750600061097a565b610977848484612ab5565b90505b9392505050565b6001546001600160a01b031633146109b45760405162461bcd60e51b81526004016109ab906134fe565b60405180910390fd5b600d546001600160a01b0383811691161415610a085760405162461bcd60e51b815260206004820152601360248201527221b0b73737ba1031329029a7ac903a37b5b2b760691b60448201526064016109ab565b610a1c6001600160a01b0383163383612bc0565b604080516001600160a01b0384168152602081018390527f74545154aac348a3eac92596bd1971957ca94795f4e954ec5f613b55fab78129910160405180910390a15050565b6001546001600160a01b03163314610a8c5760405162461bcd60e51b81526004016109ab906134fe565b808210610acf5760405162461bcd60e51b81526020600482015260116024820152700dad2dc40daeae6e840c4ca407840dac2f607b1b60448201526064016109ab565b600b91909155600c55565b6001546001600160a01b0316331480610afd57506002546001600160a01b031633145b610b415760405162461bcd60e51b81526020600482015260156024820152742737ba1037bbb732b91037b91034b73532b1ba37b960591b60448201526064016109ab565b60016000838152600f602052604090205460ff166003811115610b6657610b666138ec565b14610ba65760405162461bcd60e51b815260206004820152601060248201526f2637ba3a32b93c903737ba1037b832b760811b60448201526064016109ab565b600d54610bbe906001600160a01b0316333084612c28565b6000828152600f60205260408120601a018054839290610bdf908490613653565b909155505060405181815282907f1bbd659dd628a25f7ff2eabb69c74a56939c539728282275c1c9c1a2d3e340499060200160405180910390a25050565b6001546001600160a01b03163314610c475760405162461bcd60e51b81526004016109ab906134fe565b80610c825760405162461bcd60e51b815260206004820152600b60248201526a04d757374206265203e20360ac1b60448201526064016109ab565b600755565b6001546001600160a01b03163314610cb15760405162461bcd60e51b81526004016109ab906134fe565b6001546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600180546001600160a01b0319169055565b333b15610d415760405162461bcd60e51b815260206004820152601460248201527310dbdb9d1c9858dd081b9bdd08185b1b1bddd95960621b60448201526064016109ab565b333214610d905760405162461bcd60e51b815260206004820152601a60248201527f50726f787920636f6e7472616374206e6f7420616c6c6f77656400000000000060448201526064016109ab565b60026000541415610db35760405162461bcd60e51b81526004016109ab90613533565b600260005580610dfb5760405162461bcd60e51b8152602060048201526013602482015272139bc81d1a58dad95d081cdc1958da599a5959606a1b60448201526064016109ab565b600754811115610e405760405162461bcd60e51b815260206004820152601060248201526f546f6f206d616e79207469636b65747360801b60448201526064016109ab565b60016000848152600f602052604090205460ff166003811115610e6557610e656138ec565b14610ea85760405162461bcd60e51b81526020600482015260136024820152722637ba3a32b93c9034b9903737ba1037b832b760691b60448201526064016109ab565b6000838152600f60205260409020600201544210610efa5760405162461bcd60e51b815260206004820152600f60248201526e2637ba3a32b93c9034b99037bb32b960891b60448201526064016109ab565b6000838152600f602052604081206004810154600390910154610f1e919084612c66565b600d54909150610f39906001600160a01b0316333084612c28565b6000848152600f60205260408120601a018054839290610f5a908490613653565b90915550600090505b82811015611188576000848483818110610f7f57610f7f613902565b9050602002016020810190610f9491906132eb565b90506103e88163ffffffff1610158015610fb657506107cf8163ffffffff1611155b610ff25760405162461bcd60e51b815260206004820152600d60248201526c4f7574736964652072616e676560981b60448201526064016109ab565b60008681526012602052604081209061100c600a8461389d565b61101790600161366b565b63ffffffff1681526020810191909152604001600090812080549161103b8361385e565b909155505060008681526012602052604081209061105a60648461389d565b61106590600b61366b565b63ffffffff168152602081019190915260400160009081208054916110898361385e565b90915550506000868152601260205260408120906110a96103e88461389d565b6110b490606f61366b565b63ffffffff168152602081019190915260400160009081208054916110d88361385e565b90915550503360008181526013602090815260408083208a84528252808320600680548254600181018455928652848620909201919091558151808301835263ffffffff80881682528185019687528254865260109094529184209151825495516001600160a01b0316640100000000026001600160c01b0319909616931692909217939093179092558154919061116f8361385e565b91905055505080806111809061385e565b915050610f63565b50604051828152849033907fd7d247b583de1023852eef87b48f54354dbec771d01bc2cc49e96094efc322b99060200160405180910390a3505060016000555050565b6060808260008167ffffffffffffffff8111156111ea576111ea613918565b604051908082528060200260200182016040528015611213578160200160208202803683370190505b50905060008267ffffffffffffffff81111561123157611231613918565b60405190808252806020026020018201604052801561125a578160200160208202803683370190505b50905060005b83811015611376576010600089898481811061127e5761127e613902565b90506020020135815260200190815260200160002060000160009054906101000a900463ffffffff168382815181106112b9576112b9613902565b63ffffffff9092166020928302919091019091015260006010818a8a858181106112e5576112e5613902565b602090810292909201358352508101919091526040016000205464010000000090046001600160a01b0316141561133f57600182828151811061132a5761132a613902565b91151560209283029190910190910152611364565b600082828151811061135357611353613902565b911515602092830291909101909101525b8061136e8161385e565b915050611260565b509093509150505b9250929050565b6001546001600160a01b031633146113af5760405162461bcd60e51b81526004016109ab906134fe565b60036005546000908152600f602052604090205460ff1660038111156113d7576113d76138ec565b146114245760405162461bcd60e51b815260206004820152601860248201527f4c6f7474657279206e6f7420696e20636c61696d61626c65000000000000000060448201526064016109ab565b806001600160a01b031663b37217a4600554600654604051602001611453929190918252602082015260400190565b60408051808303601f1901815290829052805160209091012060e083901b6001600160e01b03191682526004820152602401600060405180830381600087803b15801561149f57600080fd5b505af11580156114b3573d6000803e3d6000fd5b50505050806001600160a01b031663a1c4f55a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156114f057600080fd5b505afa158015611504573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115289190613308565b50600e80546001600160a01b0319166001600160a01b0383169081179091556040517f383f8cb39dfa7c3fb901a460dd449ea924868f0a92ff03da64740fffa5f1de6290600090a250565b6003546001600160a01b0316331461159d5760405162461bcd60e51b81526004016109ab9061356a565b600260005414156115c05760405162461bcd60e51b81526004016109ab90613533565b600260005560016000828152600f602052604090205460ff1660038111156115ea576115ea6138ec565b1461162a5760405162461bcd60e51b815260206004820152601060248201526f2637ba3a32b93c903737ba1037b832b760811b60448201526064016109ab565b6000818152600f6020526040902060020154421161167d5760405162461bcd60e51b815260206004820152601060248201526f2637ba3a32b93c903737ba1037bb32b960811b60448201526064016109ab565b6006546000828152600f6020908152604091829020601901839055600e548251918201859052918101929092526001600160a01b03169063b37217a49060600160408051808303601f1901815290829052805160209091012060e083901b6001600160e01b03191682526004820152602401600060405180830381600087803b15801561170957600080fd5b505af115801561171d573d6000803e3d6000fd5b5050506000828152600f6020908152604091829020805460ff1916600217905560065491519182528392507f3728e75294796694d59d2ffced9c394279baf7b9ebd2702db43f5f04bac67929910160405180910390a2506001600055565b6001546001600160a01b031633146117a55760405162461bcd60e51b81526004016109ab906134fe565b808211156117f55760405162461bcd60e51b815260206004820152601b60248201527f6d696e5072696365206d757374206265203c206d61785072696365000000000060448201526064016109ab565b600991909155600855565b6003546001600160a01b0316331461182a5760405162461bcd60e51b81526004016109ab9061356a565b600554158061185e575060036005546000908152600f602052604090205460ff16600381111561185c5761185c6138ec565b145b6118aa5760405162461bcd60e51b815260206004820152601960248201527f4e6f742074696d6520746f207374617274206c6f74746572790000000000000060448201526064016109ab565b600b546118b742876137f6565b1180156118ce5750600c546118cc42876137f6565b105b61191a5760405162461bcd60e51b815260206004820152601f60248201527f4c6f7474657279206c656e677468206f757473696465206f662072616e67650060448201526064016109ab565b600954841015801561192e57506008548411155b61196e5760405162461bcd60e51b81526020600482015260116024820152704f757473696465206f66206c696d69747360781b60448201526064016109ab565b61012c8310156119c05760405162461bcd60e51b815260206004820152601860248201527f446973636f756e742064697669736f7220746f6f206c6f77000000000000000060448201526064016109ab565b610bb8811115611a0a5760405162461bcd60e51b81526020600482015260156024820152740a8e4cac2e6eae4f240cccaca40e8dede40d0d2ced605b1b60448201526064016109ab565b60a0820135608083013560608401356040850135611a2d60208701358735613653565b611a379190613653565b611a419190613653565b611a4b9190613653565b611a559190613653565b61271014611aa55760405162461bcd60e51b815260206004820152601860248201527f52657761726473206d75737420657175616c203130303030000000000000000060448201526064016109ab565b60058054906000611ab58361385e565b9091555050604080516101a0810190915280600181526020014281526020018681526020018581526020018481526020018360068060200260405190810160405280929190826006602002808284376000920182905250928452505060208083018590526040805160c080820183528482528184018590528183018590526060808301869052608080840187905260a080850188905285890194909452845180840186528781528087018890528086018890528083018890528082018890528085018890529188019190915260065490870181905291860191909152600a549085015260e09093018290526005548252600f90522081518154829060ff19166001836003811115611bc857611bc86138ec565b02179055506020820151600182015560408201516002820155606082015160038201556080820151600482015560a0820151611c0a9060058301906006612efb565b5060c0820151600b82015560e0820151611c2a90600c8301906006612efb565b50610100820151611c419060128301906006612efb565b5061012082015160188201556101408201516019820155610160820151601a82015561018090910151601b909101805463ffffffff191663ffffffff909216919091179055600554600654600a5460408051428152602081018a9052908101889052606081019290925260808201527f367e70f8c0e0c0a6504d92172bda155c02022d532fc85b5d66a9c49e31c8bc779060a00160405180910390a250506000600a55505050565b6003546001600160a01b03163314611d135760405162461bcd60e51b81526004016109ab9061356a565b60026000541415611d365760405162461bcd60e51b81526004016109ab90613533565b60026000818155838152600f602052604090205460ff166003811115611d5e57611d5e6138ec565b14611d9f5760405162461bcd60e51b81526020600482015260116024820152704c6f7474657279206e6f7420636c6f736560781b60448201526064016109ab565b600e60009054906101000a90046001600160a01b03166001600160a01b031663fbe5d9176040518163ffffffff1660e01b815260040160206040518083038186803b158015611ded57600080fd5b505afa158015611e01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e259190613106565b8214611e675760405162461bcd60e51b8152602060048201526011602482015270273ab6b132b939903737ba10323930bbb760791b60448201526064016109ab565b600e54604080516350e27aad60e11b815290516000926001600160a01b03169163a1c4f55a916004808301926020929190829003018186803b158015611eac57600080fd5b505afa158015611ec0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ee49190613308565b6000848152600f60205260408120600b015491925090819061271090611f0a90826137f6565b6000878152600f60205260409020601a0154611f2691906137d7565b611f309190613693565b90506000805b60038163ffffffff1610156121b657600081611f54600160036137f6565b611f5e919061380d565b90506000611f6d82600161366b565b611f7890600a6136ec565b611f82908861389d565b63ffffffff808416600090815260116020526040902054611fa492911661366b565b60008a815260126020908152604080832063ffffffff85168452909152902054909150611fd29087906137f6565b60008a8152600f6020526040902060120163ffffffff841660068110611ffa57611ffa613902565b0155600089815260126020908152604080832063ffffffff851684529091529020546120279087906137f6565b15612126576000898152600f6020526040902060050163ffffffff83166006811061205457612054613902565b01541561212157600089815260126020908152604080832063ffffffff851684529091529020546127109061208a9088906137f6565b60008b8152600f60205260409020879060050163ffffffff8616600681106120b4576120b4613902565b01546120c091906137d7565b6120ca9190613693565b6120d49190613693565b60008a8152600f60205260409020600c0163ffffffff8416600681106120fc576120fc613902565b0155600089815260126020908152604080832063ffffffff8516845290915290205495505b6121a1565b6000898152600f60205260408120600c0163ffffffff84166006811061214e5761214e613902565b01556000898152600f6020526040902061271090869060050163ffffffff85166006811061217e5761217e613902565b015461218a91906137d7565b6121949190613693565b61219e9085613653565b93505b505080806121ae90613879565b915050611f36565b506000868152600f60205260409020601b8101805463ffffffff871663ffffffff19909116179055805460ff1916600317905584156121f557600a5560005b6000868152600f60205260409020601a01546122129083906137f6565b61221c9082613653565b600454600d5491925061223c916001600160a01b03908116911683612bc0565b6005546040805163ffffffff87168152602081018690527f98e31a6607b8b15b4d5b91de54f4c09ffe4c4cf162aa532c70b5213754e2e703910160405180910390a25050600160005550505050565b600061012c8410156122df5760405162461bcd60e51b815260206004820152601f60248201527f4d757374206265203e3d204d494e5f444953434f554e545f44495649534f520060448201526064016109ab565b8161232c5760405162461bcd60e51b815260206004820152601d60248201527f4e756d626572206f66207469636b657473206d757374206265203e203000000060448201526064016109ab565b610977848484612c66565b333b1561237d5760405162461bcd60e51b815260206004820152601460248201527310dbdb9d1c9858dd081b9bdd08185b1b1bddd95960621b60448201526064016109ab565b3332146123cc5760405162461bcd60e51b815260206004820152601a60248201527f50726f787920636f6e7472616374206e6f7420616c6c6f77656400000000000060448201526064016109ab565b600260005414156123ef5760405162461bcd60e51b81526004016109ab90613533565b60026000558281146124355760405162461bcd60e51b815260206004820152600f60248201526e09cdee840e6c2daca40d8cadccee8d608b1b60448201526064016109ab565b826124765760405162461bcd60e51b815260206004820152601160248201527004c656e677468206d757374206265203e3607c1b60448201526064016109ab565b6007548311156124bb5760405162461bcd60e51b815260206004820152601060248201526f546f6f206d616e79207469636b65747360801b60448201526064016109ab565b60036000868152600f602052604090205460ff1660038111156124e0576124e06138ec565b146125255760405162461bcd60e51b81526020600482015260156024820152744c6f7474657279206e6f7420636c61696d61626c6560581b60448201526064016109ab565b6000805b8481101561284857600384848381811061254557612545613902565b905060200201602081019061255a91906132eb565b63ffffffff16106125a45760405162461bcd60e51b8152602060048201526014602482015273427261636b6574206f7574206f662072616e676560601b60448201526064016109ab565b60008686838181106125b8576125b8613902565b90506020020135905080600f60008a8152602001908152602001600020601901541161261a5760405162461bcd60e51b81526020600482015260116024820152700a8d2c6d6cae892c840e8dede40d0d2ced607b1b60448201526064016109ab565b6000888152600f602052604090206018015481101561266e5760405162461bcd60e51b815260206004820152601060248201526f5469636b6574496420746f6f206c6f7760801b60448201526064016109ab565b60008181526010602052604090205464010000000090046001600160a01b031633146126cc5760405162461bcd60e51b815260206004820152600d60248201526c2737ba103a34329037bbb732b960991b60448201526064016109ab565b60008181526010602052604081208054640100000000600160c01b031916905561271d898388888781811061270357612703613902565b905060200201602081019061271891906132eb565b612ab5565b90508061276c5760405162461bcd60e51b815260206004820152601960248201527f4e6f207072697a6520666f72207468697320627261636b65740000000000000060448201526064016109ab565b612778600160036137f6565b86868581811061278a5761278a613902565b905060200201602081019061279f91906132eb565b63ffffffff1614612827576127e189838888878181106127c1576127c1613902565b90506020020160208101906127d691906132eb565b61271890600161366b565b156128275760405162461bcd60e51b8152602060048201526016602482015275213930b1b5b2ba1036bab9ba103132903434b3b432b960511b60448201526064016109ab565b6128318185613653565b9350505080806128409061385e565b915050612529565b50600d54612860906001600160a01b03163383612bc0565b6040805182815260208101869052879133917f0f5fca62da8fb5d95525b49e5eaa7b20bc6bd9e2f6b64b493442d1c0bd6ef486910160405180910390a35050600160005550505050565b6001546001600160a01b031633146128d45760405162461bcd60e51b81526004016109ab906134fe565b6001600160a01b0383166128fa5760405162461bcd60e51b81526004016109ab906134ce565b6001600160a01b0382166129205760405162461bcd60e51b81526004016109ab906134ce565b6001600160a01b0381166129465760405162461bcd60e51b81526004016109ab906134ce565b600380546001600160a01b038581166001600160a01b0319928316811790935560048054868316908416811790915560028054928616929093168217909255604080519384526020840192909252908201527f3e945b7660001d46cfd5e729545f7f0b6c65bdee54066a91c7acad703f1b731e9060600160405180910390a1505050565b6001546001600160a01b031633146129f45760405162461bcd60e51b81526004016109ab906134fe565b6001600160a01b038116612a595760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016109ab565b6001546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600180546001600160a01b0319166001600160a01b0392909216919091179055565b6000838152600f60209081526040808320601b0154858452601090925282205463ffffffff918216911682612aeb85600161366b565b612af690600a6136ec565b612b00908361389d565b63ffffffff808716600090815260116020526040902054612b2292911661366b565b90506000612b3186600161366b565b612b3c90600a6136ec565b612b46908561389d565b63ffffffff808816600090815260116020526040902054612b6892911661366b565b90508063ffffffff168263ffffffff161415612bb3576000888152600f60205260409020600c0163ffffffff871660068110612ba657612ba6613902565b015494505050505061097a565b600094505050505061097a565b6040516001600160a01b038316602482015260448101829052612c2390849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612c9d565b505050565b6040516001600160a01b0380851660248301528316604482015260648101829052612c609085906323b872dd60e01b90608401612bec565b50505050565b60008382612c75826001613653565b612c7f91906137f6565b612c8984866137d7565b612c9391906137d7565b6109779190613693565b6000612cf2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612d6f9092919063ffffffff16565b805190915015612c235780806020019051810190612d1091906130d0565b612c235760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016109ab565b6060610977848460008585843b612dc85760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016109ab565b600080866001600160a01b03168587604051612de491906133dd565b60006040518083038185875af1925050503d8060008114612e21576040519150601f19603f3d011682016040523d82523d6000602084013e612e26565b606091505b5091509150612e36828286612e41565b979650505050505050565b60608315612e5057508161097a565b825115612e605782518084602001fd5b8160405162461bcd60e51b81526004016109ab919061349b565b604080516101a08101909152806000815260200160008152602001600081526020016000815260200160008152602001612eb2612f39565b815260200160008152602001612ec6612f39565b8152602001612ed3612f39565b8152602001600081526020016000815260200160008152602001600063ffffffff1681525090565b8260068101928215612f29579160200282015b82811115612f29578251825591602001919060010190612f0e565b50612f35929150612f57565b5090565b6040518060c001604052806006906020820280368337509192915050565b5b80821115612f355760008155600101612f58565b80356001600160a01b0381168114612f8357600080fd5b919050565b60008083601f840112612f9a57600080fd5b50813567ffffffffffffffff811115612fb257600080fd5b6020830191508360208260051b850101111561137e57600080fd5b600060208284031215612fdf57600080fd5b61097a82612f6c565b600080600060608486031215612ffd57600080fd5b61300684612f6c565b925061301460208501612f6c565b915061302260408501612f6c565b90509250925092565b6000806040838503121561303e57600080fd5b61304783612f6c565b946020939093013593505050565b6000806000806080858703121561306b57600080fd5b61307485612f6c565b966020860135965060408601359560600135945092505050565b600080602083850312156130a157600080fd5b823567ffffffffffffffff8111156130b857600080fd5b6130c485828601612f88565b90969095509350505050565b6000602082840312156130e257600080fd5b815161097a8161392e565b6000602082840312156130ff57600080fd5b5035919050565b60006020828403121561311857600080fd5b5051919050565b60008060008060006060868803121561313757600080fd5b85359450602086013567ffffffffffffffff8082111561315657600080fd5b61316289838a01612f88565b9096509450604088013591508082111561317b57600080fd5b5061318888828901612f88565b969995985093965092949392505050565b6000806000604084860312156131ae57600080fd5b83359250602084013567ffffffffffffffff8111156131cc57600080fd5b6131d886828701612f88565b9497909650939450505050565b600080604083850312156131f857600080fd5b82359150602083013561320a8161392e565b809150509250929050565b6000806040838503121561322857600080fd5b50508035926020909101359150565b60008060006060848603121561324c57600080fd5b505081359360208301359350604090920135919050565b6000806000806000610140868803121561327c57600080fd5b8535945060208601359350604086013592506101208601878111156132a057600080fd5b94979396509194606001933592915050565b6000806000606084860312156132c757600080fd5b833592506020840135915060408401356132e08161393f565b809150509250925092565b6000602082840312156132fd57600080fd5b813561097a8161393f565b60006020828403121561331a57600080fd5b815161097a8161393f565b600081518084526020808501945080840160005b83811015613357578151151587529582019590820190600101613339565b509495945050505050565b8060005b6006811015612c60578151845260209384019390910190600101613366565b600081518084526020808501945080840160005b8381101561335757815163ffffffff1687529582019590820190600101613399565b600481106133d957634e487b7160e01b600052602160045260246000fd5b9052565b600082516133ef818460208701613832565b9190910192915050565b6080808252855190820181905260009060209060a0840190828901845b8281101561343257815184529284019290840190600101613416565b505050838103828501526134468188613385565b915050828103604084015261345b8186613325565b91505082606083015295945050505050565b6040815260006134806040830185613385565b82810360208401526134928185613325565b95945050505050565b60208152600082518060208401526134ba816040850160208701613832565b601f01601f19169190910160400192915050565b60208082526016908201527543616e6e6f74206265207a65726f206164647265737360501b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6020808252600c908201526b2737ba1037b832b930ba37b960a11b604082015260600190565b6000610380820190506135a48284516133bb565b6020830151602083015260408301516040830152606083015160608301526080830151608083015260a08301516135de60a0840182613362565b5060c0830151610160818185015260e0850151915061018061360281860184613362565b6101008601519250613618610240860184613362565b6101208601516103008601526101408601516103208601529085015161034085015284015163ffffffff811661036085015290505092915050565b60008219821115613666576136666138c0565b500190565b600063ffffffff80831681851680830382111561368a5761368a6138c0565b01949350505050565b6000826136a2576136a26138d6565b500490565b600181815b808511156136e4578163ffffffff048211156136ca576136ca6138c0565b808516156136d757918102915b93841c93908002906136ac565b509250929050565b600063ffffffff613701818516828516613709565b949350505050565b600082613718575060016137d1565b81613725575060006137d1565b816001811461373b576002811461374557613776565b60019150506137d1565b60ff841115613756576137566138c0565b6001841b915063ffffffff821115613770576137706138c0565b506137d1565b5060208310610133831016604e8410600b84101617156137ad575081810a63ffffffff8111156137a8576137a86138c0565b6137d1565b6137b783836136a7565b8063ffffffff048211156137cd576137cd6138c0565b0290505b92915050565b60008160001904831182151516156137f1576137f16138c0565b500290565b600082821015613808576138086138c0565b500390565b600063ffffffff8381169083168181101561382a5761382a6138c0565b039392505050565b60005b8381101561384d578181015183820152602001613835565b83811115612c605750506000910152565b6000600019821415613872576138726138c0565b5060010190565b600063ffffffff80831681811415613893576138936138c0565b6001019392505050565b600063ffffffff808416806138b4576138b46138d6565b92169190910692915050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b801515811461393c57600080fd5b50565b63ffffffff8116811461393c57600080fdfea2646970667358221220bf8a462212477d35e7c912e9bea1785cc770f168731753264a7a656a2126adb464736f6c634300080700330000000000000000000000009fae2529863bd691b4a7171bdfcf33c7ebb10a650000000000000000000000009bfa10ec7cbdfa029692c95e493f2fc1bdcb25af
Deployed ByteCode
0x608060405234801561001057600080fd5b506004361061021c5760003560e01c80638bb8458411610125578063c4937ab9116100ad578063da4ca0391161007c578063da4ca03914610462578063db19da0d14610475578063dcbad90d1461047e578063f2b3c80914610491578063f2fde38b1461049a57600080fd5b8063c4937ab914610420578063c5f956af14610433578063c914914f14610446578063ca9d740f1461045957600080fd5b80639c384653116100f45780639c384653146103c15780639d8ca531146103d4578063adb4aee8146103e7578063b1829b82146103fa578063c38de5391461040d57600080fd5b80638bb84584146103695780638da5cb5b1461037c5780638fc3539a1461038d57806398359fa1146103ae57600080fd5b8063456d66e3116101a85780636be4097c116101775780636be4097c14610334578063715018a61461033d5780637cb583bd1461034557806380a061601461034e57806388303dbd1461035657600080fd5b8063456d66e3146102f2578063471aeab414610305578063686465b8146103185780636b8737881461032157600080fd5b80631fe86c6b116101ef5780631fe86c6b146102985780632423807a146102a15780632d3eb68e146102c15780632e530cae146102ca5780633f138d4b146102dd57600080fd5b806305531eeb1461022157806307fb5a9c1461024d578063127effb21461026457806312a9769d1461028f575b600080fd5b61023461022f366004613055565b6104ad565b60405161024494939291906133f9565b60405180910390f35b610256600b5481565b604051908152602001610244565b600354610277906001600160a01b031681565b6040516001600160a01b039091168152602001610244565b610256600a5481565b61025660075481565b6102b46102af3660046130ed565b610799565b6040516102449190613590565b61025660095481565b6102566102d83660046132b2565b6108fa565b6102f06102eb36600461302b565b610981565b005b6102f0610300366004613215565b610a62565b6102f0610313366004613215565b610ada565b61025660065481565b6102f061032f3660046130ed565b610c1d565b61025660055481565b6102f0610c87565b61025661012c81565b600554610256565b6102f0610364366004613199565b610cfb565b600d54610277906001600160a01b031681565b6001546001600160a01b0316610277565b6103a061039b36600461308e565b6111cb565b60405161024492919061346d565b6102f06103bc366004612fcd565b611385565b600254610277906001600160a01b031681565b6102f06103e23660046130ed565b611573565b6102f06103f5366004613215565b61177b565b6102f0610408366004613263565b611800565b6102f061041b3660046131e5565b611ce9565b61025661042e366004613237565b61228b565b600454610277906001600160a01b031681565b6102f061045436600461311f565b612337565b61025660085481565b6102f0610470366004612fe8565b6128aa565b610256600c5481565b600e54610277906001600160a01b031681565b610256610bb881565b6102f06104a8366004612fcd565b6129ca565b6001600160a01b0384166000908152601360209081526040808320868452909152812054606091829182919085906104e588826137f6565b8211156104f9576104f688826137f6565b91505b60008267ffffffffffffffff81111561051457610514613918565b60405190808252806020026020018201604052801561053d578160200160208202803683370190505b50905060008367ffffffffffffffff81111561055b5761055b613918565b604051908082528060200260200182016040528015610584578160200160208202803683370190505b50905060008467ffffffffffffffff8111156105a2576105a2613918565b6040519080825280602002602001820160405280156105cb578160200160208202803683370190505b50905060005b8581101561077357601360008f6001600160a01b03166001600160a01b0316815260200190815260200160002060008e81526020019081526020016000208c8261061b9190613653565b8154811061062b5761062b613902565b906000526020600020015484828151811061064857610648613902565b6020026020010181815250506010600085838151811061066a5761066a613902565b6020026020010151815260200190815260200160002060000160009054906101000a900463ffffffff168382815181106106a6576106a6613902565b602002602001019063ffffffff16908163ffffffff168152505060006001600160a01b0316601060008684815181106106e1576106e1613902565b60209081029190910181015182528101919091526040016000205464010000000090046001600160a01b0316141561073c57600182828151811061072757610727613902565b91151560209283029190910190910152610761565b600082828151811061075057610750613902565b911515602092830291909101909101525b8061076b8161385e565b9150506105d1565b50828282610781888f613653565b98509850985098505050505050945094509450949050565b6107a1612e7a565b6000828152600f60205260409081902081516101a081019092528054829060ff1660038111156107d3576107d36138ec565b60038111156107e4576107e46138ec565b81526001820154602082015260028201546040808301919091526003830154606083015260048301546080830152805160c081019182905260a09092019190600584019060069082845b81548152602001906001019080831161082e575050509183525050600b82015460208201526040805160c081018252910190600c830160068282826020028201915b8154815260200190600101908083116108705750505091835250506040805160c081019182905260209092019190601284019060069082845b8154815260200190600101908083116108a95750505091835250506018820154602082015260198201546040820152601a8201546060820152601b9091015463ffffffff1660809091015292915050565b600060036000858152600f602052604090205460ff166003811115610921576109216138ec565b1461092e5750600061097a565b6000848152600f60205260409020601901548311801561095f57506000848152600f60205260409020601801548311155b1561096c5750600061097a565b610977848484612ab5565b90505b9392505050565b6001546001600160a01b031633146109b45760405162461bcd60e51b81526004016109ab906134fe565b60405180910390fd5b600d546001600160a01b0383811691161415610a085760405162461bcd60e51b815260206004820152601360248201527221b0b73737ba1031329029a7ac903a37b5b2b760691b60448201526064016109ab565b610a1c6001600160a01b0383163383612bc0565b604080516001600160a01b0384168152602081018390527f74545154aac348a3eac92596bd1971957ca94795f4e954ec5f613b55fab78129910160405180910390a15050565b6001546001600160a01b03163314610a8c5760405162461bcd60e51b81526004016109ab906134fe565b808210610acf5760405162461bcd60e51b81526020600482015260116024820152700dad2dc40daeae6e840c4ca407840dac2f607b1b60448201526064016109ab565b600b91909155600c55565b6001546001600160a01b0316331480610afd57506002546001600160a01b031633145b610b415760405162461bcd60e51b81526020600482015260156024820152742737ba1037bbb732b91037b91034b73532b1ba37b960591b60448201526064016109ab565b60016000838152600f602052604090205460ff166003811115610b6657610b666138ec565b14610ba65760405162461bcd60e51b815260206004820152601060248201526f2637ba3a32b93c903737ba1037b832b760811b60448201526064016109ab565b600d54610bbe906001600160a01b0316333084612c28565b6000828152600f60205260408120601a018054839290610bdf908490613653565b909155505060405181815282907f1bbd659dd628a25f7ff2eabb69c74a56939c539728282275c1c9c1a2d3e340499060200160405180910390a25050565b6001546001600160a01b03163314610c475760405162461bcd60e51b81526004016109ab906134fe565b80610c825760405162461bcd60e51b815260206004820152600b60248201526a04d757374206265203e20360ac1b60448201526064016109ab565b600755565b6001546001600160a01b03163314610cb15760405162461bcd60e51b81526004016109ab906134fe565b6001546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600180546001600160a01b0319169055565b333b15610d415760405162461bcd60e51b815260206004820152601460248201527310dbdb9d1c9858dd081b9bdd08185b1b1bddd95960621b60448201526064016109ab565b333214610d905760405162461bcd60e51b815260206004820152601a60248201527f50726f787920636f6e7472616374206e6f7420616c6c6f77656400000000000060448201526064016109ab565b60026000541415610db35760405162461bcd60e51b81526004016109ab90613533565b600260005580610dfb5760405162461bcd60e51b8152602060048201526013602482015272139bc81d1a58dad95d081cdc1958da599a5959606a1b60448201526064016109ab565b600754811115610e405760405162461bcd60e51b815260206004820152601060248201526f546f6f206d616e79207469636b65747360801b60448201526064016109ab565b60016000848152600f602052604090205460ff166003811115610e6557610e656138ec565b14610ea85760405162461bcd60e51b81526020600482015260136024820152722637ba3a32b93c9034b9903737ba1037b832b760691b60448201526064016109ab565b6000838152600f60205260409020600201544210610efa5760405162461bcd60e51b815260206004820152600f60248201526e2637ba3a32b93c9034b99037bb32b960891b60448201526064016109ab565b6000838152600f602052604081206004810154600390910154610f1e919084612c66565b600d54909150610f39906001600160a01b0316333084612c28565b6000848152600f60205260408120601a018054839290610f5a908490613653565b90915550600090505b82811015611188576000848483818110610f7f57610f7f613902565b9050602002016020810190610f9491906132eb565b90506103e88163ffffffff1610158015610fb657506107cf8163ffffffff1611155b610ff25760405162461bcd60e51b815260206004820152600d60248201526c4f7574736964652072616e676560981b60448201526064016109ab565b60008681526012602052604081209061100c600a8461389d565b61101790600161366b565b63ffffffff1681526020810191909152604001600090812080549161103b8361385e565b909155505060008681526012602052604081209061105a60648461389d565b61106590600b61366b565b63ffffffff168152602081019190915260400160009081208054916110898361385e565b90915550506000868152601260205260408120906110a96103e88461389d565b6110b490606f61366b565b63ffffffff168152602081019190915260400160009081208054916110d88361385e565b90915550503360008181526013602090815260408083208a84528252808320600680548254600181018455928652848620909201919091558151808301835263ffffffff80881682528185019687528254865260109094529184209151825495516001600160a01b0316640100000000026001600160c01b0319909616931692909217939093179092558154919061116f8361385e565b91905055505080806111809061385e565b915050610f63565b50604051828152849033907fd7d247b583de1023852eef87b48f54354dbec771d01bc2cc49e96094efc322b99060200160405180910390a3505060016000555050565b6060808260008167ffffffffffffffff8111156111ea576111ea613918565b604051908082528060200260200182016040528015611213578160200160208202803683370190505b50905060008267ffffffffffffffff81111561123157611231613918565b60405190808252806020026020018201604052801561125a578160200160208202803683370190505b50905060005b83811015611376576010600089898481811061127e5761127e613902565b90506020020135815260200190815260200160002060000160009054906101000a900463ffffffff168382815181106112b9576112b9613902565b63ffffffff9092166020928302919091019091015260006010818a8a858181106112e5576112e5613902565b602090810292909201358352508101919091526040016000205464010000000090046001600160a01b0316141561133f57600182828151811061132a5761132a613902565b91151560209283029190910190910152611364565b600082828151811061135357611353613902565b911515602092830291909101909101525b8061136e8161385e565b915050611260565b509093509150505b9250929050565b6001546001600160a01b031633146113af5760405162461bcd60e51b81526004016109ab906134fe565b60036005546000908152600f602052604090205460ff1660038111156113d7576113d76138ec565b146114245760405162461bcd60e51b815260206004820152601860248201527f4c6f7474657279206e6f7420696e20636c61696d61626c65000000000000000060448201526064016109ab565b806001600160a01b031663b37217a4600554600654604051602001611453929190918252602082015260400190565b60408051808303601f1901815290829052805160209091012060e083901b6001600160e01b03191682526004820152602401600060405180830381600087803b15801561149f57600080fd5b505af11580156114b3573d6000803e3d6000fd5b50505050806001600160a01b031663a1c4f55a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156114f057600080fd5b505afa158015611504573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115289190613308565b50600e80546001600160a01b0319166001600160a01b0383169081179091556040517f383f8cb39dfa7c3fb901a460dd449ea924868f0a92ff03da64740fffa5f1de6290600090a250565b6003546001600160a01b0316331461159d5760405162461bcd60e51b81526004016109ab9061356a565b600260005414156115c05760405162461bcd60e51b81526004016109ab90613533565b600260005560016000828152600f602052604090205460ff1660038111156115ea576115ea6138ec565b1461162a5760405162461bcd60e51b815260206004820152601060248201526f2637ba3a32b93c903737ba1037b832b760811b60448201526064016109ab565b6000818152600f6020526040902060020154421161167d5760405162461bcd60e51b815260206004820152601060248201526f2637ba3a32b93c903737ba1037bb32b960811b60448201526064016109ab565b6006546000828152600f6020908152604091829020601901839055600e548251918201859052918101929092526001600160a01b03169063b37217a49060600160408051808303601f1901815290829052805160209091012060e083901b6001600160e01b03191682526004820152602401600060405180830381600087803b15801561170957600080fd5b505af115801561171d573d6000803e3d6000fd5b5050506000828152600f6020908152604091829020805460ff1916600217905560065491519182528392507f3728e75294796694d59d2ffced9c394279baf7b9ebd2702db43f5f04bac67929910160405180910390a2506001600055565b6001546001600160a01b031633146117a55760405162461bcd60e51b81526004016109ab906134fe565b808211156117f55760405162461bcd60e51b815260206004820152601b60248201527f6d696e5072696365206d757374206265203c206d61785072696365000000000060448201526064016109ab565b600991909155600855565b6003546001600160a01b0316331461182a5760405162461bcd60e51b81526004016109ab9061356a565b600554158061185e575060036005546000908152600f602052604090205460ff16600381111561185c5761185c6138ec565b145b6118aa5760405162461bcd60e51b815260206004820152601960248201527f4e6f742074696d6520746f207374617274206c6f74746572790000000000000060448201526064016109ab565b600b546118b742876137f6565b1180156118ce5750600c546118cc42876137f6565b105b61191a5760405162461bcd60e51b815260206004820152601f60248201527f4c6f7474657279206c656e677468206f757473696465206f662072616e67650060448201526064016109ab565b600954841015801561192e57506008548411155b61196e5760405162461bcd60e51b81526020600482015260116024820152704f757473696465206f66206c696d69747360781b60448201526064016109ab565b61012c8310156119c05760405162461bcd60e51b815260206004820152601860248201527f446973636f756e742064697669736f7220746f6f206c6f77000000000000000060448201526064016109ab565b610bb8811115611a0a5760405162461bcd60e51b81526020600482015260156024820152740a8e4cac2e6eae4f240cccaca40e8dede40d0d2ced605b1b60448201526064016109ab565b60a0820135608083013560608401356040850135611a2d60208701358735613653565b611a379190613653565b611a419190613653565b611a4b9190613653565b611a559190613653565b61271014611aa55760405162461bcd60e51b815260206004820152601860248201527f52657761726473206d75737420657175616c203130303030000000000000000060448201526064016109ab565b60058054906000611ab58361385e565b9091555050604080516101a0810190915280600181526020014281526020018681526020018581526020018481526020018360068060200260405190810160405280929190826006602002808284376000920182905250928452505060208083018590526040805160c080820183528482528184018590528183018590526060808301869052608080840187905260a080850188905285890194909452845180840186528781528087018890528086018890528083018890528082018890528085018890529188019190915260065490870181905291860191909152600a549085015260e09093018290526005548252600f90522081518154829060ff19166001836003811115611bc857611bc86138ec565b02179055506020820151600182015560408201516002820155606082015160038201556080820151600482015560a0820151611c0a9060058301906006612efb565b5060c0820151600b82015560e0820151611c2a90600c8301906006612efb565b50610100820151611c419060128301906006612efb565b5061012082015160188201556101408201516019820155610160820151601a82015561018090910151601b909101805463ffffffff191663ffffffff909216919091179055600554600654600a5460408051428152602081018a9052908101889052606081019290925260808201527f367e70f8c0e0c0a6504d92172bda155c02022d532fc85b5d66a9c49e31c8bc779060a00160405180910390a250506000600a55505050565b6003546001600160a01b03163314611d135760405162461bcd60e51b81526004016109ab9061356a565b60026000541415611d365760405162461bcd60e51b81526004016109ab90613533565b60026000818155838152600f602052604090205460ff166003811115611d5e57611d5e6138ec565b14611d9f5760405162461bcd60e51b81526020600482015260116024820152704c6f7474657279206e6f7420636c6f736560781b60448201526064016109ab565b600e60009054906101000a90046001600160a01b03166001600160a01b031663fbe5d9176040518163ffffffff1660e01b815260040160206040518083038186803b158015611ded57600080fd5b505afa158015611e01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e259190613106565b8214611e675760405162461bcd60e51b8152602060048201526011602482015270273ab6b132b939903737ba10323930bbb760791b60448201526064016109ab565b600e54604080516350e27aad60e11b815290516000926001600160a01b03169163a1c4f55a916004808301926020929190829003018186803b158015611eac57600080fd5b505afa158015611ec0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ee49190613308565b6000848152600f60205260408120600b015491925090819061271090611f0a90826137f6565b6000878152600f60205260409020601a0154611f2691906137d7565b611f309190613693565b90506000805b60038163ffffffff1610156121b657600081611f54600160036137f6565b611f5e919061380d565b90506000611f6d82600161366b565b611f7890600a6136ec565b611f82908861389d565b63ffffffff808416600090815260116020526040902054611fa492911661366b565b60008a815260126020908152604080832063ffffffff85168452909152902054909150611fd29087906137f6565b60008a8152600f6020526040902060120163ffffffff841660068110611ffa57611ffa613902565b0155600089815260126020908152604080832063ffffffff851684529091529020546120279087906137f6565b15612126576000898152600f6020526040902060050163ffffffff83166006811061205457612054613902565b01541561212157600089815260126020908152604080832063ffffffff851684529091529020546127109061208a9088906137f6565b60008b8152600f60205260409020879060050163ffffffff8616600681106120b4576120b4613902565b01546120c091906137d7565b6120ca9190613693565b6120d49190613693565b60008a8152600f60205260409020600c0163ffffffff8416600681106120fc576120fc613902565b0155600089815260126020908152604080832063ffffffff8516845290915290205495505b6121a1565b6000898152600f60205260408120600c0163ffffffff84166006811061214e5761214e613902565b01556000898152600f6020526040902061271090869060050163ffffffff85166006811061217e5761217e613902565b015461218a91906137d7565b6121949190613693565b61219e9085613653565b93505b505080806121ae90613879565b915050611f36565b506000868152600f60205260409020601b8101805463ffffffff871663ffffffff19909116179055805460ff1916600317905584156121f557600a5560005b6000868152600f60205260409020601a01546122129083906137f6565b61221c9082613653565b600454600d5491925061223c916001600160a01b03908116911683612bc0565b6005546040805163ffffffff87168152602081018690527f98e31a6607b8b15b4d5b91de54f4c09ffe4c4cf162aa532c70b5213754e2e703910160405180910390a25050600160005550505050565b600061012c8410156122df5760405162461bcd60e51b815260206004820152601f60248201527f4d757374206265203e3d204d494e5f444953434f554e545f44495649534f520060448201526064016109ab565b8161232c5760405162461bcd60e51b815260206004820152601d60248201527f4e756d626572206f66207469636b657473206d757374206265203e203000000060448201526064016109ab565b610977848484612c66565b333b1561237d5760405162461bcd60e51b815260206004820152601460248201527310dbdb9d1c9858dd081b9bdd08185b1b1bddd95960621b60448201526064016109ab565b3332146123cc5760405162461bcd60e51b815260206004820152601a60248201527f50726f787920636f6e7472616374206e6f7420616c6c6f77656400000000000060448201526064016109ab565b600260005414156123ef5760405162461bcd60e51b81526004016109ab90613533565b60026000558281146124355760405162461bcd60e51b815260206004820152600f60248201526e09cdee840e6c2daca40d8cadccee8d608b1b60448201526064016109ab565b826124765760405162461bcd60e51b815260206004820152601160248201527004c656e677468206d757374206265203e3607c1b60448201526064016109ab565b6007548311156124bb5760405162461bcd60e51b815260206004820152601060248201526f546f6f206d616e79207469636b65747360801b60448201526064016109ab565b60036000868152600f602052604090205460ff1660038111156124e0576124e06138ec565b146125255760405162461bcd60e51b81526020600482015260156024820152744c6f7474657279206e6f7420636c61696d61626c6560581b60448201526064016109ab565b6000805b8481101561284857600384848381811061254557612545613902565b905060200201602081019061255a91906132eb565b63ffffffff16106125a45760405162461bcd60e51b8152602060048201526014602482015273427261636b6574206f7574206f662072616e676560601b60448201526064016109ab565b60008686838181106125b8576125b8613902565b90506020020135905080600f60008a8152602001908152602001600020601901541161261a5760405162461bcd60e51b81526020600482015260116024820152700a8d2c6d6cae892c840e8dede40d0d2ced607b1b60448201526064016109ab565b6000888152600f602052604090206018015481101561266e5760405162461bcd60e51b815260206004820152601060248201526f5469636b6574496420746f6f206c6f7760801b60448201526064016109ab565b60008181526010602052604090205464010000000090046001600160a01b031633146126cc5760405162461bcd60e51b815260206004820152600d60248201526c2737ba103a34329037bbb732b960991b60448201526064016109ab565b60008181526010602052604081208054640100000000600160c01b031916905561271d898388888781811061270357612703613902565b905060200201602081019061271891906132eb565b612ab5565b90508061276c5760405162461bcd60e51b815260206004820152601960248201527f4e6f207072697a6520666f72207468697320627261636b65740000000000000060448201526064016109ab565b612778600160036137f6565b86868581811061278a5761278a613902565b905060200201602081019061279f91906132eb565b63ffffffff1614612827576127e189838888878181106127c1576127c1613902565b90506020020160208101906127d691906132eb565b61271890600161366b565b156128275760405162461bcd60e51b8152602060048201526016602482015275213930b1b5b2ba1036bab9ba103132903434b3b432b960511b60448201526064016109ab565b6128318185613653565b9350505080806128409061385e565b915050612529565b50600d54612860906001600160a01b03163383612bc0565b6040805182815260208101869052879133917f0f5fca62da8fb5d95525b49e5eaa7b20bc6bd9e2f6b64b493442d1c0bd6ef486910160405180910390a35050600160005550505050565b6001546001600160a01b031633146128d45760405162461bcd60e51b81526004016109ab906134fe565b6001600160a01b0383166128fa5760405162461bcd60e51b81526004016109ab906134ce565b6001600160a01b0382166129205760405162461bcd60e51b81526004016109ab906134ce565b6001600160a01b0381166129465760405162461bcd60e51b81526004016109ab906134ce565b600380546001600160a01b038581166001600160a01b0319928316811790935560048054868316908416811790915560028054928616929093168217909255604080519384526020840192909252908201527f3e945b7660001d46cfd5e729545f7f0b6c65bdee54066a91c7acad703f1b731e9060600160405180910390a1505050565b6001546001600160a01b031633146129f45760405162461bcd60e51b81526004016109ab906134fe565b6001600160a01b038116612a595760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016109ab565b6001546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600180546001600160a01b0319166001600160a01b0392909216919091179055565b6000838152600f60209081526040808320601b0154858452601090925282205463ffffffff918216911682612aeb85600161366b565b612af690600a6136ec565b612b00908361389d565b63ffffffff808716600090815260116020526040902054612b2292911661366b565b90506000612b3186600161366b565b612b3c90600a6136ec565b612b46908561389d565b63ffffffff808816600090815260116020526040902054612b6892911661366b565b90508063ffffffff168263ffffffff161415612bb3576000888152600f60205260409020600c0163ffffffff871660068110612ba657612ba6613902565b015494505050505061097a565b600094505050505061097a565b6040516001600160a01b038316602482015260448101829052612c2390849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612c9d565b505050565b6040516001600160a01b0380851660248301528316604482015260648101829052612c609085906323b872dd60e01b90608401612bec565b50505050565b60008382612c75826001613653565b612c7f91906137f6565b612c8984866137d7565b612c9391906137d7565b6109779190613693565b6000612cf2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612d6f9092919063ffffffff16565b805190915015612c235780806020019051810190612d1091906130d0565b612c235760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016109ab565b6060610977848460008585843b612dc85760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016109ab565b600080866001600160a01b03168587604051612de491906133dd565b60006040518083038185875af1925050503d8060008114612e21576040519150601f19603f3d011682016040523d82523d6000602084013e612e26565b606091505b5091509150612e36828286612e41565b979650505050505050565b60608315612e5057508161097a565b825115612e605782518084602001fd5b8160405162461bcd60e51b81526004016109ab919061349b565b604080516101a08101909152806000815260200160008152602001600081526020016000815260200160008152602001612eb2612f39565b815260200160008152602001612ec6612f39565b8152602001612ed3612f39565b8152602001600081526020016000815260200160008152602001600063ffffffff1681525090565b8260068101928215612f29579160200282015b82811115612f29578251825591602001919060010190612f0e565b50612f35929150612f57565b5090565b6040518060c001604052806006906020820280368337509192915050565b5b80821115612f355760008155600101612f58565b80356001600160a01b0381168114612f8357600080fd5b919050565b60008083601f840112612f9a57600080fd5b50813567ffffffffffffffff811115612fb257600080fd5b6020830191508360208260051b850101111561137e57600080fd5b600060208284031215612fdf57600080fd5b61097a82612f6c565b600080600060608486031215612ffd57600080fd5b61300684612f6c565b925061301460208501612f6c565b915061302260408501612f6c565b90509250925092565b6000806040838503121561303e57600080fd5b61304783612f6c565b946020939093013593505050565b6000806000806080858703121561306b57600080fd5b61307485612f6c565b966020860135965060408601359560600135945092505050565b600080602083850312156130a157600080fd5b823567ffffffffffffffff8111156130b857600080fd5b6130c485828601612f88565b90969095509350505050565b6000602082840312156130e257600080fd5b815161097a8161392e565b6000602082840312156130ff57600080fd5b5035919050565b60006020828403121561311857600080fd5b5051919050565b60008060008060006060868803121561313757600080fd5b85359450602086013567ffffffffffffffff8082111561315657600080fd5b61316289838a01612f88565b9096509450604088013591508082111561317b57600080fd5b5061318888828901612f88565b969995985093965092949392505050565b6000806000604084860312156131ae57600080fd5b83359250602084013567ffffffffffffffff8111156131cc57600080fd5b6131d886828701612f88565b9497909650939450505050565b600080604083850312156131f857600080fd5b82359150602083013561320a8161392e565b809150509250929050565b6000806040838503121561322857600080fd5b50508035926020909101359150565b60008060006060848603121561324c57600080fd5b505081359360208301359350604090920135919050565b6000806000806000610140868803121561327c57600080fd5b8535945060208601359350604086013592506101208601878111156132a057600080fd5b94979396509194606001933592915050565b6000806000606084860312156132c757600080fd5b833592506020840135915060408401356132e08161393f565b809150509250925092565b6000602082840312156132fd57600080fd5b813561097a8161393f565b60006020828403121561331a57600080fd5b815161097a8161393f565b600081518084526020808501945080840160005b83811015613357578151151587529582019590820190600101613339565b509495945050505050565b8060005b6006811015612c60578151845260209384019390910190600101613366565b600081518084526020808501945080840160005b8381101561335757815163ffffffff1687529582019590820190600101613399565b600481106133d957634e487b7160e01b600052602160045260246000fd5b9052565b600082516133ef818460208701613832565b9190910192915050565b6080808252855190820181905260009060209060a0840190828901845b8281101561343257815184529284019290840190600101613416565b505050838103828501526134468188613385565b915050828103604084015261345b8186613325565b91505082606083015295945050505050565b6040815260006134806040830185613385565b82810360208401526134928185613325565b95945050505050565b60208152600082518060208401526134ba816040850160208701613832565b601f01601f19169190910160400192915050565b60208082526016908201527543616e6e6f74206265207a65726f206164647265737360501b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6020808252600c908201526b2737ba1037b832b930ba37b960a11b604082015260600190565b6000610380820190506135a48284516133bb565b6020830151602083015260408301516040830152606083015160608301526080830151608083015260a08301516135de60a0840182613362565b5060c0830151610160818185015260e0850151915061018061360281860184613362565b6101008601519250613618610240860184613362565b6101208601516103008601526101408601516103208601529085015161034085015284015163ffffffff811661036085015290505092915050565b60008219821115613666576136666138c0565b500190565b600063ffffffff80831681851680830382111561368a5761368a6138c0565b01949350505050565b6000826136a2576136a26138d6565b500490565b600181815b808511156136e4578163ffffffff048211156136ca576136ca6138c0565b808516156136d757918102915b93841c93908002906136ac565b509250929050565b600063ffffffff613701818516828516613709565b949350505050565b600082613718575060016137d1565b81613725575060006137d1565b816001811461373b576002811461374557613776565b60019150506137d1565b60ff841115613756576137566138c0565b6001841b915063ffffffff821115613770576137706138c0565b506137d1565b5060208310610133831016604e8410600b84101617156137ad575081810a63ffffffff8111156137a8576137a86138c0565b6137d1565b6137b783836136a7565b8063ffffffff048211156137cd576137cd6138c0565b0290505b92915050565b60008160001904831182151516156137f1576137f16138c0565b500290565b600082821015613808576138086138c0565b500390565b600063ffffffff8381169083168181101561382a5761382a6138c0565b039392505050565b60005b8381101561384d578181015183820152602001613835565b83811115612c605750506000910152565b6000600019821415613872576138726138c0565b5060010190565b600063ffffffff80831681811415613893576138936138c0565b6001019392505050565b600063ffffffff808416806138b4576138b46138d6565b92169190910692915050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b801515811461393c57600080fd5b50565b63ffffffff8116811461393c57600080fdfea2646970667358221220bf8a462212477d35e7c912e9bea1785cc770f168731753264a7a656a2126adb464736f6c63430008070033