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:57:02.748854Z
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/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/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/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;
bytes32[] public allPoolIds;
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;
allPoolIds.push(poolId);
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;
}
struct PoolInfo {
bytes32 poolId;
address tokenAddress;
uint256 totalFunds;
uint256 remainingFunds;
bool isActive;
PoolState state;
bool isDepositAllowed;
bool isWithdrawalAllowed;
bytes32 matchId;
}
function getAllPools() public view returns (PoolInfo[] memory) {
uint256 poolCount = allPoolIds.length;
PoolInfo[] memory poolInfos = new PoolInfo[](poolCount);
for (uint256 i = 0; i < poolCount; i++) {
bytes32 poolId = allPoolIds[i];
Pool storage pool = pools[poolId];
poolInfos[i] = PoolInfo({
poolId: poolId,
tokenAddress: pool.tokenAddress,
totalFunds: pool.totalFunds,
remainingFunds: pool.remainingFunds,
isActive: pool.isActive,
state: pool.state,
isDepositAllowed: pool.isDepositAllowed,
isWithdrawalAllowed: pool.isWithdrawalAllowed,
matchId: pool.matchId
});
}
return poolInfos;
}
function getPoolsCount() public view returns (uint256) {
return allPoolIds.length;
}
}
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":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"allPoolIds","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"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":"tuple[]","name":"","internalType":"struct PoolManager.PoolInfo[]","components":[{"type":"bytes32","name":"poolId","internalType":"bytes32"},{"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":"bool","name":"isDepositAllowed","internalType":"bool"},{"type":"bool","name":"isWithdrawalAllowed","internalType":"bool"},{"type":"bytes32","name":"matchId","internalType":"bytes32"}]}],"name":"getAllPools","inputs":[]},{"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":"getPoolsCount","inputs":[]},{"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
0x60806040526103e8600555611fa4600655610384600755612710600855348015602757600080fd5b503380604d57604051631e4fbdf760e01b81526000600482015260240160405180910390fd5b605481605d565b506001805560ad565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b613d40806100bc6000396000f3fe60806040526004361061020f5760003560e01c8063a1071aed11610118578063c9b62674116100a0578063eb239c911161006f578063eb239c9114610724578063ef5672b614610744578063f2fde38b14610764578063f6d735b214610784578063fcb72a9c146107b457600080fd5b8063c9b626741461067f578063d88ff1f41461069f578063dc81f1c8146106c1578063ea7cfd8a146106f457600080fd5b8063b5217bb4116100e7578063b5217bb414610587578063bdec022114610616578063c0e046bc14610636578063c3a8574c1461064c578063c7d138cb1461065f57600080fd5b8063a1071aed1461050c578063a344d8431461052c578063aacc40101461055c578063b4ac68601461057257600080fd5b8063670429841161019b5780638da5cb5b1161016a5780638da5cb5b146103f7578063931d15a41461041557806393bf45c6146104355780639dc8cf73146104555780639fe9ada31461049d57600080fd5b8063670429841461035d578063715018a61461039557806371f58f15146103aa578063788e39cd146103ca57600080fd5b80635abf8f85116101e25780635abf8f85146102ba578063603ef649146102da57806366735fd8146102f05780636693643f1461031d5780636695c5b81461033d57600080fd5b806306a03645146102145780634355b8d214610247578063550e6ed1146102675780635aa28f6c14610298575b600080fd5b34801561022057600080fd5b5061023461022f366004613533565b6107d4565b6040519081526020015b60405180910390f35b34801561025357600080fd5b50610234610262366004613568565b610812565b34801561027357600080fd5b5061023461028236600461358a565b6000908152600260208190526040909120015490565b3480156102a457600080fd5b506102b86102b33660046136e0565b61084f565b005b3480156102c657600080fd5b506102346102d5366004613568565b6108de565b3480156102e657600080fd5b5061023460055481565b3480156102fc57600080fd5b5061031061030b366004613766565b6109c2565b60405161023e9190613792565b34801561032957600080fd5b506102346103383660046137de565b610acc565b34801561034957600080fd5b506102b8610358366004613568565b610af8565b34801561036957600080fd5b5061037d6103783660046137de565b610c3a565b6040516001600160a01b03909116815260200161023e565b3480156103a157600080fd5b506102b8610c4e565b3480156103b657600080fd5b506102b86103c5366004613818565b610c62565b3480156103d657600080fd5b506103ea6103e5366004613848565b610c74565b60405161023e91906138de565b34801561040357600080fd5b506000546001600160a01b031661037d565b34801561042157600080fd5b506102b8610430366004613818565b611028565b34801561044157600080fd5b506102b8610450366004613568565b611083565b34801561046157600080fd5b5061048d61047036600461358a565b600090815260026020526040902060080154610100900460ff1690565b604051901515815260200161023e565b3480156104a957600080fd5b506104f96104b836600461358a565b600460208190526000918252604090912080546001820154600283015460038401549484015460059094015492949193909260ff8082169161010090041687565b60405161023e979695949392919061394a565b34801561051857600080fd5b506102b8610527366004613990565b611388565b34801561053857600080fd5b5061023461054736600461358a565b60009081526002602052604090206007015490565b34801561056857600080fd5b5061023460065481565b34801561057e57600080fd5b50600354610234565b34801561059357600080fd5b506106016105a236600461358a565b600260208190526000918252604090912080546001820154928201546003830154600484015460078501546008909501546001600160a01b0394851696909416949293919260ff80831693610100938490048216938183169291041689565b60405161023e999897969594939291906139c6565b34801561062257600080fd5b506102b8610631366004613a28565b61139a565b34801561064257600080fd5b5061023460075481565b6102b861065a366004613568565b6114cb565b34801561066b57600080fd5b5061023461067a3660046137de565b61174b565b34801561068b57600080fd5b506102b861069a366004613818565b6117ae565b3480156106ab57600080fd5b506106b4611802565b60405161023e9190613abd565b3480156106cd57600080fd5b5061048d6106dc36600461358a565b60009081526002602052604090206008015460ff1690565b34801561070057600080fd5b5061048d61070f36600461358a565b60096020526000908152604090205460ff1681565b34801561073057600080fd5b506102b861073f366004613533565b61199b565b34801561075057600080fd5b506102b861075f366004613818565b611a40565b34801561077057600080fd5b506102b861077f366004613b73565b611a52565b34801561079057600080fd5b5061023461079f36600461358a565b60009081526002602052604090206003015490565b3480156107c057600080fd5b506102346107cf36600461358a565b611a90565b6000806107e185856108de565b60009081526004602090815260408083206001600160a01b03871684526006019091529020549150505b9392505050565b60008061081f84846108de565b600081815260046020526040902060028101549192509085146108425784610844565b835b925050505b92915050565b610857611ab1565b610862856002611388565b61086d846002611388565b600061087986866108de565b90506108888686868686611ade565b60006108948787610812565b6000818152600260208190526040822090810154600190910154929350916108c79085906001600160a01b031684611d03565b90506108d38382611eb3565b505050505050505050565b6000826109265760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c1bdbdb0810481251607a1b60448201526064015b60405180910390fd5b816109675760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c1bdbdb0810881251607a1b604482015260640161091d565b60008284106109765782610978565b835b90506000838510610989578461098b565b835b6040805160208101859052908101829052909150606001604051602081830303815290604052805190602001209250505092915050565b60008381526002602052604081206060916109dd8486613ba4565b905060006109eb8583613bbb565b6006840154909150811115610a01575060068201545b6000610a0d8383613bce565b67ffffffffffffffff811115610a2557610a256135a3565b604051908082528060200260200182016040528015610a4e578160200160208202803683370190505b509050825b82811015610ac057846006018181548110610a7057610a70613be1565b6000918252602090912001546001600160a01b031682610a908684613bce565b81518110610aa057610aa0613be1565b6001600160a01b0390921660209283029190910190910152600101610a53565b50979650505050505050565b60008281526002602090815260408083206001600160a01b038516845260050190915290205492915050565b610b00611edd565b6000610b0c83836108de565b600081815260046020526040902090915060026005820154610100900460ff166002811115610b3d57610b3d613916565b14610b7e5760405162461bcd60e51b815260206004820152601160248201527026b0ba31b41034b9903737ba1037bb32b960791b604482015260640161091d565b60028101546000610b8f8686610812565b600081815260026020819052604082200154919250610baf8888336107d4565b90506000610bbd853361174b565b90506000610bcb8633610acc565b600087815260026020526040808220600190810154898452918320015492935090918291610c0b918c916001600160a01b03908116911689898989611f07565b91509150610c198883611eb3565b610c238782611eb3565b50505050505050505050610c3660018055565b5050565b6000610c44611ab1565b61080b83836122e6565b610c56611ab1565b610c6060006124bd565b565b610c6a611ab1565b610c368282611028565b6060610c7e611ab1565b600282511015610cd05760405162461bcd60e51b815260206004820152601960248201527f4174206c65617374203220706f6f6c7320726571756972656400000000000000604482015260640161091d565b60028251610cde9190613c0d565b15610d2b5760405162461bcd60e51b815260206004820152601e60248201527f506f6f6c206172726179206c656e677468206d757374206265206576656e0000604482015260640161091d565b600060028351610d3b9190613c21565b67ffffffffffffffff811115610d5357610d536135a3565b604051908082528060200260200182016040528015610d7c578160200160208202803683370190505b50905060005b835181101561101f576000848281518110610d9f57610d9f613be1565b60200260200101519050600085836001610db99190613bbb565b81518110610dc957610dc9613be1565b602090810291909101810151600084815260029092526040808320828452922060048301549193509060ff16610e415760405162461bcd60e51b815260206004820152601b60248201527f546f6b656e20706f6f6c204120646f6573206e6f742065786973740000000000604482015260640161091d565b600481015460ff16610e955760405162461bcd60e51b815260206004820152601b60248201527f546f6b656e20706f6f6c204220646f6573206e6f742065786973740000000000604482015260640161091d565b600782015415610ee75760405162461bcd60e51b815260206004820152601960248201527f506f6f6c204120616c726561647920696e2061206d6174636800000000000000604482015260640161091d565b600781015415610f395760405162461bcd60e51b815260206004820152601960248201527f506f6f6c204220616c726561647920696e2061206d6174636800000000000000604482015260640161091d565b828403610f825760405162461bcd60e51b8152602060048201526017602482015276141bdbdb1cc81b5d5cdd08189948191a5999995c995b9d604a1b604482015260640161091d565b6000610f8e858561250d565b6000868152600260205260408082208783529120600780830184905581018390556004918201805461010061ff001991821681179092559290910180549092161790559050610fdd85856126a2565b8087610fea600289613c21565b81518110610ffa57610ffa613be1565b60200260200101818152505050505050506002816110189190613bbb565b9050610d82565b5090505b919050565b60008281526002602052604090206004015460ff166110595760405162461bcd60e51b815260040161091d90613c35565b60009182526002602052604090912060080180549115156101000261ff0019909216919091179055565b61108b611edd565b6000828152600260205260409020600481015460ff166110e25760405162461bcd60e51b8152602060048201526012602482015271506f6f6c206973206e6f742061637469766560701b604482015260640161091d565b6008810154610100900460ff1661113b5760405162461bcd60e51b815260206004820152601b60248201527f5769746864726177616c7320617265206e6f7420616c6c6f7765640000000000604482015260640161091d565b6000821161118b5760405162461bcd60e51b815260206004820152601960248201527f4d75737420776974686472617720736f6d6520746f6b656e7300000000000000604482015260640161091d565b3360009081526005820160205260409020548211156111e15760405162461bcd60e51b8152602060048201526012602482015271496e73756666696369656e742066756e647360701b604482015260640161091d565b818160020160008282546111f59190613bce565b90915550503360009081526005820160205260408120805484929061121b908490613bce565b909155505060018101546001600160a01b03166112a057604051600090339084908381818185875af1925050503d8060008114611274576040519150601f19603f3d011682016040523d82523d6000602084013e611279565b606091505b505090508061129a5760405162461bcd60e51b815260040161091d90613c62565b50611337565b600181015460405163a9059cbb60e01b8152336004820152602481018490526001600160a01b0390911690819063a9059cbb906044016020604051808303816000875af11580156112f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113199190613c8b565b6113355760405162461bcd60e51b815260040161091d90613c62565b505b600181015460405183815233916001600160a01b03169085907f4cd16167afcd2e45cd70a8b10d891f374e85f259ef7afd1867fc9be7fcb11331906020015b60405180910390a450610c3660018055565b611390611ab1565b610c3682826127c8565b6113a2611ab1565b6113aa611edd565b6113b5866002611388565b6113c0856002611388565b60006113cc87876108de565b90506113db8787878787611ade565b60006113e78888610812565b60008181526002602081905260408220908101546001909101549293509161141a9085906001600160a01b031684611d03565b90506114268382611eb3565b611435848b8b8b87878d61286a565b60008481526004602052604090206005015460ff16156114895760405162461bcd60e51b815260206004820152600f60248201526e4d617463682069732061637469766560881b604482015260640161091d565b6114938a8661297f565b61149d898661297f565b6114a684612b31565b5050506000908152600960205260409020805460ff1916905560018055505050505050565b6114d3611edd565b6000828152600260205260409020600481015460ff166115055760405162461bcd60e51b815260040161091d90613c35565b600881015460ff166115595760405162461bcd60e51b815260206004820152601860248201527f4465706f7369747320617265206e6f7420616c6c6f7765640000000000000000604482015260640161091d565b60018101546001600160a01b03166115b7578134146115b25760405162461bcd60e51b81526020600482015260156024820152744d7573742073656e6420736f6d6520746f6b656e7360581b604482015260640161091d565b61169c565b600082116115ff5760405162461bcd60e51b81526020600482015260156024820152744d7573742073656e6420736f6d6520746f6b656e7360581b604482015260640161091d565b60018101546040516323b872dd60e01b8152336004820152306024820152604481018490526001600160a01b039091169081906323b872dd906064016020604051808303816000875af115801561165a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061167e9190613c8b565b61169a5760405162461bcd60e51b815260040161091d90613c62565b505b818160020160008282546116b09190613bbb565b9091555050336000908152600582016020526040812080548492906116d6908490613bbb565b909155505060068101805460018181018355600092835260209092200180546001600160a01b03191633908117909155908201546040516001600160a01b03919091169085907fe40671b740fa5f78e7e7407dc9a0e028808df762f7f97020416b2ac647af2e3f906113769087815260200190565b600082815260026020819052604082200154810361176b57506000610849565b6000838152600260208181526040808420928301546001600160a01b03871685526005909301909152909120546117a490612710613ba4565b61080b9190613c21565b60008281526002602052604090206004015460ff166117df5760405162461bcd60e51b815260040161091d90613c35565b600091825260026020526040909120600801805460ff1916911515919091179055565b60035460609060008167ffffffffffffffff811115611823576118236135a3565b60405190808252806020026020018201604052801561189a57816020015b604080516101208101825260008082526020808301829052928201819052606082018190526080820181905260a0820181905260c0820181905260e0820181905261010082015282526000199092019101816118415790505b50905060005b82811015611994576000600382815481106118bd576118bd613be1565b6000918252602080832090910154808352600280835260409384902084516101208101865283815260018201546001600160a01b031694810194909452808201549484019490945260038401546060840152600484015460ff8082161515608086015292955060a0840192610100909104169081111561193f5761193f613916565b8152600883015460ff8082161515602084015261010090910416151560408201526007830154606090910152845185908590811061197f5761197f613be1565b602090810291909101015250506001016118a0565b5092915050565b6119a3611ab1565b60006119af84846108de565b60008181526004602052604090206005015490915060ff1615611a065760405162461bcd60e51b815260206004820152600f60248201526e4d617463682069732061637469766560881b604482015260640161091d565b611a10848361297f565b611a1a838361297f565b611a2381612b31565b6000818152600960205260409020805460ff191690555b50505050565b611a48611ab1565b610c3682826117ae565b611a5a611ab1565b6001600160a01b038116611a8457604051631e4fbdf760e01b81526000600482015260240161091d565b611a8d816124bd565b50565b60038181548110611aa057600080fd5b600091825260209091200154905081565b6000546001600160a01b03163314610c605760405163118cdaa760e01b815233600482015260240161091d565b6000611aea86866108de565b60008181526004602052604090206005015490915060ff16611b455760405162461bcd60e51b815260206004820152601460248201527313585d18da08191bd95cc81b9bdd08195e1a5cdd60621b604482015260640161091d565b6001600082815260046020526040902060050154610100900460ff166002811115611b7257611b72613916565b14611bb75760405162461bcd60e51b81526020600482015260156024820152744d61746368206e6f7420696e2070726f677265737360581b604482015260640161091d565b85841480611bc457508484145b611c095760405162461bcd60e51b8152602060048201526016602482015275496e76616c69642077696e6e6572206164647265737360501b604482015260640161091d565b8151835114611c535760405162461bcd60e51b8152602060048201526016602482015275082e4e4c2f2e640d8cadccee8d040dad2e6dac2e8c6d60531b604482015260640161091d565b6000835111611c9a5760405162461bcd60e51b8152602060048201526013602482015272139bc81c1b185e595c9cc81c1c9bdd9a591959606a1b604482015260640161091d565b60008181526004602052604090206002810185905560058101805461ffff1916610200179055611ccb828585612bae565b8186887fee20e6cf265453dc32c716ce04a1c54c44b9616a1e738f217f515736509aa9dc60405160405180910390a450505050505050565b6000611d0d611edd565b60008481526009602052604090205460ff1615611d3c5760405162461bcd60e51b815260040161091d90613ca8565b6000848152600960205260408120805460ff1916600117905560085460055484929190611d699084613ba4565b611d739190613c21565b90506001600160a01b038516611df157604051600090339083908381818185875af1925050503d8060008114611dc5576040519150601f19603f3d011682016040523d82523d6000602084013e611dca565b606091505b5050905080611deb5760405162461bcd60e51b815260040161091d90613c62565b50611e67565b60405163a9059cbb60e01b81523360048201526024810182905285906001600160a01b0382169063a9059cbb906044016020604051808303816000875af1158015611e40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e649190613c8b565b50505b6040518181526001600160a01b0386169033907ff0af9bc2c3a4716fef6ce079f5de916f018e0201e2f7052dfeae945801475b2f9060200160405180910390a391505061080b60018055565b60008281526002602052604081206003018054839290611ed4908490613bce565b90915550505050565b600260015403611f0057604051633ee5aeb560e01b815260040160405180910390fd5b6002600155565b6000878152600960209081526040808320338452600101909152812054819060ff1615611f465760405162461bcd60e51b815260040161091d90613ca8565b600089815260096020908152604080832033845260020190915290205460ff1615611f835760405162461bcd60e51b815260040161091d90613ca8565b600089815260096020908152604080832033845260030190915290205460ff1615611fc05760405162461bcd60e51b815260040161091d90613ca8565b600089815260096020908152604080832033845260018082018452828520805460ff199081168317909155600283018552838620805482168317905560039092019093529083208054909116909117905561201b8786612e0d565b905060006120298888612e46565b90506001600160a01b038a166120a757604051600090339087908381818185875af1925050503d806000811461207b576040519150601f19603f3d011682016040523d82523d6000602084013e612080565b606091505b50509050806120a15760405162461bcd60e51b815260040161091d90613c62565b5061211d565b60405163a9059cbb60e01b8152336004820152602481018690528a906001600160a01b0382169063a9059cbb906044016020604051808303816000875af11580156120f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061211a9190613c8b565b50505b6001600160a01b0389166121a0576000336121388385613bbb565b604051600081818185875af1925050503d8060008114612174576040519150601f19603f3d011682016040523d82523d6000602084013e612179565b606091505b505090508061219a5760405162461bcd60e51b815260040161091d90613c62565b5061222d565b886001600160a01b03811663a9059cbb336121bb8587613bbb565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303816000875af1158015612206573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061222a9190613c8b565b50505b6040518581526001600160a01b038b16903390600080516020613ceb8339815191529060200160405180910390a36040518281526001600160a01b038a16903390600080516020613ceb8339815191529060200160405180910390a36040518181526001600160a01b038a169033907fde02534236523c2e02492e6cfc4cd7cc6003b1891460f414626d77e7c867551f9060200160405180910390a3846122d48284613bbb565b93509350505097509795505050505050565b60008281526002602052604081206004015460ff161561233e5760405162461bcd60e51b8152602060048201526013602482015272506f6f6c20616c72656164792065786973747360681b604482015260640161091d565b6001600160a01b038216156123fd5760008290506000816001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612392573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123b69190613cd1565b116123fb5760405162461bcd60e51b8152602060048201526015602482015274496e76616c696420746f6b656e206164647265737360581b604482015260640161091d565b505b60008381526002602052604080822080546001600160a01b0319908116339081178355600180840180546001600160a01b038a1694168417905560048401805461ffff199081168317909155600885018054610101921691909117905560038054918201815586527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b0188905592519193909187917fc0c143d18100b0ec0b6c08cc52247dd860ffd3fc2af30733326e5f980c19635a91a4509092915050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60008183036125585760405162461bcd60e51b8152602060048201526017602482015276141bdbdb1cc81b5d5cdd08189948191a5999995c995b9d604a1b604482015260640161091d565b826125995760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c1bdbdb0810481251607a1b604482015260640161091d565b816125da5760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c1bdbdb0810881251607a1b604482015260640161091d565b60006125e684846108de565b60008181526004602052604090206005015490915060ff16156126425760405162461bcd60e51b81526020600482015260146024820152734d6174636820616c72656164792065786973747360601b604482015260640161091d565b600081815260046020526040808220868155600180820187905560058201805461ffff19169091179055905190918391869188917ff94047cb2b767481be8aad8cae3c3ce5f432cfe8dd7b23f50e3d18648b4a7b959190a4509392505050565b60006126ae83836108de565b60008181526004602052604090206005015490915060ff166127095760405162461bcd60e51b815260206004820152601460248201527313585d18da08191bd95cc81b9bdd08195e1a5cdd60621b604482015260640161091d565b60008082815260046020526040902060050154610100900460ff16600281111561273557612735613916565b1461277a5760405162461bcd60e51b815260206004820152601560248201527413585d18da08185b1c9958591e481cdd185c9d1959605a1b604482015260640161091d565b600081815260046020526040808220600501805461ff001916610100179055518291849186917f29d26f27771059d3fdf99a7ea828394ca3980824b18f47ba9959beb3e9f3d87391a4505050565b60008281526002602052604090206004015460ff166127f95760405162461bcd60e51b815260040161091d90613c35565b60008281526002602081905260409091206004018054839261ff00199091169061010090849081111561282e5761282e613916565b0217905550600281600281111561284757612847613916565b03610c365750600090815260026020819052604090912090810154600390910155565b6000848152600260205260408120905b60068201548110156128f057600082600601828154811061289d5761289d613be1565b60009182526020808320909101548983526002825260408084206001600160a01b039092168085526005909201909252912054909150156128e7576128e78a8a8a8a8a8a87612e57565b5060010161287a565b5060005b82518110156108d357600083828151811061291157612911613be1565b6020026020010151905060006129288a8a846107d4565b9050600081118015612960575060008b81526009602090815260408083206001600160a01b038616845260030190915290205460ff16155b15612975576129758b8b8b8b8b8b888861325f565b50506001016128f4565b600082815260026020526040902060038101546001909101546001600160a01b0316612a1e576000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146129f2576040519150601f19603f3d011682016040523d82523d6000602084013e6129f7565b606091505b5050905080612a185760405162461bcd60e51b815260040161091d90613c62565b50612ac5565b6000838152600260205260409081902060010154905163a9059cbb60e01b81526001600160a01b0384811660048301526024820184905290911690819063a9059cbb906044016020604051808303816000875af1158015612a83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612aa79190613c8b565b612ac35760405162461bcd60e51b815260040161091d90613c62565b505b6000838152600260208190526040822080546001600160a01b0319908116825560018201805490911690559081018290556003810182905560048101805461ffff1916905590612b1860068301826134ea565b5060006007820155600801805461ffff19169055505050565b80612b715760405162461bcd60e51b815260206004820152601060248201526f125b9d985b1a59081b585d18da08125160821b604482015260640161091d565b6000908152600460208190526040822082815560018101839055600281018390556003810183905590810191909155600501805461ffff19169055565b8051825114612bf85760405162461bcd60e51b8152602060048201526016602482015275082e4e4c2f2e640d8cadccee8d040dad2e6dac2e8c6d60531b604482015260640161091d565b6000825111612c385760405162461bcd60e51b815260206004820152600c60248201526b456d7074792061727261797360a01b604482015260640161091d565b600083815260046020526040812090805b8451811015612db45760006001600160a01b0316858281518110612c6f57612c6f613be1565b60200260200101516001600160a01b031603612cc65760405162461bcd60e51b8152602060048201526016602482015275496e76616c696420706c61796572206164647265737360501b604482015260640161091d565b6000848281518110612cda57612cda613be1565b602002602001015111612d2f5760405162461bcd60e51b815260206004820152601860248201527f496e76616c69642073686172652070657263656e746167650000000000000000604482015260640161091d565b838181518110612d4157612d41613be1565b602002602001015182612d549190613bbb565b9150838181518110612d6857612d68613be1565b6020026020010151836006016000878481518110612d8857612d88613be1565b6020908102919091018101516001600160a01b0316825281019190915260400160002055600101612c49565b508061271014612e065760405162461bcd60e51b815260206004820152601960248201527f546f74616c20736861726573206d757374206265203130302500000000000000604482015260640161091d565b5050505050565b60008060065484612e1e9190613ba4565b90506000600854600854612e329190613ba4565b612e3c8584613ba4565b6108449190613c21565b60008060075484612e1e9190613ba4565b6000612e6387876108de565b60008181526009602090815260408083206001600160a01b038716845260010190915290205490915060ff1615612eac5760405162461bcd60e51b815260040161091d90613ca8565b60008181526009602090815260408083206001600160a01b038616845260020190915290205460ff1615612ef25760405162461bcd60e51b815260040161091d90613ca8565b60008181526009602090815260408083206001600160a01b038616845260018082018452828520805460ff199081168317909155600290920190935290832080549091169091179055612f468888856107d4565b90508015612f7f5760008281526009602090815260408083206001600160a01b03871684526003019091529020805460ff191660011790555b6000612f8b878561174b565b90506000612f998886610acc565b90506000612fa78784612e0d565b905060008415612fbe57612fbb8886612e46565b90505b60008a8152600260205260409020600101546001600160a01b0316613056576000876001600160a01b03168460405160006040518083038185875af1925050503d806000811461302a576040519150601f19603f3d011682016040523d82523d6000602084013e61302f565b606091505b50509050806130505760405162461bcd60e51b815260040161091d90613c62565b5061307e565b60008a8152600260205260409020600101546001600160a01b031661307c818986613422565b505b600061308a8284613bbb565b905080156131525760008a8152600260205260409020600101546001600160a01b031661312a576000886001600160a01b03168260405160006040518083038185875af1925050503d80600081146130fe576040519150601f19603f3d011682016040523d82523d6000602084013e613103565b606091505b50509050806131245760405162461bcd60e51b815260040161091d90613c62565b50613152565b60008a8152600260205260409020600101546001600160a01b0316613150818a84613422565b505b61315c8b85611eb3565b6131668a82611eb3565b60008b8152600260209081526040918290206001015491518681526001600160a01b03928316928b1691600080516020613ceb833981519152910160405180910390a382156131f35760008a8152600260209081526040918290206001015491518581526001600160a01b03928316928b1691600080516020613ceb833981519152910160405180910390a35b811561324f5760008a8152600260209081526040918290206001015491518481526001600160a01b03928316928b16917fde02534236523c2e02492e6cfc4cd7cc6003b1891460f414626d77e7c867551f910160405180910390a35b5050505050505050505050505050565b600061326b88886108de565b60008181526009602090815260408083206001600160a01b038816845260030190915290205490915060ff16156132b45760405162461bcd60e51b815260040161091d90613ca8565b60008181526009602090815260408083206001600160a01b03871684526003019091528120805460ff191660011790556132ee8584612e46565b90508015613416576000868152600260205260409020600101546001600160a01b031661338e576000846001600160a01b03168260405160006040518083038185875af1925050503d8060008114613362576040519150601f19603f3d011682016040523d82523d6000602084013e613367565b606091505b50509050806133885760405162461bcd60e51b815260040161091d90613c62565b506133b6565b6000868152600260205260409020600101546001600160a01b03166133b4818684613422565b505b6133c08682611eb3565b6000868152600260209081526040918290206001015491518381526001600160a01b03928316928716917fde02534236523c2e02492e6cfc4cd7cc6003b1891460f414626d77e7c867551f910160405180910390a35b50505050505050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052613474908490613479565b505050565b600080602060008451602086016000885af18061349c576040513d6000823e3d81fd5b50506000513d915081156134b45780600114156134c1565b6001600160a01b0384163b155b15611a3a57604051635274afe760e01b81526001600160a01b038516600482015260240161091d565b5080546000825590600052602060002090810190611a8d91905b808211156135185760008155600101613504565b5090565b80356001600160a01b038116811461102357600080fd5b60008060006060848603121561354857600080fd5b833592506020840135915061355f6040850161351c565b90509250925092565b6000806040838503121561357b57600080fd5b50508035926020909101359150565b60006020828403121561359c57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156135e2576135e26135a3565b604052919050565b600067ffffffffffffffff821115613604576136046135a3565b5060051b60200190565b600082601f83011261361f57600080fd5b813561363261362d826135ea565b6135b9565b8082825260208201915060208360051b86010192508583111561365457600080fd5b602085015b838110156136785761366a8161351c565b835260209283019201613659565b5095945050505050565b600082601f83011261369357600080fd5b81356136a161362d826135ea565b8082825260208201915060208360051b8601019250858311156136c357600080fd5b602085015b838110156136785780358352602092830192016136c8565b600080600080600060a086880312156136f857600080fd5b853594506020860135935060408601359250606086013567ffffffffffffffff81111561372457600080fd5b6137308882890161360e565b925050608086013567ffffffffffffffff81111561374d57600080fd5b61375988828901613682565b9150509295509295909350565b60008060006060848603121561377b57600080fd5b505081359360208301359350604090920135919050565b602080825282518282018190526000918401906040840190835b818110156137d35783516001600160a01b03168352602093840193909201916001016137ac565b509095945050505050565b600080604083850312156137f157600080fd5b823591506138016020840161351c565b90509250929050565b8015158114611a8d57600080fd5b6000806040838503121561382b57600080fd5b82359150602083013561383d8161380a565b809150509250929050565b60006020828403121561385a57600080fd5b813567ffffffffffffffff81111561387157600080fd5b8201601f8101841361388257600080fd5b803561389061362d826135ea565b8082825260208201915060208360051b8501019250868311156138b257600080fd5b6020840193505b828410156138d45783358252602093840193909101906138b9565b9695505050505050565b602080825282518282018190526000918401906040840190835b818110156137d35783518352602093840193909201916001016138f8565b634e487b7160e01b600052602160045260246000fd5b60038110611a8d57634e487b7160e01b600052602160045260246000fd5b600060e08201905088825287602083015286604083015285606083015284608083015283151560a083015261397e8361392c565b8260c083015298975050505050505050565b600080604083850312156139a357600080fd5b8235915060208301356003811061383d57600080fd5b6139c28161392c565b9052565b6001600160a01b038a81168252891660208201526040810188905260608101879052851515608082015261012081016139fe8661392c565b60a082019590955260c081019390935290151560e083015215156101009091015295945050505050565b60008060008060008060c08789031215613a4157600080fd5b863595506020870135945060408701359350606087013567ffffffffffffffff811115613a6d57600080fd5b613a7989828a0161360e565b935050608087013567ffffffffffffffff811115613a9657600080fd5b613aa289828a01613682565b925050613ab160a0880161351c565b90509295509295509295565b602080825282518282018190526000918401906040840190835b818110156137d35783518051845260018060a01b036020820151166020850152604081015160408501526060810151606085015260808101511515608085015260a0810151613b2960a08601826139b9565b5060c0810151613b3d60c086018215159052565b5060e0810151613b5160e086018215159052565b5061010090810151908401526020939093019261012090920191600101613ad7565b600060208284031215613b8557600080fd5b61080b8261351c565b634e487b7160e01b600052601160045260246000fd5b808202811582820484141761084957610849613b8e565b8082018082111561084957610849613b8e565b8181038181111561084957610849613b8e565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601260045260246000fd5b600082613c1c57613c1c613bf7565b500690565b600082613c3057613c30613bf7565b500490565b602080825260139082015272141bdbdb08191bd95cc81b9bdd08195e1a5cdd606a1b604082015260600190565b6020808252600f908201526e151c985b9cd9995c8819985a5b1959608a1b604082015260600190565b600060208284031215613c9d57600080fd5b815161080b8161380a565b6020808252600f908201526e105b1c9958591e4818db185a5b5959608a1b604082015260600190565b600060208284031215613ce357600080fd5b505191905056fe691d3da84f60a8e9f7618970b6df07a3a18b47254d483e44e071f50e8c3cbbfaa2646970667358221220d4e91d7f3b2d538bf631b0ee5d84d860768aa6f3417790ac80fb88f961dacf8864736f6c634300081c0033
Deployed ByteCode
0x60806040526004361061020f5760003560e01c8063a1071aed11610118578063c9b62674116100a0578063eb239c911161006f578063eb239c9114610724578063ef5672b614610744578063f2fde38b14610764578063f6d735b214610784578063fcb72a9c146107b457600080fd5b8063c9b626741461067f578063d88ff1f41461069f578063dc81f1c8146106c1578063ea7cfd8a146106f457600080fd5b8063b5217bb4116100e7578063b5217bb414610587578063bdec022114610616578063c0e046bc14610636578063c3a8574c1461064c578063c7d138cb1461065f57600080fd5b8063a1071aed1461050c578063a344d8431461052c578063aacc40101461055c578063b4ac68601461057257600080fd5b8063670429841161019b5780638da5cb5b1161016a5780638da5cb5b146103f7578063931d15a41461041557806393bf45c6146104355780639dc8cf73146104555780639fe9ada31461049d57600080fd5b8063670429841461035d578063715018a61461039557806371f58f15146103aa578063788e39cd146103ca57600080fd5b80635abf8f85116101e25780635abf8f85146102ba578063603ef649146102da57806366735fd8146102f05780636693643f1461031d5780636695c5b81461033d57600080fd5b806306a03645146102145780634355b8d214610247578063550e6ed1146102675780635aa28f6c14610298575b600080fd5b34801561022057600080fd5b5061023461022f366004613533565b6107d4565b6040519081526020015b60405180910390f35b34801561025357600080fd5b50610234610262366004613568565b610812565b34801561027357600080fd5b5061023461028236600461358a565b6000908152600260208190526040909120015490565b3480156102a457600080fd5b506102b86102b33660046136e0565b61084f565b005b3480156102c657600080fd5b506102346102d5366004613568565b6108de565b3480156102e657600080fd5b5061023460055481565b3480156102fc57600080fd5b5061031061030b366004613766565b6109c2565b60405161023e9190613792565b34801561032957600080fd5b506102346103383660046137de565b610acc565b34801561034957600080fd5b506102b8610358366004613568565b610af8565b34801561036957600080fd5b5061037d6103783660046137de565b610c3a565b6040516001600160a01b03909116815260200161023e565b3480156103a157600080fd5b506102b8610c4e565b3480156103b657600080fd5b506102b86103c5366004613818565b610c62565b3480156103d657600080fd5b506103ea6103e5366004613848565b610c74565b60405161023e91906138de565b34801561040357600080fd5b506000546001600160a01b031661037d565b34801561042157600080fd5b506102b8610430366004613818565b611028565b34801561044157600080fd5b506102b8610450366004613568565b611083565b34801561046157600080fd5b5061048d61047036600461358a565b600090815260026020526040902060080154610100900460ff1690565b604051901515815260200161023e565b3480156104a957600080fd5b506104f96104b836600461358a565b600460208190526000918252604090912080546001820154600283015460038401549484015460059094015492949193909260ff8082169161010090041687565b60405161023e979695949392919061394a565b34801561051857600080fd5b506102b8610527366004613990565b611388565b34801561053857600080fd5b5061023461054736600461358a565b60009081526002602052604090206007015490565b34801561056857600080fd5b5061023460065481565b34801561057e57600080fd5b50600354610234565b34801561059357600080fd5b506106016105a236600461358a565b600260208190526000918252604090912080546001820154928201546003830154600484015460078501546008909501546001600160a01b0394851696909416949293919260ff80831693610100938490048216938183169291041689565b60405161023e999897969594939291906139c6565b34801561062257600080fd5b506102b8610631366004613a28565b61139a565b34801561064257600080fd5b5061023460075481565b6102b861065a366004613568565b6114cb565b34801561066b57600080fd5b5061023461067a3660046137de565b61174b565b34801561068b57600080fd5b506102b861069a366004613818565b6117ae565b3480156106ab57600080fd5b506106b4611802565b60405161023e9190613abd565b3480156106cd57600080fd5b5061048d6106dc36600461358a565b60009081526002602052604090206008015460ff1690565b34801561070057600080fd5b5061048d61070f36600461358a565b60096020526000908152604090205460ff1681565b34801561073057600080fd5b506102b861073f366004613533565b61199b565b34801561075057600080fd5b506102b861075f366004613818565b611a40565b34801561077057600080fd5b506102b861077f366004613b73565b611a52565b34801561079057600080fd5b5061023461079f36600461358a565b60009081526002602052604090206003015490565b3480156107c057600080fd5b506102346107cf36600461358a565b611a90565b6000806107e185856108de565b60009081526004602090815260408083206001600160a01b03871684526006019091529020549150505b9392505050565b60008061081f84846108de565b600081815260046020526040902060028101549192509085146108425784610844565b835b925050505b92915050565b610857611ab1565b610862856002611388565b61086d846002611388565b600061087986866108de565b90506108888686868686611ade565b60006108948787610812565b6000818152600260208190526040822090810154600190910154929350916108c79085906001600160a01b031684611d03565b90506108d38382611eb3565b505050505050505050565b6000826109265760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c1bdbdb0810481251607a1b60448201526064015b60405180910390fd5b816109675760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c1bdbdb0810881251607a1b604482015260640161091d565b60008284106109765782610978565b835b90506000838510610989578461098b565b835b6040805160208101859052908101829052909150606001604051602081830303815290604052805190602001209250505092915050565b60008381526002602052604081206060916109dd8486613ba4565b905060006109eb8583613bbb565b6006840154909150811115610a01575060068201545b6000610a0d8383613bce565b67ffffffffffffffff811115610a2557610a256135a3565b604051908082528060200260200182016040528015610a4e578160200160208202803683370190505b509050825b82811015610ac057846006018181548110610a7057610a70613be1565b6000918252602090912001546001600160a01b031682610a908684613bce565b81518110610aa057610aa0613be1565b6001600160a01b0390921660209283029190910190910152600101610a53565b50979650505050505050565b60008281526002602090815260408083206001600160a01b038516845260050190915290205492915050565b610b00611edd565b6000610b0c83836108de565b600081815260046020526040902090915060026005820154610100900460ff166002811115610b3d57610b3d613916565b14610b7e5760405162461bcd60e51b815260206004820152601160248201527026b0ba31b41034b9903737ba1037bb32b960791b604482015260640161091d565b60028101546000610b8f8686610812565b600081815260026020819052604082200154919250610baf8888336107d4565b90506000610bbd853361174b565b90506000610bcb8633610acc565b600087815260026020526040808220600190810154898452918320015492935090918291610c0b918c916001600160a01b03908116911689898989611f07565b91509150610c198883611eb3565b610c238782611eb3565b50505050505050505050610c3660018055565b5050565b6000610c44611ab1565b61080b83836122e6565b610c56611ab1565b610c6060006124bd565b565b610c6a611ab1565b610c368282611028565b6060610c7e611ab1565b600282511015610cd05760405162461bcd60e51b815260206004820152601960248201527f4174206c65617374203220706f6f6c7320726571756972656400000000000000604482015260640161091d565b60028251610cde9190613c0d565b15610d2b5760405162461bcd60e51b815260206004820152601e60248201527f506f6f6c206172726179206c656e677468206d757374206265206576656e0000604482015260640161091d565b600060028351610d3b9190613c21565b67ffffffffffffffff811115610d5357610d536135a3565b604051908082528060200260200182016040528015610d7c578160200160208202803683370190505b50905060005b835181101561101f576000848281518110610d9f57610d9f613be1565b60200260200101519050600085836001610db99190613bbb565b81518110610dc957610dc9613be1565b602090810291909101810151600084815260029092526040808320828452922060048301549193509060ff16610e415760405162461bcd60e51b815260206004820152601b60248201527f546f6b656e20706f6f6c204120646f6573206e6f742065786973740000000000604482015260640161091d565b600481015460ff16610e955760405162461bcd60e51b815260206004820152601b60248201527f546f6b656e20706f6f6c204220646f6573206e6f742065786973740000000000604482015260640161091d565b600782015415610ee75760405162461bcd60e51b815260206004820152601960248201527f506f6f6c204120616c726561647920696e2061206d6174636800000000000000604482015260640161091d565b600781015415610f395760405162461bcd60e51b815260206004820152601960248201527f506f6f6c204220616c726561647920696e2061206d6174636800000000000000604482015260640161091d565b828403610f825760405162461bcd60e51b8152602060048201526017602482015276141bdbdb1cc81b5d5cdd08189948191a5999995c995b9d604a1b604482015260640161091d565b6000610f8e858561250d565b6000868152600260205260408082208783529120600780830184905581018390556004918201805461010061ff001991821681179092559290910180549092161790559050610fdd85856126a2565b8087610fea600289613c21565b81518110610ffa57610ffa613be1565b60200260200101818152505050505050506002816110189190613bbb565b9050610d82565b5090505b919050565b60008281526002602052604090206004015460ff166110595760405162461bcd60e51b815260040161091d90613c35565b60009182526002602052604090912060080180549115156101000261ff0019909216919091179055565b61108b611edd565b6000828152600260205260409020600481015460ff166110e25760405162461bcd60e51b8152602060048201526012602482015271506f6f6c206973206e6f742061637469766560701b604482015260640161091d565b6008810154610100900460ff1661113b5760405162461bcd60e51b815260206004820152601b60248201527f5769746864726177616c7320617265206e6f7420616c6c6f7765640000000000604482015260640161091d565b6000821161118b5760405162461bcd60e51b815260206004820152601960248201527f4d75737420776974686472617720736f6d6520746f6b656e7300000000000000604482015260640161091d565b3360009081526005820160205260409020548211156111e15760405162461bcd60e51b8152602060048201526012602482015271496e73756666696369656e742066756e647360701b604482015260640161091d565b818160020160008282546111f59190613bce565b90915550503360009081526005820160205260408120805484929061121b908490613bce565b909155505060018101546001600160a01b03166112a057604051600090339084908381818185875af1925050503d8060008114611274576040519150601f19603f3d011682016040523d82523d6000602084013e611279565b606091505b505090508061129a5760405162461bcd60e51b815260040161091d90613c62565b50611337565b600181015460405163a9059cbb60e01b8152336004820152602481018490526001600160a01b0390911690819063a9059cbb906044016020604051808303816000875af11580156112f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113199190613c8b565b6113355760405162461bcd60e51b815260040161091d90613c62565b505b600181015460405183815233916001600160a01b03169085907f4cd16167afcd2e45cd70a8b10d891f374e85f259ef7afd1867fc9be7fcb11331906020015b60405180910390a450610c3660018055565b611390611ab1565b610c3682826127c8565b6113a2611ab1565b6113aa611edd565b6113b5866002611388565b6113c0856002611388565b60006113cc87876108de565b90506113db8787878787611ade565b60006113e78888610812565b60008181526002602081905260408220908101546001909101549293509161141a9085906001600160a01b031684611d03565b90506114268382611eb3565b611435848b8b8b87878d61286a565b60008481526004602052604090206005015460ff16156114895760405162461bcd60e51b815260206004820152600f60248201526e4d617463682069732061637469766560881b604482015260640161091d565b6114938a8661297f565b61149d898661297f565b6114a684612b31565b5050506000908152600960205260409020805460ff1916905560018055505050505050565b6114d3611edd565b6000828152600260205260409020600481015460ff166115055760405162461bcd60e51b815260040161091d90613c35565b600881015460ff166115595760405162461bcd60e51b815260206004820152601860248201527f4465706f7369747320617265206e6f7420616c6c6f7765640000000000000000604482015260640161091d565b60018101546001600160a01b03166115b7578134146115b25760405162461bcd60e51b81526020600482015260156024820152744d7573742073656e6420736f6d6520746f6b656e7360581b604482015260640161091d565b61169c565b600082116115ff5760405162461bcd60e51b81526020600482015260156024820152744d7573742073656e6420736f6d6520746f6b656e7360581b604482015260640161091d565b60018101546040516323b872dd60e01b8152336004820152306024820152604481018490526001600160a01b039091169081906323b872dd906064016020604051808303816000875af115801561165a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061167e9190613c8b565b61169a5760405162461bcd60e51b815260040161091d90613c62565b505b818160020160008282546116b09190613bbb565b9091555050336000908152600582016020526040812080548492906116d6908490613bbb565b909155505060068101805460018181018355600092835260209092200180546001600160a01b03191633908117909155908201546040516001600160a01b03919091169085907fe40671b740fa5f78e7e7407dc9a0e028808df762f7f97020416b2ac647af2e3f906113769087815260200190565b600082815260026020819052604082200154810361176b57506000610849565b6000838152600260208181526040808420928301546001600160a01b03871685526005909301909152909120546117a490612710613ba4565b61080b9190613c21565b60008281526002602052604090206004015460ff166117df5760405162461bcd60e51b815260040161091d90613c35565b600091825260026020526040909120600801805460ff1916911515919091179055565b60035460609060008167ffffffffffffffff811115611823576118236135a3565b60405190808252806020026020018201604052801561189a57816020015b604080516101208101825260008082526020808301829052928201819052606082018190526080820181905260a0820181905260c0820181905260e0820181905261010082015282526000199092019101816118415790505b50905060005b82811015611994576000600382815481106118bd576118bd613be1565b6000918252602080832090910154808352600280835260409384902084516101208101865283815260018201546001600160a01b031694810194909452808201549484019490945260038401546060840152600484015460ff8082161515608086015292955060a0840192610100909104169081111561193f5761193f613916565b8152600883015460ff8082161515602084015261010090910416151560408201526007830154606090910152845185908590811061197f5761197f613be1565b602090810291909101015250506001016118a0565b5092915050565b6119a3611ab1565b60006119af84846108de565b60008181526004602052604090206005015490915060ff1615611a065760405162461bcd60e51b815260206004820152600f60248201526e4d617463682069732061637469766560881b604482015260640161091d565b611a10848361297f565b611a1a838361297f565b611a2381612b31565b6000818152600960205260409020805460ff191690555b50505050565b611a48611ab1565b610c3682826117ae565b611a5a611ab1565b6001600160a01b038116611a8457604051631e4fbdf760e01b81526000600482015260240161091d565b611a8d816124bd565b50565b60038181548110611aa057600080fd5b600091825260209091200154905081565b6000546001600160a01b03163314610c605760405163118cdaa760e01b815233600482015260240161091d565b6000611aea86866108de565b60008181526004602052604090206005015490915060ff16611b455760405162461bcd60e51b815260206004820152601460248201527313585d18da08191bd95cc81b9bdd08195e1a5cdd60621b604482015260640161091d565b6001600082815260046020526040902060050154610100900460ff166002811115611b7257611b72613916565b14611bb75760405162461bcd60e51b81526020600482015260156024820152744d61746368206e6f7420696e2070726f677265737360581b604482015260640161091d565b85841480611bc457508484145b611c095760405162461bcd60e51b8152602060048201526016602482015275496e76616c69642077696e6e6572206164647265737360501b604482015260640161091d565b8151835114611c535760405162461bcd60e51b8152602060048201526016602482015275082e4e4c2f2e640d8cadccee8d040dad2e6dac2e8c6d60531b604482015260640161091d565b6000835111611c9a5760405162461bcd60e51b8152602060048201526013602482015272139bc81c1b185e595c9cc81c1c9bdd9a591959606a1b604482015260640161091d565b60008181526004602052604090206002810185905560058101805461ffff1916610200179055611ccb828585612bae565b8186887fee20e6cf265453dc32c716ce04a1c54c44b9616a1e738f217f515736509aa9dc60405160405180910390a450505050505050565b6000611d0d611edd565b60008481526009602052604090205460ff1615611d3c5760405162461bcd60e51b815260040161091d90613ca8565b6000848152600960205260408120805460ff1916600117905560085460055484929190611d699084613ba4565b611d739190613c21565b90506001600160a01b038516611df157604051600090339083908381818185875af1925050503d8060008114611dc5576040519150601f19603f3d011682016040523d82523d6000602084013e611dca565b606091505b5050905080611deb5760405162461bcd60e51b815260040161091d90613c62565b50611e67565b60405163a9059cbb60e01b81523360048201526024810182905285906001600160a01b0382169063a9059cbb906044016020604051808303816000875af1158015611e40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e649190613c8b565b50505b6040518181526001600160a01b0386169033907ff0af9bc2c3a4716fef6ce079f5de916f018e0201e2f7052dfeae945801475b2f9060200160405180910390a391505061080b60018055565b60008281526002602052604081206003018054839290611ed4908490613bce565b90915550505050565b600260015403611f0057604051633ee5aeb560e01b815260040160405180910390fd5b6002600155565b6000878152600960209081526040808320338452600101909152812054819060ff1615611f465760405162461bcd60e51b815260040161091d90613ca8565b600089815260096020908152604080832033845260020190915290205460ff1615611f835760405162461bcd60e51b815260040161091d90613ca8565b600089815260096020908152604080832033845260030190915290205460ff1615611fc05760405162461bcd60e51b815260040161091d90613ca8565b600089815260096020908152604080832033845260018082018452828520805460ff199081168317909155600283018552838620805482168317905560039092019093529083208054909116909117905561201b8786612e0d565b905060006120298888612e46565b90506001600160a01b038a166120a757604051600090339087908381818185875af1925050503d806000811461207b576040519150601f19603f3d011682016040523d82523d6000602084013e612080565b606091505b50509050806120a15760405162461bcd60e51b815260040161091d90613c62565b5061211d565b60405163a9059cbb60e01b8152336004820152602481018690528a906001600160a01b0382169063a9059cbb906044016020604051808303816000875af11580156120f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061211a9190613c8b565b50505b6001600160a01b0389166121a0576000336121388385613bbb565b604051600081818185875af1925050503d8060008114612174576040519150601f19603f3d011682016040523d82523d6000602084013e612179565b606091505b505090508061219a5760405162461bcd60e51b815260040161091d90613c62565b5061222d565b886001600160a01b03811663a9059cbb336121bb8587613bbb565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303816000875af1158015612206573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061222a9190613c8b565b50505b6040518581526001600160a01b038b16903390600080516020613ceb8339815191529060200160405180910390a36040518281526001600160a01b038a16903390600080516020613ceb8339815191529060200160405180910390a36040518181526001600160a01b038a169033907fde02534236523c2e02492e6cfc4cd7cc6003b1891460f414626d77e7c867551f9060200160405180910390a3846122d48284613bbb565b93509350505097509795505050505050565b60008281526002602052604081206004015460ff161561233e5760405162461bcd60e51b8152602060048201526013602482015272506f6f6c20616c72656164792065786973747360681b604482015260640161091d565b6001600160a01b038216156123fd5760008290506000816001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612392573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123b69190613cd1565b116123fb5760405162461bcd60e51b8152602060048201526015602482015274496e76616c696420746f6b656e206164647265737360581b604482015260640161091d565b505b60008381526002602052604080822080546001600160a01b0319908116339081178355600180840180546001600160a01b038a1694168417905560048401805461ffff199081168317909155600885018054610101921691909117905560038054918201815586527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b0188905592519193909187917fc0c143d18100b0ec0b6c08cc52247dd860ffd3fc2af30733326e5f980c19635a91a4509092915050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60008183036125585760405162461bcd60e51b8152602060048201526017602482015276141bdbdb1cc81b5d5cdd08189948191a5999995c995b9d604a1b604482015260640161091d565b826125995760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c1bdbdb0810481251607a1b604482015260640161091d565b816125da5760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c1bdbdb0810881251607a1b604482015260640161091d565b60006125e684846108de565b60008181526004602052604090206005015490915060ff16156126425760405162461bcd60e51b81526020600482015260146024820152734d6174636820616c72656164792065786973747360601b604482015260640161091d565b600081815260046020526040808220868155600180820187905560058201805461ffff19169091179055905190918391869188917ff94047cb2b767481be8aad8cae3c3ce5f432cfe8dd7b23f50e3d18648b4a7b959190a4509392505050565b60006126ae83836108de565b60008181526004602052604090206005015490915060ff166127095760405162461bcd60e51b815260206004820152601460248201527313585d18da08191bd95cc81b9bdd08195e1a5cdd60621b604482015260640161091d565b60008082815260046020526040902060050154610100900460ff16600281111561273557612735613916565b1461277a5760405162461bcd60e51b815260206004820152601560248201527413585d18da08185b1c9958591e481cdd185c9d1959605a1b604482015260640161091d565b600081815260046020526040808220600501805461ff001916610100179055518291849186917f29d26f27771059d3fdf99a7ea828394ca3980824b18f47ba9959beb3e9f3d87391a4505050565b60008281526002602052604090206004015460ff166127f95760405162461bcd60e51b815260040161091d90613c35565b60008281526002602081905260409091206004018054839261ff00199091169061010090849081111561282e5761282e613916565b0217905550600281600281111561284757612847613916565b03610c365750600090815260026020819052604090912090810154600390910155565b6000848152600260205260408120905b60068201548110156128f057600082600601828154811061289d5761289d613be1565b60009182526020808320909101548983526002825260408084206001600160a01b039092168085526005909201909252912054909150156128e7576128e78a8a8a8a8a8a87612e57565b5060010161287a565b5060005b82518110156108d357600083828151811061291157612911613be1565b6020026020010151905060006129288a8a846107d4565b9050600081118015612960575060008b81526009602090815260408083206001600160a01b038616845260030190915290205460ff16155b15612975576129758b8b8b8b8b8b888861325f565b50506001016128f4565b600082815260026020526040902060038101546001909101546001600160a01b0316612a1e576000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146129f2576040519150601f19603f3d011682016040523d82523d6000602084013e6129f7565b606091505b5050905080612a185760405162461bcd60e51b815260040161091d90613c62565b50612ac5565b6000838152600260205260409081902060010154905163a9059cbb60e01b81526001600160a01b0384811660048301526024820184905290911690819063a9059cbb906044016020604051808303816000875af1158015612a83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612aa79190613c8b565b612ac35760405162461bcd60e51b815260040161091d90613c62565b505b6000838152600260208190526040822080546001600160a01b0319908116825560018201805490911690559081018290556003810182905560048101805461ffff1916905590612b1860068301826134ea565b5060006007820155600801805461ffff19169055505050565b80612b715760405162461bcd60e51b815260206004820152601060248201526f125b9d985b1a59081b585d18da08125160821b604482015260640161091d565b6000908152600460208190526040822082815560018101839055600281018390556003810183905590810191909155600501805461ffff19169055565b8051825114612bf85760405162461bcd60e51b8152602060048201526016602482015275082e4e4c2f2e640d8cadccee8d040dad2e6dac2e8c6d60531b604482015260640161091d565b6000825111612c385760405162461bcd60e51b815260206004820152600c60248201526b456d7074792061727261797360a01b604482015260640161091d565b600083815260046020526040812090805b8451811015612db45760006001600160a01b0316858281518110612c6f57612c6f613be1565b60200260200101516001600160a01b031603612cc65760405162461bcd60e51b8152602060048201526016602482015275496e76616c696420706c61796572206164647265737360501b604482015260640161091d565b6000848281518110612cda57612cda613be1565b602002602001015111612d2f5760405162461bcd60e51b815260206004820152601860248201527f496e76616c69642073686172652070657263656e746167650000000000000000604482015260640161091d565b838181518110612d4157612d41613be1565b602002602001015182612d549190613bbb565b9150838181518110612d6857612d68613be1565b6020026020010151836006016000878481518110612d8857612d88613be1565b6020908102919091018101516001600160a01b0316825281019190915260400160002055600101612c49565b508061271014612e065760405162461bcd60e51b815260206004820152601960248201527f546f74616c20736861726573206d757374206265203130302500000000000000604482015260640161091d565b5050505050565b60008060065484612e1e9190613ba4565b90506000600854600854612e329190613ba4565b612e3c8584613ba4565b6108449190613c21565b60008060075484612e1e9190613ba4565b6000612e6387876108de565b60008181526009602090815260408083206001600160a01b038716845260010190915290205490915060ff1615612eac5760405162461bcd60e51b815260040161091d90613ca8565b60008181526009602090815260408083206001600160a01b038616845260020190915290205460ff1615612ef25760405162461bcd60e51b815260040161091d90613ca8565b60008181526009602090815260408083206001600160a01b038616845260018082018452828520805460ff199081168317909155600290920190935290832080549091169091179055612f468888856107d4565b90508015612f7f5760008281526009602090815260408083206001600160a01b03871684526003019091529020805460ff191660011790555b6000612f8b878561174b565b90506000612f998886610acc565b90506000612fa78784612e0d565b905060008415612fbe57612fbb8886612e46565b90505b60008a8152600260205260409020600101546001600160a01b0316613056576000876001600160a01b03168460405160006040518083038185875af1925050503d806000811461302a576040519150601f19603f3d011682016040523d82523d6000602084013e61302f565b606091505b50509050806130505760405162461bcd60e51b815260040161091d90613c62565b5061307e565b60008a8152600260205260409020600101546001600160a01b031661307c818986613422565b505b600061308a8284613bbb565b905080156131525760008a8152600260205260409020600101546001600160a01b031661312a576000886001600160a01b03168260405160006040518083038185875af1925050503d80600081146130fe576040519150601f19603f3d011682016040523d82523d6000602084013e613103565b606091505b50509050806131245760405162461bcd60e51b815260040161091d90613c62565b50613152565b60008a8152600260205260409020600101546001600160a01b0316613150818a84613422565b505b61315c8b85611eb3565b6131668a82611eb3565b60008b8152600260209081526040918290206001015491518681526001600160a01b03928316928b1691600080516020613ceb833981519152910160405180910390a382156131f35760008a8152600260209081526040918290206001015491518581526001600160a01b03928316928b1691600080516020613ceb833981519152910160405180910390a35b811561324f5760008a8152600260209081526040918290206001015491518481526001600160a01b03928316928b16917fde02534236523c2e02492e6cfc4cd7cc6003b1891460f414626d77e7c867551f910160405180910390a35b5050505050505050505050505050565b600061326b88886108de565b60008181526009602090815260408083206001600160a01b038816845260030190915290205490915060ff16156132b45760405162461bcd60e51b815260040161091d90613ca8565b60008181526009602090815260408083206001600160a01b03871684526003019091528120805460ff191660011790556132ee8584612e46565b90508015613416576000868152600260205260409020600101546001600160a01b031661338e576000846001600160a01b03168260405160006040518083038185875af1925050503d8060008114613362576040519150601f19603f3d011682016040523d82523d6000602084013e613367565b606091505b50509050806133885760405162461bcd60e51b815260040161091d90613c62565b506133b6565b6000868152600260205260409020600101546001600160a01b03166133b4818684613422565b505b6133c08682611eb3565b6000868152600260209081526040918290206001015491518381526001600160a01b03928316928716917fde02534236523c2e02492e6cfc4cd7cc6003b1891460f414626d77e7c867551f910160405180910390a35b50505050505050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052613474908490613479565b505050565b600080602060008451602086016000885af18061349c576040513d6000823e3d81fd5b50506000513d915081156134b45780600114156134c1565b6001600160a01b0384163b155b15611a3a57604051635274afe760e01b81526001600160a01b038516600482015260240161091d565b5080546000825590600052602060002090810190611a8d91905b808211156135185760008155600101613504565b5090565b80356001600160a01b038116811461102357600080fd5b60008060006060848603121561354857600080fd5b833592506020840135915061355f6040850161351c565b90509250925092565b6000806040838503121561357b57600080fd5b50508035926020909101359150565b60006020828403121561359c57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156135e2576135e26135a3565b604052919050565b600067ffffffffffffffff821115613604576136046135a3565b5060051b60200190565b600082601f83011261361f57600080fd5b813561363261362d826135ea565b6135b9565b8082825260208201915060208360051b86010192508583111561365457600080fd5b602085015b838110156136785761366a8161351c565b835260209283019201613659565b5095945050505050565b600082601f83011261369357600080fd5b81356136a161362d826135ea565b8082825260208201915060208360051b8601019250858311156136c357600080fd5b602085015b838110156136785780358352602092830192016136c8565b600080600080600060a086880312156136f857600080fd5b853594506020860135935060408601359250606086013567ffffffffffffffff81111561372457600080fd5b6137308882890161360e565b925050608086013567ffffffffffffffff81111561374d57600080fd5b61375988828901613682565b9150509295509295909350565b60008060006060848603121561377b57600080fd5b505081359360208301359350604090920135919050565b602080825282518282018190526000918401906040840190835b818110156137d35783516001600160a01b03168352602093840193909201916001016137ac565b509095945050505050565b600080604083850312156137f157600080fd5b823591506138016020840161351c565b90509250929050565b8015158114611a8d57600080fd5b6000806040838503121561382b57600080fd5b82359150602083013561383d8161380a565b809150509250929050565b60006020828403121561385a57600080fd5b813567ffffffffffffffff81111561387157600080fd5b8201601f8101841361388257600080fd5b803561389061362d826135ea565b8082825260208201915060208360051b8501019250868311156138b257600080fd5b6020840193505b828410156138d45783358252602093840193909101906138b9565b9695505050505050565b602080825282518282018190526000918401906040840190835b818110156137d35783518352602093840193909201916001016138f8565b634e487b7160e01b600052602160045260246000fd5b60038110611a8d57634e487b7160e01b600052602160045260246000fd5b600060e08201905088825287602083015286604083015285606083015284608083015283151560a083015261397e8361392c565b8260c083015298975050505050505050565b600080604083850312156139a357600080fd5b8235915060208301356003811061383d57600080fd5b6139c28161392c565b9052565b6001600160a01b038a81168252891660208201526040810188905260608101879052851515608082015261012081016139fe8661392c565b60a082019590955260c081019390935290151560e083015215156101009091015295945050505050565b60008060008060008060c08789031215613a4157600080fd5b863595506020870135945060408701359350606087013567ffffffffffffffff811115613a6d57600080fd5b613a7989828a0161360e565b935050608087013567ffffffffffffffff811115613a9657600080fd5b613aa289828a01613682565b925050613ab160a0880161351c565b90509295509295509295565b602080825282518282018190526000918401906040840190835b818110156137d35783518051845260018060a01b036020820151166020850152604081015160408501526060810151606085015260808101511515608085015260a0810151613b2960a08601826139b9565b5060c0810151613b3d60c086018215159052565b5060e0810151613b5160e086018215159052565b5061010090810151908401526020939093019261012090920191600101613ad7565b600060208284031215613b8557600080fd5b61080b8261351c565b634e487b7160e01b600052601160045260246000fd5b808202811582820484141761084957610849613b8e565b8082018082111561084957610849613b8e565b8181038181111561084957610849613b8e565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601260045260246000fd5b600082613c1c57613c1c613bf7565b500690565b600082613c3057613c30613bf7565b500490565b602080825260139082015272141bdbdb08191bd95cc81b9bdd08195e1a5cdd606a1b604082015260600190565b6020808252600f908201526e151c985b9cd9995c8819985a5b1959608a1b604082015260600190565b600060208284031215613c9d57600080fd5b815161080b8161380a565b6020808252600f908201526e105b1c9958591e4818db185a5b5959608a1b604082015260600190565b600060208284031215613ce357600080fd5b505191905056fe691d3da84f60a8e9f7618970b6df07a3a18b47254d483e44e071f50e8c3cbbfaa2646970667358221220d4e91d7f3b2d538bf631b0ee5d84d860768aa6f3417790ac80fb88f961dacf8864736f6c634300081c0033