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-22T17:31:12.440744Z
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);
// Disable deposits and withdrawals during match
pools[poolA].isDepositAllowed = false;
pools[poolA].isWithdrawalAllowed = false;
pools[poolB].isDepositAllowed = false;
pools[poolB].isWithdrawalAllowed = false;
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/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/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/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
0x60806040526103e8600555611fa4600655610384600755612710600855348015602757600080fd5b503380604d57604051631e4fbdf760e01b81526000600482015260240160405180910390fd5b605481605d565b506001805560ad565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b613d75806100bc6000396000f3fe60806040526004361061020f5760003560e01c8063a1071aed11610118578063c9b62674116100a0578063eb239c911161006f578063eb239c9114610724578063ef5672b614610744578063f2fde38b14610764578063f6d735b214610784578063fcb72a9c146107b457600080fd5b8063c9b626741461067f578063d88ff1f41461069f578063dc81f1c8146106c1578063ea7cfd8a146106f457600080fd5b8063b5217bb4116100e7578063b5217bb414610587578063bdec022114610616578063c0e046bc14610636578063c3a8574c1461064c578063c7d138cb1461065f57600080fd5b8063a1071aed1461050c578063a344d8431461052c578063aacc40101461055c578063b4ac68601461057257600080fd5b8063670429841161019b5780638da5cb5b1161016a5780638da5cb5b146103f7578063931d15a41461041557806393bf45c6146104355780639dc8cf73146104555780639fe9ada31461049d57600080fd5b8063670429841461035d578063715018a61461039557806371f58f15146103aa578063788e39cd146103ca57600080fd5b80635abf8f85116101e25780635abf8f85146102ba578063603ef649146102da57806366735fd8146102f05780636693643f1461031d5780636695c5b81461033d57600080fd5b806306a03645146102145780634355b8d214610247578063550e6ed1146102675780635aa28f6c14610298575b600080fd5b34801561022057600080fd5b5061023461022f366004613568565b6107d4565b6040519081526020015b60405180910390f35b34801561025357600080fd5b5061023461026236600461359d565b610812565b34801561027357600080fd5b506102346102823660046135bf565b6000908152600260208190526040909120015490565b3480156102a457600080fd5b506102b86102b3366004613715565b61084f565b005b3480156102c657600080fd5b506102346102d536600461359d565b6108de565b3480156102e657600080fd5b5061023460055481565b3480156102fc57600080fd5b5061031061030b36600461379b565b6109c2565b60405161023e91906137c7565b34801561032957600080fd5b50610234610338366004613813565b610acc565b34801561034957600080fd5b506102b861035836600461359d565b610af8565b34801561036957600080fd5b5061037d610378366004613813565b610c3a565b6040516001600160a01b03909116815260200161023e565b3480156103a157600080fd5b506102b8610c4e565b3480156103b657600080fd5b506102b86103c536600461384d565b610c62565b3480156103d657600080fd5b506103ea6103e536600461387d565b610c74565b60405161023e9190613913565b34801561040357600080fd5b506000546001600160a01b031661037d565b34801561042157600080fd5b506102b861043036600461384d565b61105d565b34801561044157600080fd5b506102b861045036600461359d565b6110b8565b34801561046157600080fd5b5061048d6104703660046135bf565b600090815260026020526040902060080154610100900460ff1690565b604051901515815260200161023e565b3480156104a957600080fd5b506104f96104b83660046135bf565b600460208190526000918252604090912080546001820154600283015460038401549484015460059094015492949193909260ff8082169161010090041687565b60405161023e979695949392919061397f565b34801561051857600080fd5b506102b86105273660046139c5565b6113bd565b34801561053857600080fd5b506102346105473660046135bf565b60009081526002602052604090206007015490565b34801561056857600080fd5b5061023460065481565b34801561057e57600080fd5b50600354610234565b34801561059357600080fd5b506106016105a23660046135bf565b600260208190526000918252604090912080546001820154928201546003830154600484015460078501546008909501546001600160a01b0394851696909416949293919260ff80831693610100938490048216938183169291041689565b60405161023e999897969594939291906139fb565b34801561062257600080fd5b506102b8610631366004613a5d565b6113cf565b34801561064257600080fd5b5061023460075481565b6102b861065a36600461359d565b611500565b34801561066b57600080fd5b5061023461067a366004613813565b611780565b34801561068b57600080fd5b506102b861069a36600461384d565b6117e3565b3480156106ab57600080fd5b506106b4611837565b60405161023e9190613af2565b3480156106cd57600080fd5b5061048d6106dc3660046135bf565b60009081526002602052604090206008015460ff1690565b34801561070057600080fd5b5061048d61070f3660046135bf565b60096020526000908152604090205460ff1681565b34801561073057600080fd5b506102b861073f366004613568565b6119d0565b34801561075057600080fd5b506102b861075f36600461384d565b611a75565b34801561077057600080fd5b506102b861077f366004613ba8565b611a87565b34801561079057600080fd5b5061023461079f3660046135bf565b60009081526002602052604090206003015490565b3480156107c057600080fd5b506102346107cf3660046135bf565b611ac5565b6000806107e185856108de565b60009081526004602090815260408083206001600160a01b03871684526006019091529020549150505b9392505050565b60008061081f84846108de565b600081815260046020526040902060028101549192509085146108425784610844565b835b925050505b92915050565b610857611ae6565b6108628560026113bd565b61086d8460026113bd565b600061087986866108de565b90506108888686868686611b13565b60006108948787610812565b6000818152600260208190526040822090810154600190910154929350916108c79085906001600160a01b031684611d38565b90506108d38382611ee8565b505050505050505050565b6000826109265760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c1bdbdb0810481251607a1b60448201526064015b60405180910390fd5b816109675760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c1bdbdb0810881251607a1b604482015260640161091d565b60008284106109765782610978565b835b90506000838510610989578461098b565b835b6040805160208101859052908101829052909150606001604051602081830303815290604052805190602001209250505092915050565b60008381526002602052604081206060916109dd8486613bd9565b905060006109eb8583613bf0565b6006840154909150811115610a01575060068201545b6000610a0d8383613c03565b67ffffffffffffffff811115610a2557610a256135d8565b604051908082528060200260200182016040528015610a4e578160200160208202803683370190505b509050825b82811015610ac057846006018181548110610a7057610a70613c16565b6000918252602090912001546001600160a01b031682610a908684613c03565b81518110610aa057610aa0613c16565b6001600160a01b0390921660209283029190910190910152600101610a53565b50979650505050505050565b60008281526002602090815260408083206001600160a01b038516845260050190915290205492915050565b610b00611f12565b6000610b0c83836108de565b600081815260046020526040902090915060026005820154610100900460ff166002811115610b3d57610b3d61394b565b14610b7e5760405162461bcd60e51b815260206004820152601160248201527026b0ba31b41034b9903737ba1037bb32b960791b604482015260640161091d565b60028101546000610b8f8686610812565b600081815260026020819052604082200154919250610baf8888336107d4565b90506000610bbd8533611780565b90506000610bcb8633610acc565b600087815260026020526040808220600190810154898452918320015492935090918291610c0b918c916001600160a01b03908116911689898989611f3c565b91509150610c198883611ee8565b610c238782611ee8565b50505050505050505050610c3660018055565b5050565b6000610c44611ae6565b61080b838361231b565b610c56611ae6565b610c6060006124f2565b565b610c6a611ae6565b610c36828261105d565b6060610c7e611ae6565b600282511015610cd05760405162461bcd60e51b815260206004820152601960248201527f4174206c65617374203220706f6f6c7320726571756972656400000000000000604482015260640161091d565b60028251610cde9190613c42565b15610d2b5760405162461bcd60e51b815260206004820152601e60248201527f506f6f6c206172726179206c656e677468206d757374206265206576656e0000604482015260640161091d565b600060028351610d3b9190613c56565b67ffffffffffffffff811115610d5357610d536135d8565b604051908082528060200260200182016040528015610d7c578160200160208202803683370190505b50905060005b8351811015611054576000848281518110610d9f57610d9f613c16565b60200260200101519050600085836001610db99190613bf0565b81518110610dc957610dc9613c16565b602090810291909101810151600084815260029092526040808320828452922060048301549193509060ff16610e415760405162461bcd60e51b815260206004820152601b60248201527f546f6b656e20706f6f6c204120646f6573206e6f742065786973740000000000604482015260640161091d565b600481015460ff16610e955760405162461bcd60e51b815260206004820152601b60248201527f546f6b656e20706f6f6c204220646f6573206e6f742065786973740000000000604482015260640161091d565b600782015415610ee75760405162461bcd60e51b815260206004820152601960248201527f506f6f6c204120616c726561647920696e2061206d6174636800000000000000604482015260640161091d565b600781015415610f395760405162461bcd60e51b815260206004820152601960248201527f506f6f6c204220616c726561647920696e2061206d6174636800000000000000604482015260640161091d565b828403610f825760405162461bcd60e51b8152602060048201526017602482015276141bdbdb1cc81b5d5cdd08189948191a5999995c995b9d604a1b604482015260640161091d565b6000610f8e8585612542565b6000868152600260205260408082208783529120600780830184905581018390556004918201805461010061ff001991821681179092559290910180549092161790559050610fdd85856126d7565b60008581526002602081905260408083206008908101805461ffff199081169091558885529190932090920180549092169091558190889061101f9089613c56565b8151811061102f5761102f613c16565b602002602001018181525050505050505060028161104d9190613bf0565b9050610d82565b5090505b919050565b60008281526002602052604090206004015460ff1661108e5760405162461bcd60e51b815260040161091d90613c6a565b60009182526002602052604090912060080180549115156101000261ff0019909216919091179055565b6110c0611f12565b6000828152600260205260409020600481015460ff166111175760405162461bcd60e51b8152602060048201526012602482015271506f6f6c206973206e6f742061637469766560701b604482015260640161091d565b6008810154610100900460ff166111705760405162461bcd60e51b815260206004820152601b60248201527f5769746864726177616c7320617265206e6f7420616c6c6f7765640000000000604482015260640161091d565b600082116111c05760405162461bcd60e51b815260206004820152601960248201527f4d75737420776974686472617720736f6d6520746f6b656e7300000000000000604482015260640161091d565b3360009081526005820160205260409020548211156112165760405162461bcd60e51b8152602060048201526012602482015271496e73756666696369656e742066756e647360701b604482015260640161091d565b8181600201600082825461122a9190613c03565b909155505033600090815260058201602052604081208054849290611250908490613c03565b909155505060018101546001600160a01b03166112d557604051600090339084908381818185875af1925050503d80600081146112a9576040519150601f19603f3d011682016040523d82523d6000602084013e6112ae565b606091505b50509050806112cf5760405162461bcd60e51b815260040161091d90613c97565b5061136c565b600181015460405163a9059cbb60e01b8152336004820152602481018490526001600160a01b0390911690819063a9059cbb906044016020604051808303816000875af115801561132a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061134e9190613cc0565b61136a5760405162461bcd60e51b815260040161091d90613c97565b505b600181015460405183815233916001600160a01b03169085907f4cd16167afcd2e45cd70a8b10d891f374e85f259ef7afd1867fc9be7fcb11331906020015b60405180910390a450610c3660018055565b6113c5611ae6565b610c3682826127fd565b6113d7611ae6565b6113df611f12565b6113ea8660026113bd565b6113f58560026113bd565b600061140187876108de565b90506114108787878787611b13565b600061141c8888610812565b60008181526002602081905260408220908101546001909101549293509161144f9085906001600160a01b031684611d38565b905061145b8382611ee8565b61146a848b8b8b87878d61289f565b60008481526004602052604090206005015460ff16156114be5760405162461bcd60e51b815260206004820152600f60248201526e4d617463682069732061637469766560881b604482015260640161091d565b6114c88a866129b4565b6114d289866129b4565b6114db84612b66565b5050506000908152600960205260409020805460ff1916905560018055505050505050565b611508611f12565b6000828152600260205260409020600481015460ff1661153a5760405162461bcd60e51b815260040161091d90613c6a565b600881015460ff1661158e5760405162461bcd60e51b815260206004820152601860248201527f4465706f7369747320617265206e6f7420616c6c6f7765640000000000000000604482015260640161091d565b60018101546001600160a01b03166115ec578134146115e75760405162461bcd60e51b81526020600482015260156024820152744d7573742073656e6420736f6d6520746f6b656e7360581b604482015260640161091d565b6116d1565b600082116116345760405162461bcd60e51b81526020600482015260156024820152744d7573742073656e6420736f6d6520746f6b656e7360581b604482015260640161091d565b60018101546040516323b872dd60e01b8152336004820152306024820152604481018490526001600160a01b039091169081906323b872dd906064016020604051808303816000875af115801561168f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116b39190613cc0565b6116cf5760405162461bcd60e51b815260040161091d90613c97565b505b818160020160008282546116e59190613bf0565b90915550503360009081526005820160205260408120805484929061170b908490613bf0565b909155505060068101805460018181018355600092835260209092200180546001600160a01b03191633908117909155908201546040516001600160a01b03919091169085907fe40671b740fa5f78e7e7407dc9a0e028808df762f7f97020416b2ac647af2e3f906113ab9087815260200190565b60008281526002602081905260408220015481036117a057506000610849565b6000838152600260208181526040808420928301546001600160a01b03871685526005909301909152909120546117d990612710613bd9565b61080b9190613c56565b60008281526002602052604090206004015460ff166118145760405162461bcd60e51b815260040161091d90613c6a565b600091825260026020526040909120600801805460ff1916911515919091179055565b60035460609060008167ffffffffffffffff811115611858576118586135d8565b6040519080825280602002602001820160405280156118cf57816020015b604080516101208101825260008082526020808301829052928201819052606082018190526080820181905260a0820181905260c0820181905260e0820181905261010082015282526000199092019101816118765790505b50905060005b828110156119c9576000600382815481106118f2576118f2613c16565b6000918252602080832090910154808352600280835260409384902084516101208101865283815260018201546001600160a01b031694810194909452808201549484019490945260038401546060840152600484015460ff8082161515608086015292955060a084019261010090910416908111156119745761197461394b565b8152600883015460ff808216151560208401526101009091041615156040820152600783015460609091015284518590859081106119b4576119b4613c16565b602090810291909101015250506001016118d5565b5092915050565b6119d8611ae6565b60006119e484846108de565b60008181526004602052604090206005015490915060ff1615611a3b5760405162461bcd60e51b815260206004820152600f60248201526e4d617463682069732061637469766560881b604482015260640161091d565b611a4584836129b4565b611a4f83836129b4565b611a5881612b66565b6000818152600960205260409020805460ff191690555b50505050565b611a7d611ae6565b610c3682826117e3565b611a8f611ae6565b6001600160a01b038116611ab957604051631e4fbdf760e01b81526000600482015260240161091d565b611ac2816124f2565b50565b60038181548110611ad557600080fd5b600091825260209091200154905081565b6000546001600160a01b03163314610c605760405163118cdaa760e01b815233600482015260240161091d565b6000611b1f86866108de565b60008181526004602052604090206005015490915060ff16611b7a5760405162461bcd60e51b815260206004820152601460248201527313585d18da08191bd95cc81b9bdd08195e1a5cdd60621b604482015260640161091d565b6001600082815260046020526040902060050154610100900460ff166002811115611ba757611ba761394b565b14611bec5760405162461bcd60e51b81526020600482015260156024820152744d61746368206e6f7420696e2070726f677265737360581b604482015260640161091d565b85841480611bf957508484145b611c3e5760405162461bcd60e51b8152602060048201526016602482015275496e76616c69642077696e6e6572206164647265737360501b604482015260640161091d565b8151835114611c885760405162461bcd60e51b8152602060048201526016602482015275082e4e4c2f2e640d8cadccee8d040dad2e6dac2e8c6d60531b604482015260640161091d565b6000835111611ccf5760405162461bcd60e51b8152602060048201526013602482015272139bc81c1b185e595c9cc81c1c9bdd9a591959606a1b604482015260640161091d565b60008181526004602052604090206002810185905560058101805461ffff1916610200179055611d00828585612be3565b8186887fee20e6cf265453dc32c716ce04a1c54c44b9616a1e738f217f515736509aa9dc60405160405180910390a450505050505050565b6000611d42611f12565b60008481526009602052604090205460ff1615611d715760405162461bcd60e51b815260040161091d90613cdd565b6000848152600960205260408120805460ff1916600117905560085460055484929190611d9e9084613bd9565b611da89190613c56565b90506001600160a01b038516611e2657604051600090339083908381818185875af1925050503d8060008114611dfa576040519150601f19603f3d011682016040523d82523d6000602084013e611dff565b606091505b5050905080611e205760405162461bcd60e51b815260040161091d90613c97565b50611e9c565b60405163a9059cbb60e01b81523360048201526024810182905285906001600160a01b0382169063a9059cbb906044016020604051808303816000875af1158015611e75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e999190613cc0565b50505b6040518181526001600160a01b0386169033907ff0af9bc2c3a4716fef6ce079f5de916f018e0201e2f7052dfeae945801475b2f9060200160405180910390a391505061080b60018055565b60008281526002602052604081206003018054839290611f09908490613c03565b90915550505050565b600260015403611f3557604051633ee5aeb560e01b815260040160405180910390fd5b6002600155565b6000878152600960209081526040808320338452600101909152812054819060ff1615611f7b5760405162461bcd60e51b815260040161091d90613cdd565b600089815260096020908152604080832033845260020190915290205460ff1615611fb85760405162461bcd60e51b815260040161091d90613cdd565b600089815260096020908152604080832033845260030190915290205460ff1615611ff55760405162461bcd60e51b815260040161091d90613cdd565b600089815260096020908152604080832033845260018082018452828520805460ff19908116831790915560028301855283862080548216831790556003909201909352908320805490911690911790556120508786612e42565b9050600061205e8888612e7b565b90506001600160a01b038a166120dc57604051600090339087908381818185875af1925050503d80600081146120b0576040519150601f19603f3d011682016040523d82523d6000602084013e6120b5565b606091505b50509050806120d65760405162461bcd60e51b815260040161091d90613c97565b50612152565b60405163a9059cbb60e01b8152336004820152602481018690528a906001600160a01b0382169063a9059cbb906044016020604051808303816000875af115801561212b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061214f9190613cc0565b50505b6001600160a01b0389166121d55760003361216d8385613bf0565b604051600081818185875af1925050503d80600081146121a9576040519150601f19603f3d011682016040523d82523d6000602084013e6121ae565b606091505b50509050806121cf5760405162461bcd60e51b815260040161091d90613c97565b50612262565b886001600160a01b03811663a9059cbb336121f08587613bf0565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303816000875af115801561223b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061225f9190613cc0565b50505b6040518581526001600160a01b038b16903390600080516020613d208339815191529060200160405180910390a36040518281526001600160a01b038a16903390600080516020613d208339815191529060200160405180910390a36040518181526001600160a01b038a169033907fde02534236523c2e02492e6cfc4cd7cc6003b1891460f414626d77e7c867551f9060200160405180910390a3846123098284613bf0565b93509350505097509795505050505050565b60008281526002602052604081206004015460ff16156123735760405162461bcd60e51b8152602060048201526013602482015272506f6f6c20616c72656164792065786973747360681b604482015260640161091d565b6001600160a01b038216156124325760008290506000816001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156123c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123eb9190613d06565b116124305760405162461bcd60e51b8152602060048201526015602482015274496e76616c696420746f6b656e206164647265737360581b604482015260640161091d565b505b60008381526002602052604080822080546001600160a01b0319908116339081178355600180840180546001600160a01b038a1694168417905560048401805461ffff199081168317909155600885018054610101921691909117905560038054918201815586527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b0188905592519193909187917fc0c143d18100b0ec0b6c08cc52247dd860ffd3fc2af30733326e5f980c19635a91a4509092915050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600081830361258d5760405162461bcd60e51b8152602060048201526017602482015276141bdbdb1cc81b5d5cdd08189948191a5999995c995b9d604a1b604482015260640161091d565b826125ce5760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c1bdbdb0810481251607a1b604482015260640161091d565b8161260f5760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c1bdbdb0810881251607a1b604482015260640161091d565b600061261b84846108de565b60008181526004602052604090206005015490915060ff16156126775760405162461bcd60e51b81526020600482015260146024820152734d6174636820616c72656164792065786973747360601b604482015260640161091d565b600081815260046020526040808220868155600180820187905560058201805461ffff19169091179055905190918391869188917ff94047cb2b767481be8aad8cae3c3ce5f432cfe8dd7b23f50e3d18648b4a7b959190a4509392505050565b60006126e383836108de565b60008181526004602052604090206005015490915060ff1661273e5760405162461bcd60e51b815260206004820152601460248201527313585d18da08191bd95cc81b9bdd08195e1a5cdd60621b604482015260640161091d565b60008082815260046020526040902060050154610100900460ff16600281111561276a5761276a61394b565b146127af5760405162461bcd60e51b815260206004820152601560248201527413585d18da08185b1c9958591e481cdd185c9d1959605a1b604482015260640161091d565b600081815260046020526040808220600501805461ff001916610100179055518291849186917f29d26f27771059d3fdf99a7ea828394ca3980824b18f47ba9959beb3e9f3d87391a4505050565b60008281526002602052604090206004015460ff1661282e5760405162461bcd60e51b815260040161091d90613c6a565b60008281526002602081905260409091206004018054839261ff0019909116906101009084908111156128635761286361394b565b0217905550600281600281111561287c5761287c61394b565b03610c365750600090815260026020819052604090912090810154600390910155565b6000848152600260205260408120905b60068201548110156129255760008260060182815481106128d2576128d2613c16565b60009182526020808320909101548983526002825260408084206001600160a01b0390921680855260059092019092529120549091501561291c5761291c8a8a8a8a8a8a87612e8c565b506001016128af565b5060005b82518110156108d357600083828151811061294657612946613c16565b60200260200101519050600061295d8a8a846107d4565b9050600081118015612995575060008b81526009602090815260408083206001600160a01b038616845260030190915290205460ff16155b156129aa576129aa8b8b8b8b8b8b8888613294565b5050600101612929565b600082815260026020526040902060038101546001909101546001600160a01b0316612a53576000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612a27576040519150601f19603f3d011682016040523d82523d6000602084013e612a2c565b606091505b5050905080612a4d5760405162461bcd60e51b815260040161091d90613c97565b50612afa565b6000838152600260205260409081902060010154905163a9059cbb60e01b81526001600160a01b0384811660048301526024820184905290911690819063a9059cbb906044016020604051808303816000875af1158015612ab8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612adc9190613cc0565b612af85760405162461bcd60e51b815260040161091d90613c97565b505b6000838152600260208190526040822080546001600160a01b0319908116825560018201805490911690559081018290556003810182905560048101805461ffff1916905590612b4d600683018261351f565b5060006007820155600801805461ffff19169055505050565b80612ba65760405162461bcd60e51b815260206004820152601060248201526f125b9d985b1a59081b585d18da08125160821b604482015260640161091d565b6000908152600460208190526040822082815560018101839055600281018390556003810183905590810191909155600501805461ffff19169055565b8051825114612c2d5760405162461bcd60e51b8152602060048201526016602482015275082e4e4c2f2e640d8cadccee8d040dad2e6dac2e8c6d60531b604482015260640161091d565b6000825111612c6d5760405162461bcd60e51b815260206004820152600c60248201526b456d7074792061727261797360a01b604482015260640161091d565b600083815260046020526040812090805b8451811015612de95760006001600160a01b0316858281518110612ca457612ca4613c16565b60200260200101516001600160a01b031603612cfb5760405162461bcd60e51b8152602060048201526016602482015275496e76616c696420706c61796572206164647265737360501b604482015260640161091d565b6000848281518110612d0f57612d0f613c16565b602002602001015111612d645760405162461bcd60e51b815260206004820152601860248201527f496e76616c69642073686172652070657263656e746167650000000000000000604482015260640161091d565b838181518110612d7657612d76613c16565b602002602001015182612d899190613bf0565b9150838181518110612d9d57612d9d613c16565b6020026020010151836006016000878481518110612dbd57612dbd613c16565b6020908102919091018101516001600160a01b0316825281019190915260400160002055600101612c7e565b508061271014612e3b5760405162461bcd60e51b815260206004820152601960248201527f546f74616c20736861726573206d757374206265203130302500000000000000604482015260640161091d565b5050505050565b60008060065484612e539190613bd9565b90506000600854600854612e679190613bd9565b612e718584613bd9565b6108449190613c56565b60008060075484612e539190613bd9565b6000612e9887876108de565b60008181526009602090815260408083206001600160a01b038716845260010190915290205490915060ff1615612ee15760405162461bcd60e51b815260040161091d90613cdd565b60008181526009602090815260408083206001600160a01b038616845260020190915290205460ff1615612f275760405162461bcd60e51b815260040161091d90613cdd565b60008181526009602090815260408083206001600160a01b038616845260018082018452828520805460ff199081168317909155600290920190935290832080549091169091179055612f7b8888856107d4565b90508015612fb45760008281526009602090815260408083206001600160a01b03871684526003019091529020805460ff191660011790555b6000612fc08785611780565b90506000612fce8886610acc565b90506000612fdc8784612e42565b905060008415612ff357612ff08886612e7b565b90505b60008a8152600260205260409020600101546001600160a01b031661308b576000876001600160a01b03168460405160006040518083038185875af1925050503d806000811461305f576040519150601f19603f3d011682016040523d82523d6000602084013e613064565b606091505b50509050806130855760405162461bcd60e51b815260040161091d90613c97565b506130b3565b60008a8152600260205260409020600101546001600160a01b03166130b1818986613457565b505b60006130bf8284613bf0565b905080156131875760008a8152600260205260409020600101546001600160a01b031661315f576000886001600160a01b03168260405160006040518083038185875af1925050503d8060008114613133576040519150601f19603f3d011682016040523d82523d6000602084013e613138565b606091505b50509050806131595760405162461bcd60e51b815260040161091d90613c97565b50613187565b60008a8152600260205260409020600101546001600160a01b0316613185818a84613457565b505b6131918b85611ee8565b61319b8a82611ee8565b60008b8152600260209081526040918290206001015491518681526001600160a01b03928316928b1691600080516020613d20833981519152910160405180910390a382156132285760008a8152600260209081526040918290206001015491518581526001600160a01b03928316928b1691600080516020613d20833981519152910160405180910390a35b81156132845760008a8152600260209081526040918290206001015491518481526001600160a01b03928316928b16917fde02534236523c2e02492e6cfc4cd7cc6003b1891460f414626d77e7c867551f910160405180910390a35b5050505050505050505050505050565b60006132a088886108de565b60008181526009602090815260408083206001600160a01b038816845260030190915290205490915060ff16156132e95760405162461bcd60e51b815260040161091d90613cdd565b60008181526009602090815260408083206001600160a01b03871684526003019091528120805460ff191660011790556133238584612e7b565b9050801561344b576000868152600260205260409020600101546001600160a01b03166133c3576000846001600160a01b03168260405160006040518083038185875af1925050503d8060008114613397576040519150601f19603f3d011682016040523d82523d6000602084013e61339c565b606091505b50509050806133bd5760405162461bcd60e51b815260040161091d90613c97565b506133eb565b6000868152600260205260409020600101546001600160a01b03166133e9818684613457565b505b6133f58682611ee8565b6000868152600260209081526040918290206001015491518381526001600160a01b03928316928716917fde02534236523c2e02492e6cfc4cd7cc6003b1891460f414626d77e7c867551f910160405180910390a35b50505050505050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526134a99084906134ae565b505050565b600080602060008451602086016000885af1806134d1576040513d6000823e3d81fd5b50506000513d915081156134e95780600114156134f6565b6001600160a01b0384163b155b15611a6f57604051635274afe760e01b81526001600160a01b038516600482015260240161091d565b5080546000825590600052602060002090810190611ac291905b8082111561354d5760008155600101613539565b5090565b80356001600160a01b038116811461105857600080fd5b60008060006060848603121561357d57600080fd5b833592506020840135915061359460408501613551565b90509250925092565b600080604083850312156135b057600080fd5b50508035926020909101359150565b6000602082840312156135d157600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715613617576136176135d8565b604052919050565b600067ffffffffffffffff821115613639576136396135d8565b5060051b60200190565b600082601f83011261365457600080fd5b81356136676136628261361f565b6135ee565b8082825260208201915060208360051b86010192508583111561368957600080fd5b602085015b838110156136ad5761369f81613551565b83526020928301920161368e565b5095945050505050565b600082601f8301126136c857600080fd5b81356136d66136628261361f565b8082825260208201915060208360051b8601019250858311156136f857600080fd5b602085015b838110156136ad5780358352602092830192016136fd565b600080600080600060a0868803121561372d57600080fd5b853594506020860135935060408601359250606086013567ffffffffffffffff81111561375957600080fd5b61376588828901613643565b925050608086013567ffffffffffffffff81111561378257600080fd5b61378e888289016136b7565b9150509295509295909350565b6000806000606084860312156137b057600080fd5b505081359360208301359350604090920135919050565b602080825282518282018190526000918401906040840190835b818110156138085783516001600160a01b03168352602093840193909201916001016137e1565b509095945050505050565b6000806040838503121561382657600080fd5b8235915061383660208401613551565b90509250929050565b8015158114611ac257600080fd5b6000806040838503121561386057600080fd5b8235915060208301356138728161383f565b809150509250929050565b60006020828403121561388f57600080fd5b813567ffffffffffffffff8111156138a657600080fd5b8201601f810184136138b757600080fd5b80356138c56136628261361f565b8082825260208201915060208360051b8501019250868311156138e757600080fd5b6020840193505b828410156139095783358252602093840193909101906138ee565b9695505050505050565b602080825282518282018190526000918401906040840190835b8181101561380857835183526020938401939092019160010161392d565b634e487b7160e01b600052602160045260246000fd5b60038110611ac257634e487b7160e01b600052602160045260246000fd5b600060e08201905088825287602083015286604083015285606083015284608083015283151560a08301526139b383613961565b8260c083015298975050505050505050565b600080604083850312156139d857600080fd5b8235915060208301356003811061387257600080fd5b6139f781613961565b9052565b6001600160a01b038a8116825289166020820152604081018890526060810187905285151560808201526101208101613a3386613961565b60a082019590955260c081019390935290151560e083015215156101009091015295945050505050565b60008060008060008060c08789031215613a7657600080fd5b863595506020870135945060408701359350606087013567ffffffffffffffff811115613aa257600080fd5b613aae89828a01613643565b935050608087013567ffffffffffffffff811115613acb57600080fd5b613ad789828a016136b7565b925050613ae660a08801613551565b90509295509295509295565b602080825282518282018190526000918401906040840190835b818110156138085783518051845260018060a01b036020820151166020850152604081015160408501526060810151606085015260808101511515608085015260a0810151613b5e60a08601826139ee565b5060c0810151613b7260c086018215159052565b5060e0810151613b8660e086018215159052565b5061010090810151908401526020939093019261012090920191600101613b0c565b600060208284031215613bba57600080fd5b61080b82613551565b634e487b7160e01b600052601160045260246000fd5b808202811582820484141761084957610849613bc3565b8082018082111561084957610849613bc3565b8181038181111561084957610849613bc3565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601260045260246000fd5b600082613c5157613c51613c2c565b500690565b600082613c6557613c65613c2c565b500490565b602080825260139082015272141bdbdb08191bd95cc81b9bdd08195e1a5cdd606a1b604082015260600190565b6020808252600f908201526e151c985b9cd9995c8819985a5b1959608a1b604082015260600190565b600060208284031215613cd257600080fd5b815161080b8161383f565b6020808252600f908201526e105b1c9958591e4818db185a5b5959608a1b604082015260600190565b600060208284031215613d1857600080fd5b505191905056fe691d3da84f60a8e9f7618970b6df07a3a18b47254d483e44e071f50e8c3cbbfaa264697066735822122053fd9c7ed83ec21ae9d01816091652c14cb6f29e1814602383e89a17e35fc7be64736f6c634300081c0033
Deployed ByteCode
0x60806040526004361061020f5760003560e01c8063a1071aed11610118578063c9b62674116100a0578063eb239c911161006f578063eb239c9114610724578063ef5672b614610744578063f2fde38b14610764578063f6d735b214610784578063fcb72a9c146107b457600080fd5b8063c9b626741461067f578063d88ff1f41461069f578063dc81f1c8146106c1578063ea7cfd8a146106f457600080fd5b8063b5217bb4116100e7578063b5217bb414610587578063bdec022114610616578063c0e046bc14610636578063c3a8574c1461064c578063c7d138cb1461065f57600080fd5b8063a1071aed1461050c578063a344d8431461052c578063aacc40101461055c578063b4ac68601461057257600080fd5b8063670429841161019b5780638da5cb5b1161016a5780638da5cb5b146103f7578063931d15a41461041557806393bf45c6146104355780639dc8cf73146104555780639fe9ada31461049d57600080fd5b8063670429841461035d578063715018a61461039557806371f58f15146103aa578063788e39cd146103ca57600080fd5b80635abf8f85116101e25780635abf8f85146102ba578063603ef649146102da57806366735fd8146102f05780636693643f1461031d5780636695c5b81461033d57600080fd5b806306a03645146102145780634355b8d214610247578063550e6ed1146102675780635aa28f6c14610298575b600080fd5b34801561022057600080fd5b5061023461022f366004613568565b6107d4565b6040519081526020015b60405180910390f35b34801561025357600080fd5b5061023461026236600461359d565b610812565b34801561027357600080fd5b506102346102823660046135bf565b6000908152600260208190526040909120015490565b3480156102a457600080fd5b506102b86102b3366004613715565b61084f565b005b3480156102c657600080fd5b506102346102d536600461359d565b6108de565b3480156102e657600080fd5b5061023460055481565b3480156102fc57600080fd5b5061031061030b36600461379b565b6109c2565b60405161023e91906137c7565b34801561032957600080fd5b50610234610338366004613813565b610acc565b34801561034957600080fd5b506102b861035836600461359d565b610af8565b34801561036957600080fd5b5061037d610378366004613813565b610c3a565b6040516001600160a01b03909116815260200161023e565b3480156103a157600080fd5b506102b8610c4e565b3480156103b657600080fd5b506102b86103c536600461384d565b610c62565b3480156103d657600080fd5b506103ea6103e536600461387d565b610c74565b60405161023e9190613913565b34801561040357600080fd5b506000546001600160a01b031661037d565b34801561042157600080fd5b506102b861043036600461384d565b61105d565b34801561044157600080fd5b506102b861045036600461359d565b6110b8565b34801561046157600080fd5b5061048d6104703660046135bf565b600090815260026020526040902060080154610100900460ff1690565b604051901515815260200161023e565b3480156104a957600080fd5b506104f96104b83660046135bf565b600460208190526000918252604090912080546001820154600283015460038401549484015460059094015492949193909260ff8082169161010090041687565b60405161023e979695949392919061397f565b34801561051857600080fd5b506102b86105273660046139c5565b6113bd565b34801561053857600080fd5b506102346105473660046135bf565b60009081526002602052604090206007015490565b34801561056857600080fd5b5061023460065481565b34801561057e57600080fd5b50600354610234565b34801561059357600080fd5b506106016105a23660046135bf565b600260208190526000918252604090912080546001820154928201546003830154600484015460078501546008909501546001600160a01b0394851696909416949293919260ff80831693610100938490048216938183169291041689565b60405161023e999897969594939291906139fb565b34801561062257600080fd5b506102b8610631366004613a5d565b6113cf565b34801561064257600080fd5b5061023460075481565b6102b861065a36600461359d565b611500565b34801561066b57600080fd5b5061023461067a366004613813565b611780565b34801561068b57600080fd5b506102b861069a36600461384d565b6117e3565b3480156106ab57600080fd5b506106b4611837565b60405161023e9190613af2565b3480156106cd57600080fd5b5061048d6106dc3660046135bf565b60009081526002602052604090206008015460ff1690565b34801561070057600080fd5b5061048d61070f3660046135bf565b60096020526000908152604090205460ff1681565b34801561073057600080fd5b506102b861073f366004613568565b6119d0565b34801561075057600080fd5b506102b861075f36600461384d565b611a75565b34801561077057600080fd5b506102b861077f366004613ba8565b611a87565b34801561079057600080fd5b5061023461079f3660046135bf565b60009081526002602052604090206003015490565b3480156107c057600080fd5b506102346107cf3660046135bf565b611ac5565b6000806107e185856108de565b60009081526004602090815260408083206001600160a01b03871684526006019091529020549150505b9392505050565b60008061081f84846108de565b600081815260046020526040902060028101549192509085146108425784610844565b835b925050505b92915050565b610857611ae6565b6108628560026113bd565b61086d8460026113bd565b600061087986866108de565b90506108888686868686611b13565b60006108948787610812565b6000818152600260208190526040822090810154600190910154929350916108c79085906001600160a01b031684611d38565b90506108d38382611ee8565b505050505050505050565b6000826109265760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c1bdbdb0810481251607a1b60448201526064015b60405180910390fd5b816109675760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c1bdbdb0810881251607a1b604482015260640161091d565b60008284106109765782610978565b835b90506000838510610989578461098b565b835b6040805160208101859052908101829052909150606001604051602081830303815290604052805190602001209250505092915050565b60008381526002602052604081206060916109dd8486613bd9565b905060006109eb8583613bf0565b6006840154909150811115610a01575060068201545b6000610a0d8383613c03565b67ffffffffffffffff811115610a2557610a256135d8565b604051908082528060200260200182016040528015610a4e578160200160208202803683370190505b509050825b82811015610ac057846006018181548110610a7057610a70613c16565b6000918252602090912001546001600160a01b031682610a908684613c03565b81518110610aa057610aa0613c16565b6001600160a01b0390921660209283029190910190910152600101610a53565b50979650505050505050565b60008281526002602090815260408083206001600160a01b038516845260050190915290205492915050565b610b00611f12565b6000610b0c83836108de565b600081815260046020526040902090915060026005820154610100900460ff166002811115610b3d57610b3d61394b565b14610b7e5760405162461bcd60e51b815260206004820152601160248201527026b0ba31b41034b9903737ba1037bb32b960791b604482015260640161091d565b60028101546000610b8f8686610812565b600081815260026020819052604082200154919250610baf8888336107d4565b90506000610bbd8533611780565b90506000610bcb8633610acc565b600087815260026020526040808220600190810154898452918320015492935090918291610c0b918c916001600160a01b03908116911689898989611f3c565b91509150610c198883611ee8565b610c238782611ee8565b50505050505050505050610c3660018055565b5050565b6000610c44611ae6565b61080b838361231b565b610c56611ae6565b610c6060006124f2565b565b610c6a611ae6565b610c36828261105d565b6060610c7e611ae6565b600282511015610cd05760405162461bcd60e51b815260206004820152601960248201527f4174206c65617374203220706f6f6c7320726571756972656400000000000000604482015260640161091d565b60028251610cde9190613c42565b15610d2b5760405162461bcd60e51b815260206004820152601e60248201527f506f6f6c206172726179206c656e677468206d757374206265206576656e0000604482015260640161091d565b600060028351610d3b9190613c56565b67ffffffffffffffff811115610d5357610d536135d8565b604051908082528060200260200182016040528015610d7c578160200160208202803683370190505b50905060005b8351811015611054576000848281518110610d9f57610d9f613c16565b60200260200101519050600085836001610db99190613bf0565b81518110610dc957610dc9613c16565b602090810291909101810151600084815260029092526040808320828452922060048301549193509060ff16610e415760405162461bcd60e51b815260206004820152601b60248201527f546f6b656e20706f6f6c204120646f6573206e6f742065786973740000000000604482015260640161091d565b600481015460ff16610e955760405162461bcd60e51b815260206004820152601b60248201527f546f6b656e20706f6f6c204220646f6573206e6f742065786973740000000000604482015260640161091d565b600782015415610ee75760405162461bcd60e51b815260206004820152601960248201527f506f6f6c204120616c726561647920696e2061206d6174636800000000000000604482015260640161091d565b600781015415610f395760405162461bcd60e51b815260206004820152601960248201527f506f6f6c204220616c726561647920696e2061206d6174636800000000000000604482015260640161091d565b828403610f825760405162461bcd60e51b8152602060048201526017602482015276141bdbdb1cc81b5d5cdd08189948191a5999995c995b9d604a1b604482015260640161091d565b6000610f8e8585612542565b6000868152600260205260408082208783529120600780830184905581018390556004918201805461010061ff001991821681179092559290910180549092161790559050610fdd85856126d7565b60008581526002602081905260408083206008908101805461ffff199081169091558885529190932090920180549092169091558190889061101f9089613c56565b8151811061102f5761102f613c16565b602002602001018181525050505050505060028161104d9190613bf0565b9050610d82565b5090505b919050565b60008281526002602052604090206004015460ff1661108e5760405162461bcd60e51b815260040161091d90613c6a565b60009182526002602052604090912060080180549115156101000261ff0019909216919091179055565b6110c0611f12565b6000828152600260205260409020600481015460ff166111175760405162461bcd60e51b8152602060048201526012602482015271506f6f6c206973206e6f742061637469766560701b604482015260640161091d565b6008810154610100900460ff166111705760405162461bcd60e51b815260206004820152601b60248201527f5769746864726177616c7320617265206e6f7420616c6c6f7765640000000000604482015260640161091d565b600082116111c05760405162461bcd60e51b815260206004820152601960248201527f4d75737420776974686472617720736f6d6520746f6b656e7300000000000000604482015260640161091d565b3360009081526005820160205260409020548211156112165760405162461bcd60e51b8152602060048201526012602482015271496e73756666696369656e742066756e647360701b604482015260640161091d565b8181600201600082825461122a9190613c03565b909155505033600090815260058201602052604081208054849290611250908490613c03565b909155505060018101546001600160a01b03166112d557604051600090339084908381818185875af1925050503d80600081146112a9576040519150601f19603f3d011682016040523d82523d6000602084013e6112ae565b606091505b50509050806112cf5760405162461bcd60e51b815260040161091d90613c97565b5061136c565b600181015460405163a9059cbb60e01b8152336004820152602481018490526001600160a01b0390911690819063a9059cbb906044016020604051808303816000875af115801561132a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061134e9190613cc0565b61136a5760405162461bcd60e51b815260040161091d90613c97565b505b600181015460405183815233916001600160a01b03169085907f4cd16167afcd2e45cd70a8b10d891f374e85f259ef7afd1867fc9be7fcb11331906020015b60405180910390a450610c3660018055565b6113c5611ae6565b610c3682826127fd565b6113d7611ae6565b6113df611f12565b6113ea8660026113bd565b6113f58560026113bd565b600061140187876108de565b90506114108787878787611b13565b600061141c8888610812565b60008181526002602081905260408220908101546001909101549293509161144f9085906001600160a01b031684611d38565b905061145b8382611ee8565b61146a848b8b8b87878d61289f565b60008481526004602052604090206005015460ff16156114be5760405162461bcd60e51b815260206004820152600f60248201526e4d617463682069732061637469766560881b604482015260640161091d565b6114c88a866129b4565b6114d289866129b4565b6114db84612b66565b5050506000908152600960205260409020805460ff1916905560018055505050505050565b611508611f12565b6000828152600260205260409020600481015460ff1661153a5760405162461bcd60e51b815260040161091d90613c6a565b600881015460ff1661158e5760405162461bcd60e51b815260206004820152601860248201527f4465706f7369747320617265206e6f7420616c6c6f7765640000000000000000604482015260640161091d565b60018101546001600160a01b03166115ec578134146115e75760405162461bcd60e51b81526020600482015260156024820152744d7573742073656e6420736f6d6520746f6b656e7360581b604482015260640161091d565b6116d1565b600082116116345760405162461bcd60e51b81526020600482015260156024820152744d7573742073656e6420736f6d6520746f6b656e7360581b604482015260640161091d565b60018101546040516323b872dd60e01b8152336004820152306024820152604481018490526001600160a01b039091169081906323b872dd906064016020604051808303816000875af115801561168f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116b39190613cc0565b6116cf5760405162461bcd60e51b815260040161091d90613c97565b505b818160020160008282546116e59190613bf0565b90915550503360009081526005820160205260408120805484929061170b908490613bf0565b909155505060068101805460018181018355600092835260209092200180546001600160a01b03191633908117909155908201546040516001600160a01b03919091169085907fe40671b740fa5f78e7e7407dc9a0e028808df762f7f97020416b2ac647af2e3f906113ab9087815260200190565b60008281526002602081905260408220015481036117a057506000610849565b6000838152600260208181526040808420928301546001600160a01b03871685526005909301909152909120546117d990612710613bd9565b61080b9190613c56565b60008281526002602052604090206004015460ff166118145760405162461bcd60e51b815260040161091d90613c6a565b600091825260026020526040909120600801805460ff1916911515919091179055565b60035460609060008167ffffffffffffffff811115611858576118586135d8565b6040519080825280602002602001820160405280156118cf57816020015b604080516101208101825260008082526020808301829052928201819052606082018190526080820181905260a0820181905260c0820181905260e0820181905261010082015282526000199092019101816118765790505b50905060005b828110156119c9576000600382815481106118f2576118f2613c16565b6000918252602080832090910154808352600280835260409384902084516101208101865283815260018201546001600160a01b031694810194909452808201549484019490945260038401546060840152600484015460ff8082161515608086015292955060a084019261010090910416908111156119745761197461394b565b8152600883015460ff808216151560208401526101009091041615156040820152600783015460609091015284518590859081106119b4576119b4613c16565b602090810291909101015250506001016118d5565b5092915050565b6119d8611ae6565b60006119e484846108de565b60008181526004602052604090206005015490915060ff1615611a3b5760405162461bcd60e51b815260206004820152600f60248201526e4d617463682069732061637469766560881b604482015260640161091d565b611a4584836129b4565b611a4f83836129b4565b611a5881612b66565b6000818152600960205260409020805460ff191690555b50505050565b611a7d611ae6565b610c3682826117e3565b611a8f611ae6565b6001600160a01b038116611ab957604051631e4fbdf760e01b81526000600482015260240161091d565b611ac2816124f2565b50565b60038181548110611ad557600080fd5b600091825260209091200154905081565b6000546001600160a01b03163314610c605760405163118cdaa760e01b815233600482015260240161091d565b6000611b1f86866108de565b60008181526004602052604090206005015490915060ff16611b7a5760405162461bcd60e51b815260206004820152601460248201527313585d18da08191bd95cc81b9bdd08195e1a5cdd60621b604482015260640161091d565b6001600082815260046020526040902060050154610100900460ff166002811115611ba757611ba761394b565b14611bec5760405162461bcd60e51b81526020600482015260156024820152744d61746368206e6f7420696e2070726f677265737360581b604482015260640161091d565b85841480611bf957508484145b611c3e5760405162461bcd60e51b8152602060048201526016602482015275496e76616c69642077696e6e6572206164647265737360501b604482015260640161091d565b8151835114611c885760405162461bcd60e51b8152602060048201526016602482015275082e4e4c2f2e640d8cadccee8d040dad2e6dac2e8c6d60531b604482015260640161091d565b6000835111611ccf5760405162461bcd60e51b8152602060048201526013602482015272139bc81c1b185e595c9cc81c1c9bdd9a591959606a1b604482015260640161091d565b60008181526004602052604090206002810185905560058101805461ffff1916610200179055611d00828585612be3565b8186887fee20e6cf265453dc32c716ce04a1c54c44b9616a1e738f217f515736509aa9dc60405160405180910390a450505050505050565b6000611d42611f12565b60008481526009602052604090205460ff1615611d715760405162461bcd60e51b815260040161091d90613cdd565b6000848152600960205260408120805460ff1916600117905560085460055484929190611d9e9084613bd9565b611da89190613c56565b90506001600160a01b038516611e2657604051600090339083908381818185875af1925050503d8060008114611dfa576040519150601f19603f3d011682016040523d82523d6000602084013e611dff565b606091505b5050905080611e205760405162461bcd60e51b815260040161091d90613c97565b50611e9c565b60405163a9059cbb60e01b81523360048201526024810182905285906001600160a01b0382169063a9059cbb906044016020604051808303816000875af1158015611e75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e999190613cc0565b50505b6040518181526001600160a01b0386169033907ff0af9bc2c3a4716fef6ce079f5de916f018e0201e2f7052dfeae945801475b2f9060200160405180910390a391505061080b60018055565b60008281526002602052604081206003018054839290611f09908490613c03565b90915550505050565b600260015403611f3557604051633ee5aeb560e01b815260040160405180910390fd5b6002600155565b6000878152600960209081526040808320338452600101909152812054819060ff1615611f7b5760405162461bcd60e51b815260040161091d90613cdd565b600089815260096020908152604080832033845260020190915290205460ff1615611fb85760405162461bcd60e51b815260040161091d90613cdd565b600089815260096020908152604080832033845260030190915290205460ff1615611ff55760405162461bcd60e51b815260040161091d90613cdd565b600089815260096020908152604080832033845260018082018452828520805460ff19908116831790915560028301855283862080548216831790556003909201909352908320805490911690911790556120508786612e42565b9050600061205e8888612e7b565b90506001600160a01b038a166120dc57604051600090339087908381818185875af1925050503d80600081146120b0576040519150601f19603f3d011682016040523d82523d6000602084013e6120b5565b606091505b50509050806120d65760405162461bcd60e51b815260040161091d90613c97565b50612152565b60405163a9059cbb60e01b8152336004820152602481018690528a906001600160a01b0382169063a9059cbb906044016020604051808303816000875af115801561212b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061214f9190613cc0565b50505b6001600160a01b0389166121d55760003361216d8385613bf0565b604051600081818185875af1925050503d80600081146121a9576040519150601f19603f3d011682016040523d82523d6000602084013e6121ae565b606091505b50509050806121cf5760405162461bcd60e51b815260040161091d90613c97565b50612262565b886001600160a01b03811663a9059cbb336121f08587613bf0565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303816000875af115801561223b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061225f9190613cc0565b50505b6040518581526001600160a01b038b16903390600080516020613d208339815191529060200160405180910390a36040518281526001600160a01b038a16903390600080516020613d208339815191529060200160405180910390a36040518181526001600160a01b038a169033907fde02534236523c2e02492e6cfc4cd7cc6003b1891460f414626d77e7c867551f9060200160405180910390a3846123098284613bf0565b93509350505097509795505050505050565b60008281526002602052604081206004015460ff16156123735760405162461bcd60e51b8152602060048201526013602482015272506f6f6c20616c72656164792065786973747360681b604482015260640161091d565b6001600160a01b038216156124325760008290506000816001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156123c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123eb9190613d06565b116124305760405162461bcd60e51b8152602060048201526015602482015274496e76616c696420746f6b656e206164647265737360581b604482015260640161091d565b505b60008381526002602052604080822080546001600160a01b0319908116339081178355600180840180546001600160a01b038a1694168417905560048401805461ffff199081168317909155600885018054610101921691909117905560038054918201815586527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b0188905592519193909187917fc0c143d18100b0ec0b6c08cc52247dd860ffd3fc2af30733326e5f980c19635a91a4509092915050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600081830361258d5760405162461bcd60e51b8152602060048201526017602482015276141bdbdb1cc81b5d5cdd08189948191a5999995c995b9d604a1b604482015260640161091d565b826125ce5760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c1bdbdb0810481251607a1b604482015260640161091d565b8161260f5760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c1bdbdb0810881251607a1b604482015260640161091d565b600061261b84846108de565b60008181526004602052604090206005015490915060ff16156126775760405162461bcd60e51b81526020600482015260146024820152734d6174636820616c72656164792065786973747360601b604482015260640161091d565b600081815260046020526040808220868155600180820187905560058201805461ffff19169091179055905190918391869188917ff94047cb2b767481be8aad8cae3c3ce5f432cfe8dd7b23f50e3d18648b4a7b959190a4509392505050565b60006126e383836108de565b60008181526004602052604090206005015490915060ff1661273e5760405162461bcd60e51b815260206004820152601460248201527313585d18da08191bd95cc81b9bdd08195e1a5cdd60621b604482015260640161091d565b60008082815260046020526040902060050154610100900460ff16600281111561276a5761276a61394b565b146127af5760405162461bcd60e51b815260206004820152601560248201527413585d18da08185b1c9958591e481cdd185c9d1959605a1b604482015260640161091d565b600081815260046020526040808220600501805461ff001916610100179055518291849186917f29d26f27771059d3fdf99a7ea828394ca3980824b18f47ba9959beb3e9f3d87391a4505050565b60008281526002602052604090206004015460ff1661282e5760405162461bcd60e51b815260040161091d90613c6a565b60008281526002602081905260409091206004018054839261ff0019909116906101009084908111156128635761286361394b565b0217905550600281600281111561287c5761287c61394b565b03610c365750600090815260026020819052604090912090810154600390910155565b6000848152600260205260408120905b60068201548110156129255760008260060182815481106128d2576128d2613c16565b60009182526020808320909101548983526002825260408084206001600160a01b0390921680855260059092019092529120549091501561291c5761291c8a8a8a8a8a8a87612e8c565b506001016128af565b5060005b82518110156108d357600083828151811061294657612946613c16565b60200260200101519050600061295d8a8a846107d4565b9050600081118015612995575060008b81526009602090815260408083206001600160a01b038616845260030190915290205460ff16155b156129aa576129aa8b8b8b8b8b8b8888613294565b5050600101612929565b600082815260026020526040902060038101546001909101546001600160a01b0316612a53576000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612a27576040519150601f19603f3d011682016040523d82523d6000602084013e612a2c565b606091505b5050905080612a4d5760405162461bcd60e51b815260040161091d90613c97565b50612afa565b6000838152600260205260409081902060010154905163a9059cbb60e01b81526001600160a01b0384811660048301526024820184905290911690819063a9059cbb906044016020604051808303816000875af1158015612ab8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612adc9190613cc0565b612af85760405162461bcd60e51b815260040161091d90613c97565b505b6000838152600260208190526040822080546001600160a01b0319908116825560018201805490911690559081018290556003810182905560048101805461ffff1916905590612b4d600683018261351f565b5060006007820155600801805461ffff19169055505050565b80612ba65760405162461bcd60e51b815260206004820152601060248201526f125b9d985b1a59081b585d18da08125160821b604482015260640161091d565b6000908152600460208190526040822082815560018101839055600281018390556003810183905590810191909155600501805461ffff19169055565b8051825114612c2d5760405162461bcd60e51b8152602060048201526016602482015275082e4e4c2f2e640d8cadccee8d040dad2e6dac2e8c6d60531b604482015260640161091d565b6000825111612c6d5760405162461bcd60e51b815260206004820152600c60248201526b456d7074792061727261797360a01b604482015260640161091d565b600083815260046020526040812090805b8451811015612de95760006001600160a01b0316858281518110612ca457612ca4613c16565b60200260200101516001600160a01b031603612cfb5760405162461bcd60e51b8152602060048201526016602482015275496e76616c696420706c61796572206164647265737360501b604482015260640161091d565b6000848281518110612d0f57612d0f613c16565b602002602001015111612d645760405162461bcd60e51b815260206004820152601860248201527f496e76616c69642073686172652070657263656e746167650000000000000000604482015260640161091d565b838181518110612d7657612d76613c16565b602002602001015182612d899190613bf0565b9150838181518110612d9d57612d9d613c16565b6020026020010151836006016000878481518110612dbd57612dbd613c16565b6020908102919091018101516001600160a01b0316825281019190915260400160002055600101612c7e565b508061271014612e3b5760405162461bcd60e51b815260206004820152601960248201527f546f74616c20736861726573206d757374206265203130302500000000000000604482015260640161091d565b5050505050565b60008060065484612e539190613bd9565b90506000600854600854612e679190613bd9565b612e718584613bd9565b6108449190613c56565b60008060075484612e539190613bd9565b6000612e9887876108de565b60008181526009602090815260408083206001600160a01b038716845260010190915290205490915060ff1615612ee15760405162461bcd60e51b815260040161091d90613cdd565b60008181526009602090815260408083206001600160a01b038616845260020190915290205460ff1615612f275760405162461bcd60e51b815260040161091d90613cdd565b60008181526009602090815260408083206001600160a01b038616845260018082018452828520805460ff199081168317909155600290920190935290832080549091169091179055612f7b8888856107d4565b90508015612fb45760008281526009602090815260408083206001600160a01b03871684526003019091529020805460ff191660011790555b6000612fc08785611780565b90506000612fce8886610acc565b90506000612fdc8784612e42565b905060008415612ff357612ff08886612e7b565b90505b60008a8152600260205260409020600101546001600160a01b031661308b576000876001600160a01b03168460405160006040518083038185875af1925050503d806000811461305f576040519150601f19603f3d011682016040523d82523d6000602084013e613064565b606091505b50509050806130855760405162461bcd60e51b815260040161091d90613c97565b506130b3565b60008a8152600260205260409020600101546001600160a01b03166130b1818986613457565b505b60006130bf8284613bf0565b905080156131875760008a8152600260205260409020600101546001600160a01b031661315f576000886001600160a01b03168260405160006040518083038185875af1925050503d8060008114613133576040519150601f19603f3d011682016040523d82523d6000602084013e613138565b606091505b50509050806131595760405162461bcd60e51b815260040161091d90613c97565b50613187565b60008a8152600260205260409020600101546001600160a01b0316613185818a84613457565b505b6131918b85611ee8565b61319b8a82611ee8565b60008b8152600260209081526040918290206001015491518681526001600160a01b03928316928b1691600080516020613d20833981519152910160405180910390a382156132285760008a8152600260209081526040918290206001015491518581526001600160a01b03928316928b1691600080516020613d20833981519152910160405180910390a35b81156132845760008a8152600260209081526040918290206001015491518481526001600160a01b03928316928b16917fde02534236523c2e02492e6cfc4cd7cc6003b1891460f414626d77e7c867551f910160405180910390a35b5050505050505050505050505050565b60006132a088886108de565b60008181526009602090815260408083206001600160a01b038816845260030190915290205490915060ff16156132e95760405162461bcd60e51b815260040161091d90613cdd565b60008181526009602090815260408083206001600160a01b03871684526003019091528120805460ff191660011790556133238584612e7b565b9050801561344b576000868152600260205260409020600101546001600160a01b03166133c3576000846001600160a01b03168260405160006040518083038185875af1925050503d8060008114613397576040519150601f19603f3d011682016040523d82523d6000602084013e61339c565b606091505b50509050806133bd5760405162461bcd60e51b815260040161091d90613c97565b506133eb565b6000868152600260205260409020600101546001600160a01b03166133e9818684613457565b505b6133f58682611ee8565b6000868152600260209081526040918290206001015491518381526001600160a01b03928316928716917fde02534236523c2e02492e6cfc4cd7cc6003b1891460f414626d77e7c867551f910160405180910390a35b50505050505050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526134a99084906134ae565b505050565b600080602060008451602086016000885af1806134d1576040513d6000823e3d81fd5b50506000513d915081156134e95780600114156134f6565b6001600160a01b0384163b155b15611a6f57604051635274afe760e01b81526001600160a01b038516600482015260240161091d565b5080546000825590600052602060002090810190611ac291905b8082111561354d5760008155600101613539565b5090565b80356001600160a01b038116811461105857600080fd5b60008060006060848603121561357d57600080fd5b833592506020840135915061359460408501613551565b90509250925092565b600080604083850312156135b057600080fd5b50508035926020909101359150565b6000602082840312156135d157600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715613617576136176135d8565b604052919050565b600067ffffffffffffffff821115613639576136396135d8565b5060051b60200190565b600082601f83011261365457600080fd5b81356136676136628261361f565b6135ee565b8082825260208201915060208360051b86010192508583111561368957600080fd5b602085015b838110156136ad5761369f81613551565b83526020928301920161368e565b5095945050505050565b600082601f8301126136c857600080fd5b81356136d66136628261361f565b8082825260208201915060208360051b8601019250858311156136f857600080fd5b602085015b838110156136ad5780358352602092830192016136fd565b600080600080600060a0868803121561372d57600080fd5b853594506020860135935060408601359250606086013567ffffffffffffffff81111561375957600080fd5b61376588828901613643565b925050608086013567ffffffffffffffff81111561378257600080fd5b61378e888289016136b7565b9150509295509295909350565b6000806000606084860312156137b057600080fd5b505081359360208301359350604090920135919050565b602080825282518282018190526000918401906040840190835b818110156138085783516001600160a01b03168352602093840193909201916001016137e1565b509095945050505050565b6000806040838503121561382657600080fd5b8235915061383660208401613551565b90509250929050565b8015158114611ac257600080fd5b6000806040838503121561386057600080fd5b8235915060208301356138728161383f565b809150509250929050565b60006020828403121561388f57600080fd5b813567ffffffffffffffff8111156138a657600080fd5b8201601f810184136138b757600080fd5b80356138c56136628261361f565b8082825260208201915060208360051b8501019250868311156138e757600080fd5b6020840193505b828410156139095783358252602093840193909101906138ee565b9695505050505050565b602080825282518282018190526000918401906040840190835b8181101561380857835183526020938401939092019160010161392d565b634e487b7160e01b600052602160045260246000fd5b60038110611ac257634e487b7160e01b600052602160045260246000fd5b600060e08201905088825287602083015286604083015285606083015284608083015283151560a08301526139b383613961565b8260c083015298975050505050505050565b600080604083850312156139d857600080fd5b8235915060208301356003811061387257600080fd5b6139f781613961565b9052565b6001600160a01b038a8116825289166020820152604081018890526060810187905285151560808201526101208101613a3386613961565b60a082019590955260c081019390935290151560e083015215156101009091015295945050505050565b60008060008060008060c08789031215613a7657600080fd5b863595506020870135945060408701359350606087013567ffffffffffffffff811115613aa257600080fd5b613aae89828a01613643565b935050608087013567ffffffffffffffff811115613acb57600080fd5b613ad789828a016136b7565b925050613ae660a08801613551565b90509295509295509295565b602080825282518282018190526000918401906040840190835b818110156138085783518051845260018060a01b036020820151166020850152604081015160408501526060810151606085015260808101511515608085015260a0810151613b5e60a08601826139ee565b5060c0810151613b7260c086018215159052565b5060e0810151613b8660e086018215159052565b5061010090810151908401526020939093019261012090920191600101613b0c565b600060208284031215613bba57600080fd5b61080b82613551565b634e487b7160e01b600052601160045260246000fd5b808202811582820484141761084957610849613bc3565b8082018082111561084957610849613bc3565b8181038181111561084957610849613bc3565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601260045260246000fd5b600082613c5157613c51613c2c565b500690565b600082613c6557613c65613c2c565b500490565b602080825260139082015272141bdbdb08191bd95cc81b9bdd08195e1a5cdd606a1b604082015260600190565b6020808252600f908201526e151c985b9cd9995c8819985a5b1959608a1b604082015260600190565b600060208284031215613cd257600080fd5b815161080b8161383f565b6020808252600f908201526e105b1c9958591e4818db185a5b5959608a1b604082015260600190565b600060208284031215613d1857600080fd5b505191905056fe691d3da84f60a8e9f7618970b6df07a3a18b47254d483e44e071f50e8c3cbbfaa264697066735822122053fd9c7ed83ec21ae9d01816091652c14cb6f29e1814602383e89a17e35fc7be64736f6c634300081c0033