Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- GamiFi
- Optimization enabled
- true
- Compiler version
- v0.8.28+commit.7893614a
- Optimization runs
- 200
- EVM Version
- paris
- Verified at
- 2026-01-22T16:40:49.334628Z
contracts/GamiFi.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./PoolManager.sol";
import "./MatchManager.sol";
import "./PrizeManager.sol";
contract GamiFi is Ownable, PoolManager, MatchManager, PrizeManager {
using SafeERC20 for IERC20;
constructor() Ownable(msg.sender) {}
function createPool(
bytes32 poolId,
address tokenAddress
) public onlyOwner returns (address) {
return _createPool(poolId, tokenAddress);
}
function setPoolState(
bytes32 poolId,
PoolState newState
) public override onlyOwner {
super.setPoolState(poolId, newState);
}
function createMatch(
bytes32[] memory poolIds
) public onlyOwner returns (bytes32[] memory) {
require(poolIds.length >= 2, "At least 2 pools required");
require(poolIds.length % 2 == 0, "Pool array length must be even");
bytes32[] memory matchIds = new bytes32[](poolIds.length / 2);
for (uint256 i = 0; i < poolIds.length; i += 2) {
bytes32 poolA = poolIds[i];
bytes32 poolB = poolIds[i + 1];
Pool storage _poolA = pools[poolA];
Pool storage _poolB = pools[poolB];
require(_poolA.isActive, "Token pool A does not exist");
require(_poolB.isActive, "Token pool B does not exist");
require(_poolA.matchId == bytes32(0), "Pool A already in a match");
require(_poolB.matchId == bytes32(0), "Pool B already in a match");
require(poolA != poolB, "Pools must be different");
// Set pool state to match in progress
bytes32 matchId = _createMatch(poolA, poolB);
_matchPools(poolA, poolB, matchId);
_startMatch(poolA, poolB);
matchIds[i / 2] = matchId;
}
return matchIds;
}
function endMatch(
bytes32 poolA,
bytes32 poolB,
bytes32 winner,
address[] memory players,
uint256[] memory shares
) public override onlyOwner {
// Set pool state to match ended
setPoolState(poolA, PoolState.MATCH_ENDED);
setPoolState(poolB, PoolState.MATCH_ENDED);
bytes32 matchId = getMatchId(poolA, poolB);
super.endMatch(poolA, poolB, winner, players, shares);
bytes32 _losingToken = getLoser(poolA, poolB);
uint256 _losingTokenBalance = pools[_losingToken].totalFunds;
uint256 _serviceFee = _claimServiceFee(
matchId,
pools[_losingToken].tokenAddress,
_losingTokenBalance
);
_claimFunds(_losingToken, _serviceFee);
}
function claimPrize(bytes32 poolA, bytes32 poolB) public nonReentrant {
bytes32 matchId = getMatchId(poolA, poolB);
Match storage _match = matches[matchId];
require(_match.state == MatchState.MATCH_ENDED, "Match is not over");
bytes32 _winningToken = _match.winner;
bytes32 _losingToken = getLoser(poolA, poolB);
uint256 _losingTokenInitialBalance = pools[_losingToken].totalFunds;
uint256 _playerSharePercentage = getPlayerShare(
poolA,
poolB,
msg.sender
);
uint256 _stakerSharePercentage = getStakerShare(
_winningToken,
msg.sender
);
uint256 _stakerContribution = getContribution(
_winningToken,
msg.sender
);
(
uint256 _claimedWinningToken,
uint256 _claimedLosingToken
) = _claimPrize(
matchId,
pools[_winningToken].tokenAddress,
pools[_losingToken].tokenAddress,
_losingTokenInitialBalance,
_playerSharePercentage,
_stakerSharePercentage,
_stakerContribution
);
_claimFunds(_winningToken, _claimedWinningToken);
_claimFunds(_losingToken, _claimedLosingToken);
}
function deleteMatch(
bytes32 poolA,
bytes32 poolB,
address foundsReceiver
) public onlyOwner {
bytes32 matchId = getMatchId(poolA, poolB);
require(!matches[matchId].isActive, "Match is active");
_deletePool(poolA, foundsReceiver);
_deletePool(poolB, foundsReceiver);
_deleteMatch(matchId);
_deleteMatchClaimRecord(matchId);
}
function setPoolDepositAllowed(
bytes32 poolId,
bool isDepositAllowed
) public onlyOwner {
_setPoolDepositAllowed(poolId, isDepositAllowed);
}
function setPoolWithdrawalAllowed(
bytes32 poolId,
bool isWithdrawalAllowed
) public onlyOwner {
_setPoolWithdrawalAllowed(poolId, isWithdrawalAllowed);
}
function endMatchAndClaimAndDelete(
bytes32 poolA,
bytes32 poolB,
bytes32 winner,
address[] memory players,
uint256[] memory shares,
address foundsReceiver
) public onlyOwner nonReentrant {
// Step 1: End the match
setPoolState(poolA, PoolState.MATCH_ENDED);
setPoolState(poolB, PoolState.MATCH_ENDED);
bytes32 matchId = getMatchId(poolA, poolB);
super.endMatch(poolA, poolB, winner, players, shares);
bytes32 _losingToken = getLoser(poolA, poolB);
uint256 _losingTokenBalance = pools[_losingToken].totalFunds;
uint256 _serviceFee = _claimServiceFee(
matchId,
pools[_losingToken].tokenAddress,
_losingTokenBalance
);
_claimFunds(_losingToken, _serviceFee);
// Step 2: Claim prizes for all eligible users
_claimPrizesForAllUsers(matchId, poolA, poolB, winner, _losingToken, _losingTokenBalance, players);
// Step 3: Delete the match and pools
require(!matches[matchId].isActive, "Match is active");
_deletePool(poolA, foundsReceiver);
_deletePool(poolB, foundsReceiver);
_deleteMatch(matchId);
_deleteMatchClaimRecord(matchId);
}
function _claimPrizesForAllUsers(
bytes32 matchId,
bytes32 poolA,
bytes32 poolB,
bytes32 _winningToken,
bytes32 _losingToken,
uint256 _losingTokenInitialBalance,
address[] memory players
) internal {
// Claim for all stakers (contributors to winning pool)
Pool storage winningPool = pools[_winningToken];
for (uint256 i = 0; i < winningPool.contributors.length; i++) {
address contributor = winningPool.contributors[i];
if (pools[_winningToken].contributions[contributor] > 0) {
_claimPrizeForAddress(
matchId,
poolA,
poolB,
_winningToken,
_losingToken,
_losingTokenInitialBalance,
contributor
);
}
}
// Claim for all players (if they haven't already claimed as stakers)
for (uint256 i = 0; i < players.length; i++) {
address player = players[i];
uint256 playerShare = getPlayerShare(poolA, poolB, player);
if (playerShare > 0 && !matchClaimRecords[matchId].hasClaimedPlayerPrize[player]) {
_claimPlayerPrizeForAddress(
matchId,
poolA,
poolB,
_winningToken,
_losingToken,
_losingTokenInitialBalance,
player,
playerShare
);
}
}
}
function _claimPrizeForAddress(
bytes32 /* _matchId */,
bytes32 poolA,
bytes32 poolB,
bytes32 _winningToken,
bytes32 _losingToken,
uint256 _losingTokenInitialBalance,
address claimer
) internal {
bytes32 matchIdCheck = getMatchId(poolA, poolB);
require(
!matchClaimRecords[matchIdCheck].hasClaimedStakerRefund[claimer],
"Already claimed"
);
require(
!matchClaimRecords[matchIdCheck].hasClaimedStakerPrize[claimer],
"Already claimed"
);
matchClaimRecords[matchIdCheck].hasClaimedStakerRefund[claimer] = true;
matchClaimRecords[matchIdCheck].hasClaimedStakerPrize[claimer] = true;
uint256 _playerSharePercentage = getPlayerShare(poolA, poolB, claimer);
if (_playerSharePercentage > 0) {
matchClaimRecords[matchIdCheck].hasClaimedPlayerPrize[claimer] = true;
}
uint256 _stakerSharePercentage = getStakerShare(_winningToken, claimer);
uint256 _stakerContribution = getContribution(_winningToken, claimer);
uint256 claimableStakerPrize = _getClaimableStakerPrize(
_losingTokenInitialBalance,
_stakerSharePercentage
);
uint256 claimablePlayerPrize = 0;
if (_playerSharePercentage > 0) {
claimablePlayerPrize = _getClaimablePlayerPrize(
_losingTokenInitialBalance,
_playerSharePercentage
);
}
// Transfer winning token (staker refund)
if (pools[_winningToken].tokenAddress == address(0)) {
(bool success, ) = payable(claimer).call{value: _stakerContribution}("");
require(success, "Transfer failed");
} else {
IERC20 winningToken = IERC20(pools[_winningToken].tokenAddress);
winningToken.safeTransfer(claimer, _stakerContribution);
}
// Transfer losing token (prizes)
uint256 totalPrize = claimableStakerPrize + claimablePlayerPrize;
if (totalPrize > 0) {
if (pools[_losingToken].tokenAddress == address(0)) {
(bool success, ) = payable(claimer).call{value: totalPrize}("");
require(success, "Transfer failed");
} else {
IERC20 losingToken = IERC20(pools[_losingToken].tokenAddress);
losingToken.safeTransfer(claimer, totalPrize);
}
}
_claimFunds(_winningToken, _stakerContribution);
_claimFunds(_losingToken, totalPrize);
emit ClaimedStakePrice(claimer, pools[_winningToken].tokenAddress, _stakerContribution);
if (claimableStakerPrize > 0) {
emit ClaimedStakePrice(claimer, pools[_losingToken].tokenAddress, claimableStakerPrize);
}
if (claimablePlayerPrize > 0) {
emit ClaimedPlayerPrice(claimer, pools[_losingToken].tokenAddress, claimablePlayerPrize);
}
}
function _claimPlayerPrizeForAddress(
bytes32 /* _matchId */,
bytes32 poolA,
bytes32 poolB,
bytes32 /* _winningToken */,
bytes32 _losingToken,
uint256 _losingTokenInitialBalance,
address player,
uint256 playerShare
) internal {
bytes32 matchIdCheck = getMatchId(poolA, poolB);
require(
!matchClaimRecords[matchIdCheck].hasClaimedPlayerPrize[player],
"Already claimed"
);
matchClaimRecords[matchIdCheck].hasClaimedPlayerPrize[player] = true;
uint256 claimablePlayerPrize = _getClaimablePlayerPrize(
_losingTokenInitialBalance,
playerShare
);
if (claimablePlayerPrize > 0) {
if (pools[_losingToken].tokenAddress == address(0)) {
(bool success, ) = payable(player).call{value: claimablePlayerPrize}("");
require(success, "Transfer failed");
} else {
IERC20 losingToken = IERC20(pools[_losingToken].tokenAddress);
losingToken.safeTransfer(player, claimablePlayerPrize);
}
_claimFunds(_losingToken, claimablePlayerPrize);
emit ClaimedPlayerPrice(player, pools[_losingToken].tokenAddress, claimablePlayerPrize);
}
}
}
@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
import {Address} from "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 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 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}
@openzeppelin/contracts/utils/Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Address.sol)
pragma solidity ^0.8.20;
import {Errors} from "./Errors.sol";
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert Errors.InsufficientBalance(address(this).balance, amount);
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert Errors.FailedCall();
}
}
/**
* @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 or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {Errors.FailedCall} error.
*
* 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.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @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`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert Errors.InsufficientBalance(address(this).balance, value);
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case
* of an unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {Errors.FailedCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly ("memory-safe") {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert Errors.FailedCall();
}
}
}
@openzeppelin/contracts/access/Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
@openzeppelin/contracts/interfaces/IERC1363.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}
@openzeppelin/contracts/interfaces/IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../utils/introspection/IERC165.sol";
@openzeppelin/contracts/interfaces/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../token/ERC20/IERC20.sol";
@openzeppelin/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
@openzeppelin/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
@openzeppelin/contracts/utils/Errors.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of common custom errors used in multiple contracts
*
* IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.
* It is recommended to avoid relying on the error API for critical functionality.
*
* _Available since v5.1._
*/
library Errors {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error InsufficientBalance(uint256 balance, uint256 needed);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedCall();
/**
* @dev The deployment failed.
*/
error FailedDeployment();
/**
* @dev A necessary precompile is missing.
*/
error MissingPrecompile(address);
}
@openzeppelin/contracts/utils/ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
* consider using {ReentrancyGuardTransient} instead.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}
@openzeppelin/contracts/utils/introspection/IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
contracts/MatchManager.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
// This contract has the responsibility of managing the state of a match
// A match is between two pools
abstract contract MatchManager {
enum MatchState {
PRE_MATCH,
MATCH_IN_PROGRESS,
MATCH_ENDED
}
struct Match {
bytes32 poolA;
bytes32 poolB;
bytes32 winner;
uint256 totalFundsA;
uint256 totalFundsB;
bool isActive;
MatchState state;
mapping(address => uint256) playerShares;
}
mapping(bytes32 => Match) public matches;
event MatchCreated(
bytes32 indexed poolA,
bytes32 indexed poolB,
bytes32 indexed matchId
);
event MatchStarted(
bytes32 indexed poolA,
bytes32 indexed poolB,
bytes32 indexed matchId
);
event MatchEnded(
bytes32 indexed poolA,
bytes32 indexed poolB,
bytes32 indexed matchId
);
function _createMatch(
bytes32 poolA,
bytes32 poolB
) internal returns (bytes32) {
require(poolA != poolB, "Pools must be different");
require(poolA != bytes32(0), "Invalid pool A ID");
require(poolB != bytes32(0), "Invalid pool B ID");
bytes32 matchId = getMatchId(poolA, poolB);
require(!matches[matchId].isActive, "Match already exists");
Match storage newMatch = matches[matchId];
newMatch.poolA = poolA;
newMatch.poolB = poolB;
newMatch.isActive = true;
newMatch.state = MatchState.PRE_MATCH;
emit MatchCreated(poolA, poolB, matchId);
return matchId;
}
function _startMatch(bytes32 poolA, bytes32 poolB) internal {
bytes32 matchId = getMatchId(poolA, poolB);
require(matches[matchId].isActive, "Match does not exist");
require(
matches[matchId].state == MatchState.PRE_MATCH,
"Match already started"
);
matches[matchId].state = MatchState.MATCH_IN_PROGRESS;
emit MatchStarted(poolA, poolB, matchId);
}
function endMatch(
bytes32 poolA,
bytes32 poolB,
bytes32 winner,
address[] memory players,
uint256[] memory shares
) public virtual {
bytes32 matchId = getMatchId(poolA, poolB);
require(matches[matchId].isActive, "Match does not exist");
require(
matches[matchId].state == MatchState.MATCH_IN_PROGRESS,
"Match not in progress"
);
require(winner == poolA || winner == poolB, "Invalid winner address");
require(players.length == shares.length, "Arrays length mismatch");
require(players.length > 0, "No players provided");
Match storage _match = matches[matchId];
_match.winner = winner;
_match.state = MatchState.MATCH_ENDED;
_match.isActive = false;
_setShares(matchId, players, shares);
emit MatchEnded(poolA, poolB, matchId);
}
function _setShares(
bytes32 _matchId,
address[] memory _players,
uint256[] memory _shares
) internal {
require(_players.length == _shares.length, "Arrays length mismatch");
require(_players.length > 0, "Empty arrays");
Match storage _match = matches[_matchId];
uint256 totalSharePercentage;
for (uint256 i = 0; i < _players.length; i++) {
require(_players[i] != address(0), "Invalid player address");
require(_shares[i] > 0, "Invalid share percentage");
totalSharePercentage += _shares[i];
_match.playerShares[_players[i]] = _shares[i];
}
require(totalSharePercentage == 10000, "Total shares must be 100%");
}
function _deleteMatch(bytes32 matchId) internal {
require(matchId != bytes32(0), "Invalid match ID");
delete matches[matchId];
}
function getMatchId(
bytes32 poolA,
bytes32 poolB
) public pure returns (bytes32) {
require(poolA != bytes32(0), "Invalid pool A ID");
require(poolB != bytes32(0), "Invalid pool B ID");
bytes32 pool1 = poolA < poolB ? poolA : poolB;
bytes32 pool2 = poolA < poolB ? poolB : poolA;
return keccak256(abi.encodePacked(pool1, pool2));
}
function getLoser(
bytes32 poolA,
bytes32 poolB
) public view returns (bytes32) {
bytes32 matchId = getMatchId(poolA, poolB);
Match storage _match = matches[matchId];
return _match.winner == poolA ? poolB : poolA;
}
function getPlayerShare(
bytes32 poolA,
bytes32 poolB,
address player
) public view returns (uint256) {
bytes32 matchId = getMatchId(poolA, poolB);
Match storage _match = matches[matchId];
return _match.playerShares[player];
}
}
contracts/PoolManager.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
abstract contract PoolManager is Ownable, ReentrancyGuard {
enum PoolState {
PRE_MATCH,
MATCH_IN_PROGRESS,
MATCH_ENDED
}
struct Pool {
address creator;
address tokenAddress;
uint256 totalFunds;
uint256 remainingFunds;
bool isActive;
PoolState state;
mapping(address => uint256) contributions;
address[] contributors;
bytes32 matchId;
bool isDepositAllowed;
bool isWithdrawalAllowed;
}
mapping(bytes32 => Pool) public pools;
event PoolCreated(
bytes32 indexed poolId,
address indexed tokenAddress,
address indexed creator
);
event FundsDeposited(
bytes32 indexed poolId,
address indexed tokenAddress,
address indexed depositor,
uint256 amount
);
event FundsWithdrawn(
bytes32 indexed poolId,
address indexed tokenAddress,
address indexed withdrawer,
uint256 amount
);
function _createPool(
bytes32 poolId,
address tokenAddress
) internal returns (address) {
require(!pools[poolId].isActive, "Pool already exists");
// Check if it's a ERC20 token
if (tokenAddress != address(0)) {
IERC20 token = IERC20(tokenAddress);
require(token.totalSupply() > 0, "Invalid token address");
}
Pool storage newPool = pools[poolId];
newPool.creator = msg.sender;
newPool.tokenAddress = tokenAddress;
newPool.isActive = true;
newPool.state = PoolState.PRE_MATCH;
newPool.isDepositAllowed = true;
newPool.isWithdrawalAllowed = true;
emit PoolCreated(poolId, tokenAddress, msg.sender);
return tokenAddress;
}
function _matchPools(
bytes32 _poolA,
bytes32 _poolB,
bytes32 _matchId
) internal {
Pool storage poolA = pools[_poolA];
Pool storage poolB = pools[_poolB];
poolA.matchId = _matchId;
poolB.matchId = _matchId;
poolA.state = PoolState.MATCH_IN_PROGRESS;
poolB.state = PoolState.MATCH_IN_PROGRESS;
}
function setPoolState(bytes32 poolId, PoolState newState) public virtual {
require(pools[poolId].isActive, "Pool does not exist");
pools[poolId].state = newState;
if (newState == PoolState.MATCH_ENDED) {
pools[poolId].remainingFunds = pools[poolId].totalFunds;
}
}
function _claimFunds(bytes32 poolId, uint256 amount) internal {
pools[poolId].remainingFunds -= amount;
}
function depositToPool(
bytes32 poolId,
uint256 amount
) public payable nonReentrant {
Pool storage pool = pools[poolId];
require(pool.isActive, "Pool does not exist");
require(pool.isDepositAllowed, "Deposits are not allowed");
if (pool.tokenAddress == address(0)) {
require(msg.value == amount, "Must send some tokens");
} else {
require(amount > 0, "Must send some tokens");
IERC20 token = IERC20(pool.tokenAddress);
require(
token.transferFrom(msg.sender, address(this), amount),
"Transfer failed"
);
}
pool.totalFunds += amount;
pool.contributions[msg.sender] += amount;
pool.contributors.push(msg.sender);
emit FundsDeposited(poolId, pool.tokenAddress, msg.sender, amount);
}
function withdrawFromPool(
bytes32 poolId,
uint256 amount
) public nonReentrant {
Pool storage pool = pools[poolId];
require(pool.isActive, "Pool is not active");
require(pool.isWithdrawalAllowed, "Withdrawals are not allowed");
require(amount > 0, "Must withdraw some tokens");
require(pool.contributions[msg.sender] >= amount, "Insufficient funds");
pool.totalFunds -= amount;
pool.contributions[msg.sender] -= amount;
if (pool.tokenAddress == address(0)) {
(bool success, ) = payable(msg.sender).call{value: amount}("");
require(success, "Transfer failed");
} else {
IERC20 token = IERC20(pool.tokenAddress);
require(token.transfer(msg.sender, amount), "Transfer failed");
}
emit FundsWithdrawn(poolId, pool.tokenAddress, msg.sender, amount);
}
function getPoolBalance(bytes32 poolId) public view returns (uint256) {
return pools[poolId].totalFunds;
}
function getPoolRemainingFunds(
bytes32 poolId
) public view returns (uint256) {
return pools[poolId].remainingFunds;
}
function getContribution(
bytes32 poolId,
address contributor
) public view returns (uint256) {
return pools[poolId].contributions[contributor];
}
function getStakerShare(
bytes32 poolId,
address contributor
) public view returns (uint256) {
if (pools[poolId].totalFunds == 0) {
return 0;
}
return
(pools[poolId].contributions[contributor] * 10000) /
pools[poolId].totalFunds;
}
function getPoolMatchId(bytes32 poolId) public view returns (bytes32) {
return pools[poolId].matchId;
}
function getPoolContributors(
bytes32 poolId,
uint256 _page,
uint256 _pageSize
) public view returns (address[] memory) {
Pool storage pool = pools[poolId];
uint256 start = _page * _pageSize;
uint256 end = start + _pageSize;
if (end > pool.contributors.length) {
end = pool.contributors.length;
}
address[] memory contributors = new address[](end - start);
for (uint256 i = start; i < end; i++) {
contributors[i - start] = pool.contributors[i];
}
return contributors;
}
function _deletePool(bytes32 poolId, address foundsReceiver) internal {
uint256 remainingFunds = pools[poolId].remainingFunds;
if (pools[poolId].tokenAddress == address(0)) {
(bool success, ) = payable(foundsReceiver).call{
value: remainingFunds
}("");
require(success, "Transfer failed");
} else {
// Withdraw the remaining funds
IERC20 token = IERC20(pools[poolId].tokenAddress);
require(
token.transfer(payable(foundsReceiver), remainingFunds),
"Transfer failed"
);
}
delete pools[poolId];
}
function _setPoolDepositAllowed(
bytes32 poolId,
bool isDepositAllowed
) public {
require(pools[poolId].isActive, "Pool does not exist");
pools[poolId].isDepositAllowed = isDepositAllowed;
}
function _setPoolWithdrawalAllowed(
bytes32 poolId,
bool isWithdrawalAllowed
) public {
require(pools[poolId].isActive, "Pool does not exist");
pools[poolId].isWithdrawalAllowed = isWithdrawalAllowed;
}
function isPoolDepositAllowed(bytes32 poolId) public view returns (bool) {
return pools[poolId].isDepositAllowed;
}
function isPoolWithdrawalAllowed(
bytes32 poolId
) public view returns (bool) {
return pools[poolId].isWithdrawalAllowed;
}
}
contracts/PrizeManager.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
abstract contract PrizeManager is ReentrancyGuard {
struct ClaimRecord {
bool isServiceFeeClaimed;
mapping(address => bool) hasClaimedStakerRefund;
mapping(address => bool) hasClaimedStakerPrize;
mapping(address => bool) hasClaimedPlayerPrize;
}
uint256 public serviceFeePercentage = 1000; //10%
uint256 public stakersPrizePercentage = 8100; //81%
uint256 public playersPrizePercentage = 900; //9%
uint256 private TOT = 10000; //100%
mapping(bytes32 => ClaimRecord) public matchClaimRecords;
event ClaimedServiceFee(
address indexed receiver,
address indexed token,
uint256 amount
);
event ClaimedStakePrice(
address indexed player,
address indexed token,
uint256 amount
);
event ClaimedPlayerPrice(
address indexed player,
address indexed token,
uint256 amount
);
function _claimServiceFee(
bytes32 _matchId,
address _losingToken,
uint256 _losingTokenBalance
) internal nonReentrant returns (uint256) {
require(
matchClaimRecords[_matchId].isServiceFeeClaimed == false,
"Already claimed"
);
matchClaimRecords[_matchId].isServiceFeeClaimed = true;
uint256 totalBalance = _losingTokenBalance;
uint256 feeAmount = (totalBalance * serviceFeePercentage) / TOT;
if (_losingToken == address(0)) {
(bool success, ) = msg.sender.call{value: feeAmount}("");
require(success, "Transfer failed");
} else {
IERC20 token = IERC20(_losingToken);
token.transfer(msg.sender, feeAmount);
}
emit ClaimedServiceFee(msg.sender, _losingToken, feeAmount);
return feeAmount;
}
function _claimPrize(
bytes32 _matchId,
address _winningToken,
address _losingToken,
uint256 _losingTokenInitialBalance,
uint256 _playerSharePercentage,
uint256 _stakerSharePercentage,
uint256 _stakerContribution
)
internal
returns (uint256 _claimableWinningToken, uint256 _claimableLosingToken)
{
require(
matchClaimRecords[_matchId].hasClaimedStakerRefund[msg.sender] ==
false,
"Already claimed"
);
require(
matchClaimRecords[_matchId].hasClaimedStakerPrize[msg.sender] ==
false,
"Already claimed"
);
require(
matchClaimRecords[_matchId].hasClaimedPlayerPrize[msg.sender] ==
false,
"Already claimed"
);
matchClaimRecords[_matchId].hasClaimedStakerRefund[msg.sender] = true;
matchClaimRecords[_matchId].hasClaimedStakerPrize[msg.sender] = true;
matchClaimRecords[_matchId].hasClaimedPlayerPrize[msg.sender] = true;
uint256 claimableStakerPrize = _getClaimableStakerPrize(
_losingTokenInitialBalance,
_stakerSharePercentage
);
uint256 claimablePlayerPrize = _getClaimablePlayerPrize(
_losingTokenInitialBalance,
_playerSharePercentage
);
if (_winningToken == address(0)) {
(bool success, ) = msg.sender.call{value: _stakerContribution}("");
require(success, "Transfer failed");
} else {
IERC20 winningToken = IERC20(_winningToken);
winningToken.transfer(msg.sender, _stakerContribution);
}
if (_losingToken == address(0)) {
(bool success, ) = msg.sender.call{
value: claimableStakerPrize + claimablePlayerPrize
}("");
require(success, "Transfer failed");
} else {
IERC20 losingToken = IERC20(_losingToken);
losingToken.transfer(
msg.sender,
claimableStakerPrize + claimablePlayerPrize
);
}
emit ClaimedStakePrice(msg.sender, _winningToken, _stakerContribution);
emit ClaimedStakePrice(msg.sender, _losingToken, claimableStakerPrize);
emit ClaimedPlayerPrice(msg.sender, _losingToken, claimablePlayerPrize);
return (
_stakerContribution,
claimableStakerPrize + claimablePlayerPrize
);
}
function _getClaimableStakerRefund(
uint256 winningTokenInitialBalance,
uint256 sharePercentage
) internal view returns (uint256) {
uint256 stakerRefund = (winningTokenInitialBalance * sharePercentage) /
TOT;
return stakerRefund;
}
function _getClaimableStakerPrize(
uint256 losingTokenInitialBalance,
uint256 sharePercentage
) internal view returns (uint256) {
// Calculate stakers price (81%)
uint256 totalStakersPrize = (losingTokenInitialBalance *
stakersPrizePercentage);
// Calculate player share of stakers price
uint256 playerPrize = (totalStakersPrize * sharePercentage) /
(TOT * TOT);
return playerPrize;
}
function _getClaimablePlayerPrize(
uint256 losingTokenInitialBalance,
uint256 sharePercentage
) internal view returns (uint256) {
// Calculate player amount (9%)
uint256 totalPlayersPrize = (losingTokenInitialBalance *
playersPrizePercentage);
// Calculate player share of players prize
uint256 playerPrize = (totalPlayersPrize * sharePercentage) /
(TOT * TOT);
return playerPrize;
}
function _deleteMatchClaimRecord(bytes32 _matchId) internal {
delete matchClaimRecords[_matchId];
}
}
Compiler Settings
{"outputSelection":{"*":{"*":["*"],"":["*"]}},"optimizer":{"runs":200,"enabled":true},"libraries":{},"evmVersion":"paris"}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[]},{"type":"error","name":"OwnableInvalidOwner","inputs":[{"type":"address","name":"owner","internalType":"address"}]},{"type":"error","name":"OwnableUnauthorizedAccount","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"error","name":"ReentrancyGuardReentrantCall","inputs":[]},{"type":"error","name":"SafeERC20FailedOperation","inputs":[{"type":"address","name":"token","internalType":"address"}]},{"type":"event","name":"ClaimedPlayerPrice","inputs":[{"type":"address","name":"player","internalType":"address","indexed":true},{"type":"address","name":"token","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"ClaimedServiceFee","inputs":[{"type":"address","name":"receiver","internalType":"address","indexed":true},{"type":"address","name":"token","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"ClaimedStakePrice","inputs":[{"type":"address","name":"player","internalType":"address","indexed":true},{"type":"address","name":"token","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"FundsDeposited","inputs":[{"type":"bytes32","name":"poolId","internalType":"bytes32","indexed":true},{"type":"address","name":"tokenAddress","internalType":"address","indexed":true},{"type":"address","name":"depositor","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"FundsWithdrawn","inputs":[{"type":"bytes32","name":"poolId","internalType":"bytes32","indexed":true},{"type":"address","name":"tokenAddress","internalType":"address","indexed":true},{"type":"address","name":"withdrawer","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"MatchCreated","inputs":[{"type":"bytes32","name":"poolA","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"poolB","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"matchId","internalType":"bytes32","indexed":true}],"anonymous":false},{"type":"event","name":"MatchEnded","inputs":[{"type":"bytes32","name":"poolA","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"poolB","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"matchId","internalType":"bytes32","indexed":true}],"anonymous":false},{"type":"event","name":"MatchStarted","inputs":[{"type":"bytes32","name":"poolA","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"poolB","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"matchId","internalType":"bytes32","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":"PoolCreated","inputs":[{"type":"bytes32","name":"poolId","internalType":"bytes32","indexed":true},{"type":"address","name":"tokenAddress","internalType":"address","indexed":true},{"type":"address","name":"creator","internalType":"address","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"_setPoolDepositAllowed","inputs":[{"type":"bytes32","name":"poolId","internalType":"bytes32"},{"type":"bool","name":"isDepositAllowed","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"_setPoolWithdrawalAllowed","inputs":[{"type":"bytes32","name":"poolId","internalType":"bytes32"},{"type":"bool","name":"isWithdrawalAllowed","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"claimPrize","inputs":[{"type":"bytes32","name":"poolA","internalType":"bytes32"},{"type":"bytes32","name":"poolB","internalType":"bytes32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bytes32[]","name":"","internalType":"bytes32[]"}],"name":"createMatch","inputs":[{"type":"bytes32[]","name":"poolIds","internalType":"bytes32[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"createPool","inputs":[{"type":"bytes32","name":"poolId","internalType":"bytes32"},{"type":"address","name":"tokenAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"deleteMatch","inputs":[{"type":"bytes32","name":"poolA","internalType":"bytes32"},{"type":"bytes32","name":"poolB","internalType":"bytes32"},{"type":"address","name":"foundsReceiver","internalType":"address"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"depositToPool","inputs":[{"type":"bytes32","name":"poolId","internalType":"bytes32"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"endMatch","inputs":[{"type":"bytes32","name":"poolA","internalType":"bytes32"},{"type":"bytes32","name":"poolB","internalType":"bytes32"},{"type":"bytes32","name":"winner","internalType":"bytes32"},{"type":"address[]","name":"players","internalType":"address[]"},{"type":"uint256[]","name":"shares","internalType":"uint256[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"endMatchAndClaimAndDelete","inputs":[{"type":"bytes32","name":"poolA","internalType":"bytes32"},{"type":"bytes32","name":"poolB","internalType":"bytes32"},{"type":"bytes32","name":"winner","internalType":"bytes32"},{"type":"address[]","name":"players","internalType":"address[]"},{"type":"uint256[]","name":"shares","internalType":"uint256[]"},{"type":"address","name":"foundsReceiver","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getContribution","inputs":[{"type":"bytes32","name":"poolId","internalType":"bytes32"},{"type":"address","name":"contributor","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getLoser","inputs":[{"type":"bytes32","name":"poolA","internalType":"bytes32"},{"type":"bytes32","name":"poolB","internalType":"bytes32"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getMatchId","inputs":[{"type":"bytes32","name":"poolA","internalType":"bytes32"},{"type":"bytes32","name":"poolB","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getPlayerShare","inputs":[{"type":"bytes32","name":"poolA","internalType":"bytes32"},{"type":"bytes32","name":"poolB","internalType":"bytes32"},{"type":"address","name":"player","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getPoolBalance","inputs":[{"type":"bytes32","name":"poolId","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"","internalType":"address[]"}],"name":"getPoolContributors","inputs":[{"type":"bytes32","name":"poolId","internalType":"bytes32"},{"type":"uint256","name":"_page","internalType":"uint256"},{"type":"uint256","name":"_pageSize","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getPoolMatchId","inputs":[{"type":"bytes32","name":"poolId","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getPoolRemainingFunds","inputs":[{"type":"bytes32","name":"poolId","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getStakerShare","inputs":[{"type":"bytes32","name":"poolId","internalType":"bytes32"},{"type":"address","name":"contributor","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isPoolDepositAllowed","inputs":[{"type":"bytes32","name":"poolId","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isPoolWithdrawalAllowed","inputs":[{"type":"bytes32","name":"poolId","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"isServiceFeeClaimed","internalType":"bool"}],"name":"matchClaimRecords","inputs":[{"type":"bytes32","name":"","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"poolA","internalType":"bytes32"},{"type":"bytes32","name":"poolB","internalType":"bytes32"},{"type":"bytes32","name":"winner","internalType":"bytes32"},{"type":"uint256","name":"totalFundsA","internalType":"uint256"},{"type":"uint256","name":"totalFundsB","internalType":"uint256"},{"type":"bool","name":"isActive","internalType":"bool"},{"type":"uint8","name":"state","internalType":"enum MatchManager.MatchState"}],"name":"matches","inputs":[{"type":"bytes32","name":"","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"playersPrizePercentage","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"creator","internalType":"address"},{"type":"address","name":"tokenAddress","internalType":"address"},{"type":"uint256","name":"totalFunds","internalType":"uint256"},{"type":"uint256","name":"remainingFunds","internalType":"uint256"},{"type":"bool","name":"isActive","internalType":"bool"},{"type":"uint8","name":"state","internalType":"enum PoolManager.PoolState"},{"type":"bytes32","name":"matchId","internalType":"bytes32"},{"type":"bool","name":"isDepositAllowed","internalType":"bool"},{"type":"bool","name":"isWithdrawalAllowed","internalType":"bool"}],"name":"pools","inputs":[{"type":"bytes32","name":"","internalType":"bytes32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"serviceFeePercentage","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setPoolDepositAllowed","inputs":[{"type":"bytes32","name":"poolId","internalType":"bytes32"},{"type":"bool","name":"isDepositAllowed","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setPoolState","inputs":[{"type":"bytes32","name":"poolId","internalType":"bytes32"},{"type":"uint8","name":"newState","internalType":"enum PoolManager.PoolState"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setPoolWithdrawalAllowed","inputs":[{"type":"bytes32","name":"poolId","internalType":"bytes32"},{"type":"bool","name":"isWithdrawalAllowed","internalType":"bool"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"stakersPrizePercentage","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawFromPool","inputs":[{"type":"bytes32","name":"poolId","internalType":"bytes32"},{"type":"uint256","name":"amount","internalType":"uint256"}]}]
Contract Creation Code
0x60806040526103e8600455611fa4600555610384600655612710600755348015602757600080fd5b503380604d57604051631e4fbdf760e01b81526000600482015260240160405180910390fd5b605481605d565b506001805560ad565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b613a1e806100bc6000396000f3fe6080604052600436106101ee5760003560e01c80639dc8cf731161010d578063c3a8574c116100a0578063ea7cfd8a1161006f578063ea7cfd8a1461069f578063eb239c91146106cf578063ef5672b6146106ef578063f2fde38b1461070f578063f6d735b21461072f57600080fd5b8063c3a8574c14610619578063c7d138cb1461062c578063c9b626741461064c578063dc81f1c81461066c57600080fd5b8063aacc4010116100dc578063aacc40101461053e578063b5217bb414610554578063bdec0221146105e3578063c0e046bc1461060357600080fd5b80639dc8cf73146104345780639fe9ada31461047c578063a1071aed146104ee578063a344d8431461050e57600080fd5b80636695c5b811610185578063788e39cd11610154578063788e39cd146103a95780638da5cb5b146103d6578063931d15a4146103f457806393bf45c61461041457600080fd5b80636695c5b81461031c578063670429841461033c578063715018a61461037457806371f58f151461038957600080fd5b80635abf8f85116101c15780635abf8f8514610299578063603ef649146102b957806366735fd8146102cf5780636693643f146102fc57600080fd5b806306a03645146101f35780634355b8d214610226578063550e6ed1146102465780635aa28f6c14610277575b600080fd5b3480156101ff57600080fd5b5061021361020e3660046132d4565b61075f565b6040519081526020015b60405180910390f35b34801561023257600080fd5b50610213610241366004613309565b61079d565b34801561025257600080fd5b5061021361026136600461332b565b6000908152600260208190526040909120015490565b34801561028357600080fd5b50610297610292366004613481565b6107da565b005b3480156102a557600080fd5b506102136102b4366004613309565b610869565b3480156102c557600080fd5b5061021360045481565b3480156102db57600080fd5b506102ef6102ea366004613507565b61094d565b60405161021d9190613533565b34801561030857600080fd5b5061021361031736600461357f565b610a57565b34801561032857600080fd5b50610297610337366004613309565b610a83565b34801561034857600080fd5b5061035c61035736600461357f565b610bc5565b6040516001600160a01b03909116815260200161021d565b34801561038057600080fd5b50610297610bd9565b34801561039557600080fd5b506102976103a43660046135b9565b610bed565b3480156103b557600080fd5b506103c96103c43660046135e9565b610bff565b60405161021d919061367f565b3480156103e257600080fd5b506000546001600160a01b031661035c565b34801561040057600080fd5b5061029761040f3660046135b9565b610fb3565b34801561042057600080fd5b5061029761042f366004613309565b61100e565b34801561044057600080fd5b5061046c61044f36600461332b565b600090815260026020526040902060080154610100900460ff1690565b604051901515815260200161021d565b34801561048857600080fd5b506104db61049736600461332b565b600360208190526000918252604090912080546001820154600283015493830154600484015460059094015492949193919290919060ff8082169161010090041687565b60405161021d97969594939291906136eb565b3480156104fa57600080fd5b50610297610509366004613731565b611313565b34801561051a57600080fd5b5061021361052936600461332b565b60009081526002602052604090206007015490565b34801561054a57600080fd5b5061021360055481565b34801561056057600080fd5b506105ce61056f36600461332b565b600260208190526000918252604090912080546001820154928201546003830154600484015460078501546008909501546001600160a01b0394851696909416949293919260ff80831693610100938490048216938183169291041689565b60405161021d9998979695949392919061375a565b3480156105ef57600080fd5b506102976105fe3660046137bc565b611325565b34801561060f57600080fd5b5061021360065481565b610297610627366004613309565b611456565b34801561063857600080fd5b5061021361064736600461357f565b6116d6565b34801561065857600080fd5b506102976106673660046135b9565b611739565b34801561067857600080fd5b5061046c61068736600461332b565b60009081526002602052604090206008015460ff1690565b3480156106ab57600080fd5b5061046c6106ba36600461332b565b60086020526000908152604090205460ff1681565b3480156106db57600080fd5b506102976106ea3660046132d4565b61178d565b3480156106fb57600080fd5b5061029761070a3660046135b9565b611832565b34801561071b57600080fd5b5061029761072a366004613851565b611844565b34801561073b57600080fd5b5061021361074a36600461332b565b60009081526002602052604090206003015490565b60008061076c8585610869565b60009081526003602090815260408083206001600160a01b03871684526006019091529020549150505b9392505050565b6000806107aa8484610869565b600081815260036020526040902060028101549192509085146107cd57846107cf565b835b925050505b92915050565b6107e2611882565b6107ed856002611313565b6107f8846002611313565b60006108048686610869565b905061081386868686866118af565b600061081f878761079d565b6000818152600260208190526040822090810154600190910154929350916108529085906001600160a01b031684611ad4565b905061085e8382611c84565b505050505050505050565b6000826108b15760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c1bdbdb0810481251607a1b60448201526064015b60405180910390fd5b816108f25760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c1bdbdb0810881251607a1b60448201526064016108a8565b60008284106109015782610903565b835b905060008385106109145784610916565b835b6040805160208101859052908101829052909150606001604051602081830303815290604052805190602001209250505092915050565b60008381526002602052604081206060916109688486613882565b905060006109768583613899565b600684015490915081111561098c575060068201545b600061099883836138ac565b67ffffffffffffffff8111156109b0576109b0613344565b6040519080825280602002602001820160405280156109d9578160200160208202803683370190505b509050825b82811015610a4b578460060181815481106109fb576109fb6138bf565b6000918252602090912001546001600160a01b031682610a1b86846138ac565b81518110610a2b57610a2b6138bf565b6001600160a01b03909216602092830291909101909101526001016109de565b50979650505050505050565b60008281526002602090815260408083206001600160a01b038516845260050190915290205492915050565b610a8b611cae565b6000610a978383610869565b600081815260036020526040902090915060026005820154610100900460ff166002811115610ac857610ac86136b7565b14610b095760405162461bcd60e51b815260206004820152601160248201527026b0ba31b41034b9903737ba1037bb32b960791b60448201526064016108a8565b60028101546000610b1a868661079d565b600081815260026020819052604082200154919250610b3a88883361075f565b90506000610b4885336116d6565b90506000610b568633610a57565b600087815260026020526040808220600190810154898452918320015492935090918291610b96918c916001600160a01b03908116911689898989611cd8565b91509150610ba48883611c84565b610bae8782611c84565b50505050505050505050610bc160018055565b5050565b6000610bcf611882565b61079683836120b7565b610be1611882565b610beb600061225e565b565b610bf5611882565b610bc18282610fb3565b6060610c09611882565b600282511015610c5b5760405162461bcd60e51b815260206004820152601960248201527f4174206c65617374203220706f6f6c732072657175697265640000000000000060448201526064016108a8565b60028251610c6991906138eb565b15610cb65760405162461bcd60e51b815260206004820152601e60248201527f506f6f6c206172726179206c656e677468206d757374206265206576656e000060448201526064016108a8565b600060028351610cc691906138ff565b67ffffffffffffffff811115610cde57610cde613344565b604051908082528060200260200182016040528015610d07578160200160208202803683370190505b50905060005b8351811015610faa576000848281518110610d2a57610d2a6138bf565b60200260200101519050600085836001610d449190613899565b81518110610d5457610d546138bf565b602090810291909101810151600084815260029092526040808320828452922060048301549193509060ff16610dcc5760405162461bcd60e51b815260206004820152601b60248201527f546f6b656e20706f6f6c204120646f6573206e6f74206578697374000000000060448201526064016108a8565b600481015460ff16610e205760405162461bcd60e51b815260206004820152601b60248201527f546f6b656e20706f6f6c204220646f6573206e6f74206578697374000000000060448201526064016108a8565b600782015415610e725760405162461bcd60e51b815260206004820152601960248201527f506f6f6c204120616c726561647920696e2061206d617463680000000000000060448201526064016108a8565b600781015415610ec45760405162461bcd60e51b815260206004820152601960248201527f506f6f6c204220616c726561647920696e2061206d617463680000000000000060448201526064016108a8565b828403610f0d5760405162461bcd60e51b8152602060048201526017602482015276141bdbdb1cc81b5d5cdd08189948191a5999995c995b9d604a1b60448201526064016108a8565b6000610f1985856122ae565b6000868152600260205260408082208783529120600780830184905581018390556004918201805461010061ff001991821681179092559290910180549092161790559050610f688585612443565b8087610f756002896138ff565b81518110610f8557610f856138bf565b6020026020010181815250505050505050600281610fa39190613899565b9050610d0d565b5090505b919050565b60008281526002602052604090206004015460ff16610fe45760405162461bcd60e51b81526004016108a890613913565b60009182526002602052604090912060080180549115156101000261ff0019909216919091179055565b611016611cae565b6000828152600260205260409020600481015460ff1661106d5760405162461bcd60e51b8152602060048201526012602482015271506f6f6c206973206e6f742061637469766560701b60448201526064016108a8565b6008810154610100900460ff166110c65760405162461bcd60e51b815260206004820152601b60248201527f5769746864726177616c7320617265206e6f7420616c6c6f776564000000000060448201526064016108a8565b600082116111165760405162461bcd60e51b815260206004820152601960248201527f4d75737420776974686472617720736f6d6520746f6b656e730000000000000060448201526064016108a8565b33600090815260058201602052604090205482111561116c5760405162461bcd60e51b8152602060048201526012602482015271496e73756666696369656e742066756e647360701b60448201526064016108a8565b8181600201600082825461118091906138ac565b9091555050336000908152600582016020526040812080548492906111a69084906138ac565b909155505060018101546001600160a01b031661122b57604051600090339084908381818185875af1925050503d80600081146111ff576040519150601f19603f3d011682016040523d82523d6000602084013e611204565b606091505b50509050806112255760405162461bcd60e51b81526004016108a890613940565b506112c2565b600181015460405163a9059cbb60e01b8152336004820152602481018490526001600160a01b0390911690819063a9059cbb906044016020604051808303816000875af1158015611280573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112a49190613969565b6112c05760405162461bcd60e51b81526004016108a890613940565b505b600181015460405183815233916001600160a01b03169085907f4cd16167afcd2e45cd70a8b10d891f374e85f259ef7afd1867fc9be7fcb11331906020015b60405180910390a450610bc160018055565b61131b611882565b610bc18282612569565b61132d611882565b611335611cae565b611340866002611313565b61134b856002611313565b60006113578787610869565b905061136687878787876118af565b6000611372888861079d565b6000818152600260208190526040822090810154600190910154929350916113a59085906001600160a01b031684611ad4565b90506113b18382611c84565b6113c0848b8b8b87878d61260b565b60008481526003602052604090206005015460ff16156114145760405162461bcd60e51b815260206004820152600f60248201526e4d617463682069732061637469766560881b60448201526064016108a8565b61141e8a86612720565b6114288986612720565b611431846128d2565b5050506000908152600860205260409020805460ff1916905560018055505050505050565b61145e611cae565b6000828152600260205260409020600481015460ff166114905760405162461bcd60e51b81526004016108a890613913565b600881015460ff166114e45760405162461bcd60e51b815260206004820152601860248201527f4465706f7369747320617265206e6f7420616c6c6f776564000000000000000060448201526064016108a8565b60018101546001600160a01b03166115425781341461153d5760405162461bcd60e51b81526020600482015260156024820152744d7573742073656e6420736f6d6520746f6b656e7360581b60448201526064016108a8565b611627565b6000821161158a5760405162461bcd60e51b81526020600482015260156024820152744d7573742073656e6420736f6d6520746f6b656e7360581b60448201526064016108a8565b60018101546040516323b872dd60e01b8152336004820152306024820152604481018490526001600160a01b039091169081906323b872dd906064016020604051808303816000875af11580156115e5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116099190613969565b6116255760405162461bcd60e51b81526004016108a890613940565b505b8181600201600082825461163b9190613899565b909155505033600090815260058201602052604081208054849290611661908490613899565b909155505060068101805460018181018355600092835260209092200180546001600160a01b03191633908117909155908201546040516001600160a01b03919091169085907fe40671b740fa5f78e7e7407dc9a0e028808df762f7f97020416b2ac647af2e3f906113019087815260200190565b60008281526002602081905260408220015481036116f6575060006107d4565b6000838152600260208181526040808420928301546001600160a01b038716855260059093019091529091205461172f90612710613882565b61079691906138ff565b60008281526002602052604090206004015460ff1661176a5760405162461bcd60e51b81526004016108a890613913565b600091825260026020526040909120600801805460ff1916911515919091179055565b611795611882565b60006117a18484610869565b60008181526003602052604090206005015490915060ff16156117f85760405162461bcd60e51b815260206004820152600f60248201526e4d617463682069732061637469766560881b60448201526064016108a8565b6118028483612720565b61180c8383612720565b611815816128d2565b6000818152600860205260409020805460ff191690555b50505050565b61183a611882565b610bc18282611739565b61184c611882565b6001600160a01b03811661187657604051631e4fbdf760e01b8152600060048201526024016108a8565b61187f8161225e565b50565b6000546001600160a01b03163314610beb5760405163118cdaa760e01b81523360048201526024016108a8565b60006118bb8686610869565b60008181526003602052604090206005015490915060ff166119165760405162461bcd60e51b815260206004820152601460248201527313585d18da08191bd95cc81b9bdd08195e1a5cdd60621b60448201526064016108a8565b6001600082815260036020526040902060050154610100900460ff166002811115611943576119436136b7565b146119885760405162461bcd60e51b81526020600482015260156024820152744d61746368206e6f7420696e2070726f677265737360581b60448201526064016108a8565b8584148061199557508484145b6119da5760405162461bcd60e51b8152602060048201526016602482015275496e76616c69642077696e6e6572206164647265737360501b60448201526064016108a8565b8151835114611a245760405162461bcd60e51b8152602060048201526016602482015275082e4e4c2f2e640d8cadccee8d040dad2e6dac2e8c6d60531b60448201526064016108a8565b6000835111611a6b5760405162461bcd60e51b8152602060048201526013602482015272139bc81c1b185e595c9cc81c1c9bdd9a591959606a1b60448201526064016108a8565b60008181526003602052604090206002810185905560058101805461ffff1916610200179055611a9c82858561294f565b8186887fee20e6cf265453dc32c716ce04a1c54c44b9616a1e738f217f515736509aa9dc60405160405180910390a450505050505050565b6000611ade611cae565b60008481526008602052604090205460ff1615611b0d5760405162461bcd60e51b81526004016108a890613986565b6000848152600860205260408120805460ff1916600117905560075460045484929190611b3a9084613882565b611b4491906138ff565b90506001600160a01b038516611bc257604051600090339083908381818185875af1925050503d8060008114611b96576040519150601f19603f3d011682016040523d82523d6000602084013e611b9b565b606091505b5050905080611bbc5760405162461bcd60e51b81526004016108a890613940565b50611c38565b60405163a9059cbb60e01b81523360048201526024810182905285906001600160a01b0382169063a9059cbb906044016020604051808303816000875af1158015611c11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c359190613969565b50505b6040518181526001600160a01b0386169033907ff0af9bc2c3a4716fef6ce079f5de916f018e0201e2f7052dfeae945801475b2f9060200160405180910390a391505061079660018055565b60008281526002602052604081206003018054839290611ca59084906138ac565b90915550505050565b600260015403611cd157604051633ee5aeb560e01b815260040160405180910390fd5b6002600155565b6000878152600860209081526040808320338452600101909152812054819060ff1615611d175760405162461bcd60e51b81526004016108a890613986565b600089815260086020908152604080832033845260020190915290205460ff1615611d545760405162461bcd60e51b81526004016108a890613986565b600089815260086020908152604080832033845260030190915290205460ff1615611d915760405162461bcd60e51b81526004016108a890613986565b600089815260086020908152604080832033845260018082018452828520805460ff1990811683179091556002830185528386208054821683179055600390920190935290832080549091169091179055611dec8786612bae565b90506000611dfa8888612be7565b90506001600160a01b038a16611e7857604051600090339087908381818185875af1925050503d8060008114611e4c576040519150601f19603f3d011682016040523d82523d6000602084013e611e51565b606091505b5050905080611e725760405162461bcd60e51b81526004016108a890613940565b50611eee565b60405163a9059cbb60e01b8152336004820152602481018690528a906001600160a01b0382169063a9059cbb906044016020604051808303816000875af1158015611ec7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eeb9190613969565b50505b6001600160a01b038916611f7157600033611f098385613899565b604051600081818185875af1925050503d8060008114611f45576040519150601f19603f3d011682016040523d82523d6000602084013e611f4a565b606091505b5050905080611f6b5760405162461bcd60e51b81526004016108a890613940565b50611ffe565b886001600160a01b03811663a9059cbb33611f8c8587613899565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303816000875af1158015611fd7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ffb9190613969565b50505b6040518581526001600160a01b038b169033906000805160206139c98339815191529060200160405180910390a36040518281526001600160a01b038a169033906000805160206139c98339815191529060200160405180910390a36040518181526001600160a01b038a169033907fde02534236523c2e02492e6cfc4cd7cc6003b1891460f414626d77e7c867551f9060200160405180910390a3846120a58284613899565b93509350505097509795505050505050565b60008281526002602052604081206004015460ff161561210f5760405162461bcd60e51b8152602060048201526013602482015272506f6f6c20616c72656164792065786973747360681b60448201526064016108a8565b6001600160a01b038216156121ce5760008290506000816001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612163573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061218791906139af565b116121cc5760405162461bcd60e51b8152602060048201526015602482015274496e76616c696420746f6b656e206164647265737360581b60448201526064016108a8565b505b60008381526002602052604080822080546001600160a01b0319908116339081178355600180840180546001600160a01b038a1694168417905560048401805461ffff199081169092179055600884018054610101921691909117905592519193909187917fc0c143d18100b0ec0b6c08cc52247dd860ffd3fc2af30733326e5f980c19635a91a4509092915050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60008183036122f95760405162461bcd60e51b8152602060048201526017602482015276141bdbdb1cc81b5d5cdd08189948191a5999995c995b9d604a1b60448201526064016108a8565b8261233a5760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c1bdbdb0810481251607a1b60448201526064016108a8565b8161237b5760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c1bdbdb0810881251607a1b60448201526064016108a8565b60006123878484610869565b60008181526003602052604090206005015490915060ff16156123e35760405162461bcd60e51b81526020600482015260146024820152734d6174636820616c72656164792065786973747360601b60448201526064016108a8565b600081815260036020526040808220868155600180820187905560058201805461ffff19169091179055905190918391869188917ff94047cb2b767481be8aad8cae3c3ce5f432cfe8dd7b23f50e3d18648b4a7b959190a4509392505050565b600061244f8383610869565b60008181526003602052604090206005015490915060ff166124aa5760405162461bcd60e51b815260206004820152601460248201527313585d18da08191bd95cc81b9bdd08195e1a5cdd60621b60448201526064016108a8565b60008082815260036020526040902060050154610100900460ff1660028111156124d6576124d66136b7565b1461251b5760405162461bcd60e51b815260206004820152601560248201527413585d18da08185b1c9958591e481cdd185c9d1959605a1b60448201526064016108a8565b600081815260036020526040808220600501805461ff001916610100179055518291849186917f29d26f27771059d3fdf99a7ea828394ca3980824b18f47ba9959beb3e9f3d87391a4505050565b60008281526002602052604090206004015460ff1661259a5760405162461bcd60e51b81526004016108a890613913565b60008281526002602081905260409091206004018054839261ff0019909116906101009084908111156125cf576125cf6136b7565b021790555060028160028111156125e8576125e86136b7565b03610bc15750600090815260026020819052604090912090810154600390910155565b6000848152600260205260408120905b600682015481101561269157600082600601828154811061263e5761263e6138bf565b60009182526020808320909101548983526002825260408084206001600160a01b03909216808552600590920190925291205490915015612688576126888a8a8a8a8a8a87612bf8565b5060010161261b565b5060005b825181101561085e5760008382815181106126b2576126b26138bf565b6020026020010151905060006126c98a8a8461075f565b9050600081118015612701575060008b81526008602090815260408083206001600160a01b038616845260030190915290205460ff16155b15612716576127168b8b8b8b8b8b8888613000565b5050600101612695565b600082815260026020526040902060038101546001909101546001600160a01b03166127bf576000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612793576040519150601f19603f3d011682016040523d82523d6000602084013e612798565b606091505b50509050806127b95760405162461bcd60e51b81526004016108a890613940565b50612866565b6000838152600260205260409081902060010154905163a9059cbb60e01b81526001600160a01b0384811660048301526024820184905290911690819063a9059cbb906044016020604051808303816000875af1158015612824573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128489190613969565b6128645760405162461bcd60e51b81526004016108a890613940565b505b6000838152600260208190526040822080546001600160a01b0319908116825560018201805490911690559081018290556003810182905560048101805461ffff19169055906128b9600683018261328b565b5060006007820155600801805461ffff19169055505050565b806129125760405162461bcd60e51b815260206004820152601060248201526f125b9d985b1a59081b585d18da08125160821b60448201526064016108a8565b6000908152600360208190526040822082815560018101839055600281018390559081018290556004810191909155600501805461ffff19169055565b80518251146129995760405162461bcd60e51b8152602060048201526016602482015275082e4e4c2f2e640d8cadccee8d040dad2e6dac2e8c6d60531b60448201526064016108a8565b60008251116129d95760405162461bcd60e51b815260206004820152600c60248201526b456d7074792061727261797360a01b60448201526064016108a8565b600083815260036020526040812090805b8451811015612b555760006001600160a01b0316858281518110612a1057612a106138bf565b60200260200101516001600160a01b031603612a675760405162461bcd60e51b8152602060048201526016602482015275496e76616c696420706c61796572206164647265737360501b60448201526064016108a8565b6000848281518110612a7b57612a7b6138bf565b602002602001015111612ad05760405162461bcd60e51b815260206004820152601860248201527f496e76616c69642073686172652070657263656e74616765000000000000000060448201526064016108a8565b838181518110612ae257612ae26138bf565b602002602001015182612af59190613899565b9150838181518110612b0957612b096138bf565b6020026020010151836006016000878481518110612b2957612b296138bf565b6020908102919091018101516001600160a01b03168252810191909152604001600020556001016129ea565b508061271014612ba75760405162461bcd60e51b815260206004820152601960248201527f546f74616c20736861726573206d75737420626520313030250000000000000060448201526064016108a8565b5050505050565b60008060055484612bbf9190613882565b90506000600754600754612bd39190613882565b612bdd8584613882565b6107cf91906138ff565b60008060065484612bbf9190613882565b6000612c048787610869565b60008181526008602090815260408083206001600160a01b038716845260010190915290205490915060ff1615612c4d5760405162461bcd60e51b81526004016108a890613986565b60008181526008602090815260408083206001600160a01b038616845260020190915290205460ff1615612c935760405162461bcd60e51b81526004016108a890613986565b60008181526008602090815260408083206001600160a01b038616845260018082018452828520805460ff199081168317909155600290920190935290832080549091169091179055612ce788888561075f565b90508015612d205760008281526008602090815260408083206001600160a01b03871684526003019091529020805460ff191660011790555b6000612d2c87856116d6565b90506000612d3a8886610a57565b90506000612d488784612bae565b905060008415612d5f57612d5c8886612be7565b90505b60008a8152600260205260409020600101546001600160a01b0316612df7576000876001600160a01b03168460405160006040518083038185875af1925050503d8060008114612dcb576040519150601f19603f3d011682016040523d82523d6000602084013e612dd0565b606091505b5050905080612df15760405162461bcd60e51b81526004016108a890613940565b50612e1f565b60008a8152600260205260409020600101546001600160a01b0316612e1d8189866131c3565b505b6000612e2b8284613899565b90508015612ef35760008a8152600260205260409020600101546001600160a01b0316612ecb576000886001600160a01b03168260405160006040518083038185875af1925050503d8060008114612e9f576040519150601f19603f3d011682016040523d82523d6000602084013e612ea4565b606091505b5050905080612ec55760405162461bcd60e51b81526004016108a890613940565b50612ef3565b60008a8152600260205260409020600101546001600160a01b0316612ef1818a846131c3565b505b612efd8b85611c84565b612f078a82611c84565b60008b8152600260209081526040918290206001015491518681526001600160a01b03928316928b16916000805160206139c9833981519152910160405180910390a38215612f945760008a8152600260209081526040918290206001015491518581526001600160a01b03928316928b16916000805160206139c9833981519152910160405180910390a35b8115612ff05760008a8152600260209081526040918290206001015491518481526001600160a01b03928316928b16917fde02534236523c2e02492e6cfc4cd7cc6003b1891460f414626d77e7c867551f910160405180910390a35b5050505050505050505050505050565b600061300c8888610869565b60008181526008602090815260408083206001600160a01b038816845260030190915290205490915060ff16156130555760405162461bcd60e51b81526004016108a890613986565b60008181526008602090815260408083206001600160a01b03871684526003019091528120805460ff1916600117905561308f8584612be7565b905080156131b7576000868152600260205260409020600101546001600160a01b031661312f576000846001600160a01b03168260405160006040518083038185875af1925050503d8060008114613103576040519150601f19603f3d011682016040523d82523d6000602084013e613108565b606091505b50509050806131295760405162461bcd60e51b81526004016108a890613940565b50613157565b6000868152600260205260409020600101546001600160a01b03166131558186846131c3565b505b6131618682611c84565b6000868152600260209081526040918290206001015491518381526001600160a01b03928316928716917fde02534236523c2e02492e6cfc4cd7cc6003b1891460f414626d77e7c867551f910160405180910390a35b50505050505050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261321590849061321a565b505050565b600080602060008451602086016000885af18061323d576040513d6000823e3d81fd5b50506000513d91508115613255578060011415613262565b6001600160a01b0384163b155b1561182c57604051635274afe760e01b81526001600160a01b03851660048201526024016108a8565b508054600082559060005260206000209081019061187f91905b808211156132b957600081556001016132a5565b5090565b80356001600160a01b0381168114610fae57600080fd5b6000806000606084860312156132e957600080fd5b8335925060208401359150613300604085016132bd565b90509250925092565b6000806040838503121561331c57600080fd5b50508035926020909101359150565b60006020828403121561333d57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561338357613383613344565b604052919050565b600067ffffffffffffffff8211156133a5576133a5613344565b5060051b60200190565b600082601f8301126133c057600080fd5b81356133d36133ce8261338b565b61335a565b8082825260208201915060208360051b8601019250858311156133f557600080fd5b602085015b838110156134195761340b816132bd565b8352602092830192016133fa565b5095945050505050565b600082601f83011261343457600080fd5b81356134426133ce8261338b565b8082825260208201915060208360051b86010192508583111561346457600080fd5b602085015b83811015613419578035835260209283019201613469565b600080600080600060a0868803121561349957600080fd5b853594506020860135935060408601359250606086013567ffffffffffffffff8111156134c557600080fd5b6134d1888289016133af565b925050608086013567ffffffffffffffff8111156134ee57600080fd5b6134fa88828901613423565b9150509295509295909350565b60008060006060848603121561351c57600080fd5b505081359360208301359350604090920135919050565b602080825282518282018190526000918401906040840190835b818110156135745783516001600160a01b031683526020938401939092019160010161354d565b509095945050505050565b6000806040838503121561359257600080fd5b823591506135a2602084016132bd565b90509250929050565b801515811461187f57600080fd5b600080604083850312156135cc57600080fd5b8235915060208301356135de816135ab565b809150509250929050565b6000602082840312156135fb57600080fd5b813567ffffffffffffffff81111561361257600080fd5b8201601f8101841361362357600080fd5b80356136316133ce8261338b565b8082825260208201915060208360051b85010192508683111561365357600080fd5b6020840193505b8284101561367557833582526020938401939091019061365a565b9695505050505050565b602080825282518282018190526000918401906040840190835b81811015613574578351835260209384019390920191600101613699565b634e487b7160e01b600052602160045260246000fd5b6003811061187f57634e487b7160e01b600052602160045260246000fd5b600060e08201905088825287602083015286604083015285606083015284608083015283151560a083015261371f836136cd565b8260c083015298975050505050505050565b6000806040838503121561374457600080fd5b823591506020830135600381106135de57600080fd5b6001600160a01b038a8116825289166020820152604081018890526060810187905285151560808201526101208101613792866136cd565b60a082019590955260c081019390935290151560e083015215156101009091015295945050505050565b60008060008060008060c087890312156137d557600080fd5b863595506020870135945060408701359350606087013567ffffffffffffffff81111561380157600080fd5b61380d89828a016133af565b935050608087013567ffffffffffffffff81111561382a57600080fd5b61383689828a01613423565b92505061384560a088016132bd565b90509295509295509295565b60006020828403121561386357600080fd5b610796826132bd565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176107d4576107d461386c565b808201808211156107d4576107d461386c565b818103818111156107d4576107d461386c565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601260045260246000fd5b6000826138fa576138fa6138d5565b500690565b60008261390e5761390e6138d5565b500490565b602080825260139082015272141bdbdb08191bd95cc81b9bdd08195e1a5cdd606a1b604082015260600190565b6020808252600f908201526e151c985b9cd9995c8819985a5b1959608a1b604082015260600190565b60006020828403121561397b57600080fd5b8151610796816135ab565b6020808252600f908201526e105b1c9958591e4818db185a5b5959608a1b604082015260600190565b6000602082840312156139c157600080fd5b505191905056fe691d3da84f60a8e9f7618970b6df07a3a18b47254d483e44e071f50e8c3cbbfaa2646970667358221220cf1c04ccf4f1edd65e55aa003e4727b8b631b8254b40775c6ae070c45708427464736f6c634300081c0033
Deployed ByteCode
0x6080604052600436106101ee5760003560e01c80639dc8cf731161010d578063c3a8574c116100a0578063ea7cfd8a1161006f578063ea7cfd8a1461069f578063eb239c91146106cf578063ef5672b6146106ef578063f2fde38b1461070f578063f6d735b21461072f57600080fd5b8063c3a8574c14610619578063c7d138cb1461062c578063c9b626741461064c578063dc81f1c81461066c57600080fd5b8063aacc4010116100dc578063aacc40101461053e578063b5217bb414610554578063bdec0221146105e3578063c0e046bc1461060357600080fd5b80639dc8cf73146104345780639fe9ada31461047c578063a1071aed146104ee578063a344d8431461050e57600080fd5b80636695c5b811610185578063788e39cd11610154578063788e39cd146103a95780638da5cb5b146103d6578063931d15a4146103f457806393bf45c61461041457600080fd5b80636695c5b81461031c578063670429841461033c578063715018a61461037457806371f58f151461038957600080fd5b80635abf8f85116101c15780635abf8f8514610299578063603ef649146102b957806366735fd8146102cf5780636693643f146102fc57600080fd5b806306a03645146101f35780634355b8d214610226578063550e6ed1146102465780635aa28f6c14610277575b600080fd5b3480156101ff57600080fd5b5061021361020e3660046132d4565b61075f565b6040519081526020015b60405180910390f35b34801561023257600080fd5b50610213610241366004613309565b61079d565b34801561025257600080fd5b5061021361026136600461332b565b6000908152600260208190526040909120015490565b34801561028357600080fd5b50610297610292366004613481565b6107da565b005b3480156102a557600080fd5b506102136102b4366004613309565b610869565b3480156102c557600080fd5b5061021360045481565b3480156102db57600080fd5b506102ef6102ea366004613507565b61094d565b60405161021d9190613533565b34801561030857600080fd5b5061021361031736600461357f565b610a57565b34801561032857600080fd5b50610297610337366004613309565b610a83565b34801561034857600080fd5b5061035c61035736600461357f565b610bc5565b6040516001600160a01b03909116815260200161021d565b34801561038057600080fd5b50610297610bd9565b34801561039557600080fd5b506102976103a43660046135b9565b610bed565b3480156103b557600080fd5b506103c96103c43660046135e9565b610bff565b60405161021d919061367f565b3480156103e257600080fd5b506000546001600160a01b031661035c565b34801561040057600080fd5b5061029761040f3660046135b9565b610fb3565b34801561042057600080fd5b5061029761042f366004613309565b61100e565b34801561044057600080fd5b5061046c61044f36600461332b565b600090815260026020526040902060080154610100900460ff1690565b604051901515815260200161021d565b34801561048857600080fd5b506104db61049736600461332b565b600360208190526000918252604090912080546001820154600283015493830154600484015460059094015492949193919290919060ff8082169161010090041687565b60405161021d97969594939291906136eb565b3480156104fa57600080fd5b50610297610509366004613731565b611313565b34801561051a57600080fd5b5061021361052936600461332b565b60009081526002602052604090206007015490565b34801561054a57600080fd5b5061021360055481565b34801561056057600080fd5b506105ce61056f36600461332b565b600260208190526000918252604090912080546001820154928201546003830154600484015460078501546008909501546001600160a01b0394851696909416949293919260ff80831693610100938490048216938183169291041689565b60405161021d9998979695949392919061375a565b3480156105ef57600080fd5b506102976105fe3660046137bc565b611325565b34801561060f57600080fd5b5061021360065481565b610297610627366004613309565b611456565b34801561063857600080fd5b5061021361064736600461357f565b6116d6565b34801561065857600080fd5b506102976106673660046135b9565b611739565b34801561067857600080fd5b5061046c61068736600461332b565b60009081526002602052604090206008015460ff1690565b3480156106ab57600080fd5b5061046c6106ba36600461332b565b60086020526000908152604090205460ff1681565b3480156106db57600080fd5b506102976106ea3660046132d4565b61178d565b3480156106fb57600080fd5b5061029761070a3660046135b9565b611832565b34801561071b57600080fd5b5061029761072a366004613851565b611844565b34801561073b57600080fd5b5061021361074a36600461332b565b60009081526002602052604090206003015490565b60008061076c8585610869565b60009081526003602090815260408083206001600160a01b03871684526006019091529020549150505b9392505050565b6000806107aa8484610869565b600081815260036020526040902060028101549192509085146107cd57846107cf565b835b925050505b92915050565b6107e2611882565b6107ed856002611313565b6107f8846002611313565b60006108048686610869565b905061081386868686866118af565b600061081f878761079d565b6000818152600260208190526040822090810154600190910154929350916108529085906001600160a01b031684611ad4565b905061085e8382611c84565b505050505050505050565b6000826108b15760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c1bdbdb0810481251607a1b60448201526064015b60405180910390fd5b816108f25760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c1bdbdb0810881251607a1b60448201526064016108a8565b60008284106109015782610903565b835b905060008385106109145784610916565b835b6040805160208101859052908101829052909150606001604051602081830303815290604052805190602001209250505092915050565b60008381526002602052604081206060916109688486613882565b905060006109768583613899565b600684015490915081111561098c575060068201545b600061099883836138ac565b67ffffffffffffffff8111156109b0576109b0613344565b6040519080825280602002602001820160405280156109d9578160200160208202803683370190505b509050825b82811015610a4b578460060181815481106109fb576109fb6138bf565b6000918252602090912001546001600160a01b031682610a1b86846138ac565b81518110610a2b57610a2b6138bf565b6001600160a01b03909216602092830291909101909101526001016109de565b50979650505050505050565b60008281526002602090815260408083206001600160a01b038516845260050190915290205492915050565b610a8b611cae565b6000610a978383610869565b600081815260036020526040902090915060026005820154610100900460ff166002811115610ac857610ac86136b7565b14610b095760405162461bcd60e51b815260206004820152601160248201527026b0ba31b41034b9903737ba1037bb32b960791b60448201526064016108a8565b60028101546000610b1a868661079d565b600081815260026020819052604082200154919250610b3a88883361075f565b90506000610b4885336116d6565b90506000610b568633610a57565b600087815260026020526040808220600190810154898452918320015492935090918291610b96918c916001600160a01b03908116911689898989611cd8565b91509150610ba48883611c84565b610bae8782611c84565b50505050505050505050610bc160018055565b5050565b6000610bcf611882565b61079683836120b7565b610be1611882565b610beb600061225e565b565b610bf5611882565b610bc18282610fb3565b6060610c09611882565b600282511015610c5b5760405162461bcd60e51b815260206004820152601960248201527f4174206c65617374203220706f6f6c732072657175697265640000000000000060448201526064016108a8565b60028251610c6991906138eb565b15610cb65760405162461bcd60e51b815260206004820152601e60248201527f506f6f6c206172726179206c656e677468206d757374206265206576656e000060448201526064016108a8565b600060028351610cc691906138ff565b67ffffffffffffffff811115610cde57610cde613344565b604051908082528060200260200182016040528015610d07578160200160208202803683370190505b50905060005b8351811015610faa576000848281518110610d2a57610d2a6138bf565b60200260200101519050600085836001610d449190613899565b81518110610d5457610d546138bf565b602090810291909101810151600084815260029092526040808320828452922060048301549193509060ff16610dcc5760405162461bcd60e51b815260206004820152601b60248201527f546f6b656e20706f6f6c204120646f6573206e6f74206578697374000000000060448201526064016108a8565b600481015460ff16610e205760405162461bcd60e51b815260206004820152601b60248201527f546f6b656e20706f6f6c204220646f6573206e6f74206578697374000000000060448201526064016108a8565b600782015415610e725760405162461bcd60e51b815260206004820152601960248201527f506f6f6c204120616c726561647920696e2061206d617463680000000000000060448201526064016108a8565b600781015415610ec45760405162461bcd60e51b815260206004820152601960248201527f506f6f6c204220616c726561647920696e2061206d617463680000000000000060448201526064016108a8565b828403610f0d5760405162461bcd60e51b8152602060048201526017602482015276141bdbdb1cc81b5d5cdd08189948191a5999995c995b9d604a1b60448201526064016108a8565b6000610f1985856122ae565b6000868152600260205260408082208783529120600780830184905581018390556004918201805461010061ff001991821681179092559290910180549092161790559050610f688585612443565b8087610f756002896138ff565b81518110610f8557610f856138bf565b6020026020010181815250505050505050600281610fa39190613899565b9050610d0d565b5090505b919050565b60008281526002602052604090206004015460ff16610fe45760405162461bcd60e51b81526004016108a890613913565b60009182526002602052604090912060080180549115156101000261ff0019909216919091179055565b611016611cae565b6000828152600260205260409020600481015460ff1661106d5760405162461bcd60e51b8152602060048201526012602482015271506f6f6c206973206e6f742061637469766560701b60448201526064016108a8565b6008810154610100900460ff166110c65760405162461bcd60e51b815260206004820152601b60248201527f5769746864726177616c7320617265206e6f7420616c6c6f776564000000000060448201526064016108a8565b600082116111165760405162461bcd60e51b815260206004820152601960248201527f4d75737420776974686472617720736f6d6520746f6b656e730000000000000060448201526064016108a8565b33600090815260058201602052604090205482111561116c5760405162461bcd60e51b8152602060048201526012602482015271496e73756666696369656e742066756e647360701b60448201526064016108a8565b8181600201600082825461118091906138ac565b9091555050336000908152600582016020526040812080548492906111a69084906138ac565b909155505060018101546001600160a01b031661122b57604051600090339084908381818185875af1925050503d80600081146111ff576040519150601f19603f3d011682016040523d82523d6000602084013e611204565b606091505b50509050806112255760405162461bcd60e51b81526004016108a890613940565b506112c2565b600181015460405163a9059cbb60e01b8152336004820152602481018490526001600160a01b0390911690819063a9059cbb906044016020604051808303816000875af1158015611280573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112a49190613969565b6112c05760405162461bcd60e51b81526004016108a890613940565b505b600181015460405183815233916001600160a01b03169085907f4cd16167afcd2e45cd70a8b10d891f374e85f259ef7afd1867fc9be7fcb11331906020015b60405180910390a450610bc160018055565b61131b611882565b610bc18282612569565b61132d611882565b611335611cae565b611340866002611313565b61134b856002611313565b60006113578787610869565b905061136687878787876118af565b6000611372888861079d565b6000818152600260208190526040822090810154600190910154929350916113a59085906001600160a01b031684611ad4565b90506113b18382611c84565b6113c0848b8b8b87878d61260b565b60008481526003602052604090206005015460ff16156114145760405162461bcd60e51b815260206004820152600f60248201526e4d617463682069732061637469766560881b60448201526064016108a8565b61141e8a86612720565b6114288986612720565b611431846128d2565b5050506000908152600860205260409020805460ff1916905560018055505050505050565b61145e611cae565b6000828152600260205260409020600481015460ff166114905760405162461bcd60e51b81526004016108a890613913565b600881015460ff166114e45760405162461bcd60e51b815260206004820152601860248201527f4465706f7369747320617265206e6f7420616c6c6f776564000000000000000060448201526064016108a8565b60018101546001600160a01b03166115425781341461153d5760405162461bcd60e51b81526020600482015260156024820152744d7573742073656e6420736f6d6520746f6b656e7360581b60448201526064016108a8565b611627565b6000821161158a5760405162461bcd60e51b81526020600482015260156024820152744d7573742073656e6420736f6d6520746f6b656e7360581b60448201526064016108a8565b60018101546040516323b872dd60e01b8152336004820152306024820152604481018490526001600160a01b039091169081906323b872dd906064016020604051808303816000875af11580156115e5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116099190613969565b6116255760405162461bcd60e51b81526004016108a890613940565b505b8181600201600082825461163b9190613899565b909155505033600090815260058201602052604081208054849290611661908490613899565b909155505060068101805460018181018355600092835260209092200180546001600160a01b03191633908117909155908201546040516001600160a01b03919091169085907fe40671b740fa5f78e7e7407dc9a0e028808df762f7f97020416b2ac647af2e3f906113019087815260200190565b60008281526002602081905260408220015481036116f6575060006107d4565b6000838152600260208181526040808420928301546001600160a01b038716855260059093019091529091205461172f90612710613882565b61079691906138ff565b60008281526002602052604090206004015460ff1661176a5760405162461bcd60e51b81526004016108a890613913565b600091825260026020526040909120600801805460ff1916911515919091179055565b611795611882565b60006117a18484610869565b60008181526003602052604090206005015490915060ff16156117f85760405162461bcd60e51b815260206004820152600f60248201526e4d617463682069732061637469766560881b60448201526064016108a8565b6118028483612720565b61180c8383612720565b611815816128d2565b6000818152600860205260409020805460ff191690555b50505050565b61183a611882565b610bc18282611739565b61184c611882565b6001600160a01b03811661187657604051631e4fbdf760e01b8152600060048201526024016108a8565b61187f8161225e565b50565b6000546001600160a01b03163314610beb5760405163118cdaa760e01b81523360048201526024016108a8565b60006118bb8686610869565b60008181526003602052604090206005015490915060ff166119165760405162461bcd60e51b815260206004820152601460248201527313585d18da08191bd95cc81b9bdd08195e1a5cdd60621b60448201526064016108a8565b6001600082815260036020526040902060050154610100900460ff166002811115611943576119436136b7565b146119885760405162461bcd60e51b81526020600482015260156024820152744d61746368206e6f7420696e2070726f677265737360581b60448201526064016108a8565b8584148061199557508484145b6119da5760405162461bcd60e51b8152602060048201526016602482015275496e76616c69642077696e6e6572206164647265737360501b60448201526064016108a8565b8151835114611a245760405162461bcd60e51b8152602060048201526016602482015275082e4e4c2f2e640d8cadccee8d040dad2e6dac2e8c6d60531b60448201526064016108a8565b6000835111611a6b5760405162461bcd60e51b8152602060048201526013602482015272139bc81c1b185e595c9cc81c1c9bdd9a591959606a1b60448201526064016108a8565b60008181526003602052604090206002810185905560058101805461ffff1916610200179055611a9c82858561294f565b8186887fee20e6cf265453dc32c716ce04a1c54c44b9616a1e738f217f515736509aa9dc60405160405180910390a450505050505050565b6000611ade611cae565b60008481526008602052604090205460ff1615611b0d5760405162461bcd60e51b81526004016108a890613986565b6000848152600860205260408120805460ff1916600117905560075460045484929190611b3a9084613882565b611b4491906138ff565b90506001600160a01b038516611bc257604051600090339083908381818185875af1925050503d8060008114611b96576040519150601f19603f3d011682016040523d82523d6000602084013e611b9b565b606091505b5050905080611bbc5760405162461bcd60e51b81526004016108a890613940565b50611c38565b60405163a9059cbb60e01b81523360048201526024810182905285906001600160a01b0382169063a9059cbb906044016020604051808303816000875af1158015611c11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c359190613969565b50505b6040518181526001600160a01b0386169033907ff0af9bc2c3a4716fef6ce079f5de916f018e0201e2f7052dfeae945801475b2f9060200160405180910390a391505061079660018055565b60008281526002602052604081206003018054839290611ca59084906138ac565b90915550505050565b600260015403611cd157604051633ee5aeb560e01b815260040160405180910390fd5b6002600155565b6000878152600860209081526040808320338452600101909152812054819060ff1615611d175760405162461bcd60e51b81526004016108a890613986565b600089815260086020908152604080832033845260020190915290205460ff1615611d545760405162461bcd60e51b81526004016108a890613986565b600089815260086020908152604080832033845260030190915290205460ff1615611d915760405162461bcd60e51b81526004016108a890613986565b600089815260086020908152604080832033845260018082018452828520805460ff1990811683179091556002830185528386208054821683179055600390920190935290832080549091169091179055611dec8786612bae565b90506000611dfa8888612be7565b90506001600160a01b038a16611e7857604051600090339087908381818185875af1925050503d8060008114611e4c576040519150601f19603f3d011682016040523d82523d6000602084013e611e51565b606091505b5050905080611e725760405162461bcd60e51b81526004016108a890613940565b50611eee565b60405163a9059cbb60e01b8152336004820152602481018690528a906001600160a01b0382169063a9059cbb906044016020604051808303816000875af1158015611ec7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eeb9190613969565b50505b6001600160a01b038916611f7157600033611f098385613899565b604051600081818185875af1925050503d8060008114611f45576040519150601f19603f3d011682016040523d82523d6000602084013e611f4a565b606091505b5050905080611f6b5760405162461bcd60e51b81526004016108a890613940565b50611ffe565b886001600160a01b03811663a9059cbb33611f8c8587613899565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303816000875af1158015611fd7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ffb9190613969565b50505b6040518581526001600160a01b038b169033906000805160206139c98339815191529060200160405180910390a36040518281526001600160a01b038a169033906000805160206139c98339815191529060200160405180910390a36040518181526001600160a01b038a169033907fde02534236523c2e02492e6cfc4cd7cc6003b1891460f414626d77e7c867551f9060200160405180910390a3846120a58284613899565b93509350505097509795505050505050565b60008281526002602052604081206004015460ff161561210f5760405162461bcd60e51b8152602060048201526013602482015272506f6f6c20616c72656164792065786973747360681b60448201526064016108a8565b6001600160a01b038216156121ce5760008290506000816001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612163573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061218791906139af565b116121cc5760405162461bcd60e51b8152602060048201526015602482015274496e76616c696420746f6b656e206164647265737360581b60448201526064016108a8565b505b60008381526002602052604080822080546001600160a01b0319908116339081178355600180840180546001600160a01b038a1694168417905560048401805461ffff199081169092179055600884018054610101921691909117905592519193909187917fc0c143d18100b0ec0b6c08cc52247dd860ffd3fc2af30733326e5f980c19635a91a4509092915050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60008183036122f95760405162461bcd60e51b8152602060048201526017602482015276141bdbdb1cc81b5d5cdd08189948191a5999995c995b9d604a1b60448201526064016108a8565b8261233a5760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c1bdbdb0810481251607a1b60448201526064016108a8565b8161237b5760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c1bdbdb0810881251607a1b60448201526064016108a8565b60006123878484610869565b60008181526003602052604090206005015490915060ff16156123e35760405162461bcd60e51b81526020600482015260146024820152734d6174636820616c72656164792065786973747360601b60448201526064016108a8565b600081815260036020526040808220868155600180820187905560058201805461ffff19169091179055905190918391869188917ff94047cb2b767481be8aad8cae3c3ce5f432cfe8dd7b23f50e3d18648b4a7b959190a4509392505050565b600061244f8383610869565b60008181526003602052604090206005015490915060ff166124aa5760405162461bcd60e51b815260206004820152601460248201527313585d18da08191bd95cc81b9bdd08195e1a5cdd60621b60448201526064016108a8565b60008082815260036020526040902060050154610100900460ff1660028111156124d6576124d66136b7565b1461251b5760405162461bcd60e51b815260206004820152601560248201527413585d18da08185b1c9958591e481cdd185c9d1959605a1b60448201526064016108a8565b600081815260036020526040808220600501805461ff001916610100179055518291849186917f29d26f27771059d3fdf99a7ea828394ca3980824b18f47ba9959beb3e9f3d87391a4505050565b60008281526002602052604090206004015460ff1661259a5760405162461bcd60e51b81526004016108a890613913565b60008281526002602081905260409091206004018054839261ff0019909116906101009084908111156125cf576125cf6136b7565b021790555060028160028111156125e8576125e86136b7565b03610bc15750600090815260026020819052604090912090810154600390910155565b6000848152600260205260408120905b600682015481101561269157600082600601828154811061263e5761263e6138bf565b60009182526020808320909101548983526002825260408084206001600160a01b03909216808552600590920190925291205490915015612688576126888a8a8a8a8a8a87612bf8565b5060010161261b565b5060005b825181101561085e5760008382815181106126b2576126b26138bf565b6020026020010151905060006126c98a8a8461075f565b9050600081118015612701575060008b81526008602090815260408083206001600160a01b038616845260030190915290205460ff16155b15612716576127168b8b8b8b8b8b8888613000565b5050600101612695565b600082815260026020526040902060038101546001909101546001600160a01b03166127bf576000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612793576040519150601f19603f3d011682016040523d82523d6000602084013e612798565b606091505b50509050806127b95760405162461bcd60e51b81526004016108a890613940565b50612866565b6000838152600260205260409081902060010154905163a9059cbb60e01b81526001600160a01b0384811660048301526024820184905290911690819063a9059cbb906044016020604051808303816000875af1158015612824573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128489190613969565b6128645760405162461bcd60e51b81526004016108a890613940565b505b6000838152600260208190526040822080546001600160a01b0319908116825560018201805490911690559081018290556003810182905560048101805461ffff19169055906128b9600683018261328b565b5060006007820155600801805461ffff19169055505050565b806129125760405162461bcd60e51b815260206004820152601060248201526f125b9d985b1a59081b585d18da08125160821b60448201526064016108a8565b6000908152600360208190526040822082815560018101839055600281018390559081018290556004810191909155600501805461ffff19169055565b80518251146129995760405162461bcd60e51b8152602060048201526016602482015275082e4e4c2f2e640d8cadccee8d040dad2e6dac2e8c6d60531b60448201526064016108a8565b60008251116129d95760405162461bcd60e51b815260206004820152600c60248201526b456d7074792061727261797360a01b60448201526064016108a8565b600083815260036020526040812090805b8451811015612b555760006001600160a01b0316858281518110612a1057612a106138bf565b60200260200101516001600160a01b031603612a675760405162461bcd60e51b8152602060048201526016602482015275496e76616c696420706c61796572206164647265737360501b60448201526064016108a8565b6000848281518110612a7b57612a7b6138bf565b602002602001015111612ad05760405162461bcd60e51b815260206004820152601860248201527f496e76616c69642073686172652070657263656e74616765000000000000000060448201526064016108a8565b838181518110612ae257612ae26138bf565b602002602001015182612af59190613899565b9150838181518110612b0957612b096138bf565b6020026020010151836006016000878481518110612b2957612b296138bf565b6020908102919091018101516001600160a01b03168252810191909152604001600020556001016129ea565b508061271014612ba75760405162461bcd60e51b815260206004820152601960248201527f546f74616c20736861726573206d75737420626520313030250000000000000060448201526064016108a8565b5050505050565b60008060055484612bbf9190613882565b90506000600754600754612bd39190613882565b612bdd8584613882565b6107cf91906138ff565b60008060065484612bbf9190613882565b6000612c048787610869565b60008181526008602090815260408083206001600160a01b038716845260010190915290205490915060ff1615612c4d5760405162461bcd60e51b81526004016108a890613986565b60008181526008602090815260408083206001600160a01b038616845260020190915290205460ff1615612c935760405162461bcd60e51b81526004016108a890613986565b60008181526008602090815260408083206001600160a01b038616845260018082018452828520805460ff199081168317909155600290920190935290832080549091169091179055612ce788888561075f565b90508015612d205760008281526008602090815260408083206001600160a01b03871684526003019091529020805460ff191660011790555b6000612d2c87856116d6565b90506000612d3a8886610a57565b90506000612d488784612bae565b905060008415612d5f57612d5c8886612be7565b90505b60008a8152600260205260409020600101546001600160a01b0316612df7576000876001600160a01b03168460405160006040518083038185875af1925050503d8060008114612dcb576040519150601f19603f3d011682016040523d82523d6000602084013e612dd0565b606091505b5050905080612df15760405162461bcd60e51b81526004016108a890613940565b50612e1f565b60008a8152600260205260409020600101546001600160a01b0316612e1d8189866131c3565b505b6000612e2b8284613899565b90508015612ef35760008a8152600260205260409020600101546001600160a01b0316612ecb576000886001600160a01b03168260405160006040518083038185875af1925050503d8060008114612e9f576040519150601f19603f3d011682016040523d82523d6000602084013e612ea4565b606091505b5050905080612ec55760405162461bcd60e51b81526004016108a890613940565b50612ef3565b60008a8152600260205260409020600101546001600160a01b0316612ef1818a846131c3565b505b612efd8b85611c84565b612f078a82611c84565b60008b8152600260209081526040918290206001015491518681526001600160a01b03928316928b16916000805160206139c9833981519152910160405180910390a38215612f945760008a8152600260209081526040918290206001015491518581526001600160a01b03928316928b16916000805160206139c9833981519152910160405180910390a35b8115612ff05760008a8152600260209081526040918290206001015491518481526001600160a01b03928316928b16917fde02534236523c2e02492e6cfc4cd7cc6003b1891460f414626d77e7c867551f910160405180910390a35b5050505050505050505050505050565b600061300c8888610869565b60008181526008602090815260408083206001600160a01b038816845260030190915290205490915060ff16156130555760405162461bcd60e51b81526004016108a890613986565b60008181526008602090815260408083206001600160a01b03871684526003019091528120805460ff1916600117905561308f8584612be7565b905080156131b7576000868152600260205260409020600101546001600160a01b031661312f576000846001600160a01b03168260405160006040518083038185875af1925050503d8060008114613103576040519150601f19603f3d011682016040523d82523d6000602084013e613108565b606091505b50509050806131295760405162461bcd60e51b81526004016108a890613940565b50613157565b6000868152600260205260409020600101546001600160a01b03166131558186846131c3565b505b6131618682611c84565b6000868152600260209081526040918290206001015491518381526001600160a01b03928316928716917fde02534236523c2e02492e6cfc4cd7cc6003b1891460f414626d77e7c867551f910160405180910390a35b50505050505050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261321590849061321a565b505050565b600080602060008451602086016000885af18061323d576040513d6000823e3d81fd5b50506000513d91508115613255578060011415613262565b6001600160a01b0384163b155b1561182c57604051635274afe760e01b81526001600160a01b03851660048201526024016108a8565b508054600082559060005260206000209081019061187f91905b808211156132b957600081556001016132a5565b5090565b80356001600160a01b0381168114610fae57600080fd5b6000806000606084860312156132e957600080fd5b8335925060208401359150613300604085016132bd565b90509250925092565b6000806040838503121561331c57600080fd5b50508035926020909101359150565b60006020828403121561333d57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561338357613383613344565b604052919050565b600067ffffffffffffffff8211156133a5576133a5613344565b5060051b60200190565b600082601f8301126133c057600080fd5b81356133d36133ce8261338b565b61335a565b8082825260208201915060208360051b8601019250858311156133f557600080fd5b602085015b838110156134195761340b816132bd565b8352602092830192016133fa565b5095945050505050565b600082601f83011261343457600080fd5b81356134426133ce8261338b565b8082825260208201915060208360051b86010192508583111561346457600080fd5b602085015b83811015613419578035835260209283019201613469565b600080600080600060a0868803121561349957600080fd5b853594506020860135935060408601359250606086013567ffffffffffffffff8111156134c557600080fd5b6134d1888289016133af565b925050608086013567ffffffffffffffff8111156134ee57600080fd5b6134fa88828901613423565b9150509295509295909350565b60008060006060848603121561351c57600080fd5b505081359360208301359350604090920135919050565b602080825282518282018190526000918401906040840190835b818110156135745783516001600160a01b031683526020938401939092019160010161354d565b509095945050505050565b6000806040838503121561359257600080fd5b823591506135a2602084016132bd565b90509250929050565b801515811461187f57600080fd5b600080604083850312156135cc57600080fd5b8235915060208301356135de816135ab565b809150509250929050565b6000602082840312156135fb57600080fd5b813567ffffffffffffffff81111561361257600080fd5b8201601f8101841361362357600080fd5b80356136316133ce8261338b565b8082825260208201915060208360051b85010192508683111561365357600080fd5b6020840193505b8284101561367557833582526020938401939091019061365a565b9695505050505050565b602080825282518282018190526000918401906040840190835b81811015613574578351835260209384019390920191600101613699565b634e487b7160e01b600052602160045260246000fd5b6003811061187f57634e487b7160e01b600052602160045260246000fd5b600060e08201905088825287602083015286604083015285606083015284608083015283151560a083015261371f836136cd565b8260c083015298975050505050505050565b6000806040838503121561374457600080fd5b823591506020830135600381106135de57600080fd5b6001600160a01b038a8116825289166020820152604081018890526060810187905285151560808201526101208101613792866136cd565b60a082019590955260c081019390935290151560e083015215156101009091015295945050505050565b60008060008060008060c087890312156137d557600080fd5b863595506020870135945060408701359350606087013567ffffffffffffffff81111561380157600080fd5b61380d89828a016133af565b935050608087013567ffffffffffffffff81111561382a57600080fd5b61383689828a01613423565b92505061384560a088016132bd565b90509295509295509295565b60006020828403121561386357600080fd5b610796826132bd565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176107d4576107d461386c565b808201808211156107d4576107d461386c565b818103818111156107d4576107d461386c565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601260045260246000fd5b6000826138fa576138fa6138d5565b500690565b60008261390e5761390e6138d5565b500490565b602080825260139082015272141bdbdb08191bd95cc81b9bdd08195e1a5cdd606a1b604082015260600190565b6020808252600f908201526e151c985b9cd9995c8819985a5b1959608a1b604082015260600190565b60006020828403121561397b57600080fd5b8151610796816135ab565b6020808252600f908201526e105b1c9958591e4818db185a5b5959608a1b604082015260600190565b6000602082840312156139c157600080fd5b505191905056fe691d3da84f60a8e9f7618970b6df07a3a18b47254d483e44e071f50e8c3cbbfaa2646970667358221220cf1c04ccf4f1edd65e55aa003e4727b8b631b8254b40775c6ae070c45708427464736f6c634300081c0033