Latest 25 from a total of 2,960 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Close | 61217653 | 1 hr ago | IN | 0 S | 0.00375342 | ||||
| Claim | 61217643 | 1 hr ago | IN | 0 S | 0.00737082 | ||||
| Join | 61217169 | 1 hr ago | IN | 0 S | 0.00803907 | ||||
| Claim | 61211447 | 3 hrs ago | IN | 0 S | 0.00737082 | ||||
| Set Result | 61189933 | 9 hrs ago | IN | 0 S | 0.00389425 | ||||
| Set Result | 61189931 | 9 hrs ago | IN | 0 S | 0.00389425 | ||||
| Join | 61184108 | 11 hrs ago | IN | 0 S | 0.00803907 | ||||
| Create | 61180524 | 12 hrs ago | IN | 0 S | 0.0186988 | ||||
| Create | 61180518 | 12 hrs ago | IN | 0 S | 0.0186988 | ||||
| Join | 61127599 | 27 hrs ago | IN | 0 S | 0.00803907 | ||||
| Join | 61127596 | 27 hrs ago | IN | 0 S | 0.00803907 | ||||
| Join | 61073827 | 2 days ago | IN | 0 S | 0.00803907 | ||||
| Close | 61073773 | 2 days ago | IN | 0 S | 0.00361889 | ||||
| Close | 61073764 | 2 days ago | IN | 0 S | 0.00375342 | ||||
| Claim | 61073752 | 2 days ago | IN | 0 S | 0.0064966 | ||||
| Claim | 61073734 | 2 days ago | IN | 0 S | 0.00649605 | ||||
| Join | 61066346 | 2 days ago | IN | 0 S | 0.00803907 | ||||
| Join | 61066318 | 2 days ago | IN | 0 S | 0.00897957 | ||||
| Close | 61066307 | 2 days ago | IN | 0 S | 0.00325182 | ||||
| Claim | 61066303 | 2 days ago | IN | 0 S | 0.00737082 | ||||
| Close | 61066294 | 2 days ago | IN | 0 S | 0.00361889 | ||||
| Claim | 61066285 | 2 days ago | IN | 0 S | 0.00655979 | ||||
| Close | 61066269 | 2 days ago | IN | 0 S | 0.00374836 | ||||
| Claim | 61066257 | 2 days ago | IN | 0 S | 0.0074371 | ||||
| Close | 61052459 | 2 days ago | IN | 0 S | 0.00361889 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Cross-Chain Transactions
Loading...
Loading
Contract Name:
BurnBitArenaContract
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
No with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "../openzepline/contracts/utils/ReentrancyGuard.sol";
import "../openzepline/contracts/token/ERC20/IERC20.sol";
import "../openzepline/contracts/utils/cryptography/MerkleProof.sol";
import "../openzepline/contracts/access/AccessControl.sol";
import "../openzepline/contracts/utils/math/Math.sol";
import {DataTypes, IAirdrop} from "./DataTypes.sol";
// Specialized libraries
import {ArenaCreateLib} from "./ArenaCreateLib.sol";
import {ArenaJoinLib} from "./ArenaJoinLib.sol";
import {ArenaRewardLib} from "./ArenaRewardLib.sol";
import {ArenaViewLib} from "./ArenaViewLib.sol";
/**
* @title BurnBitArenaContract
* @notice Main entry-point for users and admins; delegates logic to specialized libraries.
*/
contract BurnBitArenaContract is AccessControl, ReentrancyGuard {
using ArenaCreateLib for DataTypes.ArenaStorage;
using ArenaJoinLib for DataTypes.ArenaStorage;
using ArenaRewardLib for DataTypes.ArenaStorage;
using ArenaViewLib for DataTypes.ArenaStorage;
using Math for uint256;
// -----------------------------------
// Custom Errors
// -----------------------------------
error E1(); // generic invalid addresses or zero address
error E2();
error E3();
error P(); // "Paused"
error Bl(); // "Blocked"
error IAdd(); // "Invalid address"
error BS(); // "Bad State"
error CA(); // "Challenge active"
error TF(); // "Transfer failed"
error TMC(); // "Too many challenges"
error CF(); // "Challenge full"
// -----------------------------------
// Storage
// -----------------------------------
DataTypes.ArenaStorage internal s;
// -----------------------------------
// Roles
// -----------------------------------
bytes32 public constant R_ORACLE = keccak256("ORACLE");
bytes32 public constant R_AFFILIATE = keccak256("AFFILIATE");
bytes32 public constant R_ADMIN = keccak256("ADMIN");
// -----------------------------------
// Events
// (Renamed to short names to reduce bytecode.)
// -----------------------------------
event ECR(address indexed u, uint256 indexed c); // BCreate
event EJN(address indexed u, uint256 indexed c); // BJoin
event ECL(address indexed u, uint256 indexed c); // BClosed
event EWD(address indexed u, uint256 indexed c, uint256 a); // BWithdraw
event ERCM(address indexed u, uint256 indexed c, uint256 a);// BReclaim
event ECu(address indexed a, bool s, bool c, uint8 v, uint256 p); // update state
event ECan(uint256 indexed c); // BCancelled
event EFor(uint256 indexed c, address indexed u, uint256 p);// BForfeit
event ERew(uint256 indexed c, bytes32 r); // BRewardPublished
event EBlk(address indexed u); // BBlocked
event ECon(uint256 indexed c, address indexed u, uint256 p); // BConcluded
// -----------------------------------
// Constructor
// -----------------------------------
constructor(IERC20 bBitToken, uint256 maxPotValue, IAirdrop airdropAddress) {
if (
address(airdropAddress) == address(0) ||
address(bBitToken) == address(0)
) revert E1();
s.bBit = address(bBitToken);
s.airdrop = address(airdropAddress);
s.config = DataTypes.ArenaConfig({
maxPotValue: maxPotValue,
cancelAll: false,
paused: false,
maxActive: 3
});
if (!IERC20(s.bBit).approve(s.airdrop, type(uint256).max)) revert TF();
// Grant roles in a loop to reduce code repetition
bytes32[4] memory roles = [DEFAULT_ADMIN_ROLE, R_ADMIN, R_ORACLE, R_AFFILIATE];
for (uint256 i; i < 4;) {
_grantRole(roles[i], msg.sender);
unchecked {++i;}
}
}
// -----------------------------------
// Modifiers
// -----------------------------------
modifier notPaused() {
if (s.config.paused) revert P();
_;
}
modifier notBlocked() {
if (s.blocked[msg.sender]) revert Bl();
_;
}
// -----------------------------------
// Admin Functions
// -----------------------------------
function blockUser(address user) external onlyRole(R_ADMIN) {
s.blocked[user] = true;
emit EBlk(user);
}
/**
* @notice Updates multiple configuration parameters in a single transaction.
* @param max max active users.
* @param cancelAll Whether to cancel all challenges.
* @param pause Whether to pause the platform.
* @param maxPotValue Maximum Value of a challenge pot
*/
function updateState(uint8 max, bool cancelAll, bool pause, uint256 maxPotValue) external onlyRole(R_ADMIN) notBlocked {
s.config.cancelAll = cancelAll;
s.config.paused = pause;
s.config.maxActive = max;
s.config.maxPotValue = maxPotValue;
// Emit the combined event
emit ECu(msg.sender, cancelAll, pause, max, maxPotValue);
}
function cancel(uint256 challengeId) external nonReentrant notBlocked {
DataTypes.Challenge storage comp = s.challenges[challengeId];
// Combining checks to reduce code size:
if (
s.challengeMerkleRoots[challengeId] != bytes32(0) ||
comp.cancelled ||
// If not admin, user must be the creator & challenge not started or <2 people
!(
hasRole(R_ADMIN, msg.sender) ||
(
comp.creator == msg.sender &&
(
comp.startAndEndTime[0] > block.timestamp ||
comp.enrolledUsersCount < 2
)
)
)
) revert BS();
uint256 refundAmount = s.cancelChallenge(challengeId);
if (refundAmount > 0 && !IERC20(s.bBit).transfer(comp.creator, refundAmount)) revert TF();
emit ECan(challengeId);
}
// -----------------------------------
// Competition Operations
// -----------------------------------
function create(
uint256 buyInAmount,
uint256[] calldata startAndEndDates,
uint256[] calldata joinAndForfeitFees,
uint8[] calldata metricAndCompStyle,
uint256 initialStake,
uint32 maximumNumberOfUsers,
uint32 challengeGoal
) external onlyRole(R_AFFILIATE) notPaused nonReentrant notBlocked {
uint256 challengeId = s.createChallenge(
buyInAmount,
startAndEndDates,
joinAndForfeitFees,
metricAndCompStyle,
initialStake,
maximumNumberOfUsers,
challengeGoal,
msg.sender
);
if (initialStake > 0 && !IERC20(s.bBit).transferFrom(msg.sender, address(this), initialStake)) revert TF();
emit ECR(msg.sender, challengeId);
}
function join(uint256 challengeId) external nonReentrant notPaused notBlocked {
(uint256 airdropAmt, uint256 remainingCost) = s.joinChallenge(challengeId, msg.sender);
// Deduct from airdrop first
if (airdropAmt > 0) {
IAirdrop(s.airdrop).withdraw(msg.sender, airdropAmt);
}
// Deduct remaining from user's ERC20
if (remainingCost > 0 && !IERC20(s.bBit).transferFrom(msg.sender, address(this), remainingCost)) revert TF();
emit EJN(msg.sender, challengeId);
}
function forfeit(uint256 challengeId) external nonReentrant {
DataTypes.Challenge storage challenge = s.challenges[challengeId];
if (challenge.startAndEndTime.length < 2) revert BS();
if (block.timestamp > challenge.startAndEndTime[0]) revert CA();
(uint256 amountToWallet, uint256 amountToAirdrop, uint256 forfeitFee) = s.forfeit(challengeId, msg.sender);
// Return to airdrop if needed
if (amountToAirdrop > 0) {
IAirdrop(s.airdrop).deposit(msg.sender, amountToAirdrop);
}
// Balance to user
if (amountToWallet > 0 && !IERC20(s.bBit).transfer(msg.sender, amountToWallet)) revert TF();
if (forfeitFee > 0 && !IERC20(s.bBit).transfer(challenge.creator, forfeitFee)) revert TF();
emit EFor(challengeId, msg.sender, amountToWallet + amountToAirdrop);
}
function close(uint256 challengeId) external notBlocked {
DataTypes.Challenge storage challenge = s.challenges[challengeId];
if (challenge.startAndEndTime.length < 2) revert BS();
s.closeChallenge(challengeId, msg.sender);
emit ECL(msg.sender, challengeId);
}
function reclaimStake(uint256 challengeId) external nonReentrant {
DataTypes.Challenge storage comp = s.challenges[challengeId];
if (
comp.startAndEndTime.length < 2 ||
(!s.config.cancelAll && !comp.cancelled)
) revert BS();
(uint256 amountToWallet, uint256 amountToAirdrop) = s.reclaimStake(challengeId, msg.sender);
if (amountToAirdrop > 0) {
IAirdrop(s.airdrop).deposit(msg.sender, amountToAirdrop);
}
if (amountToWallet > 0 && !IERC20(s.bBit).transfer(msg.sender, amountToWallet)) revert TF();
emit ERCM(msg.sender, challengeId, amountToWallet + amountToAirdrop);
}
// -----------------------------------
// Reward Distribution
// -----------------------------------
function setResult(uint256 challengeId, bytes32 root, uint256 totalReward)
external
onlyRole(R_ORACLE)
{
DataTypes.Challenge storage challenge = s.challenges[challengeId];
if (challenge.startAndEndTime.length < 2 || challenge.startAndEndTime[1] >= block.timestamp) revert CA();
if (challenge.totalStake < totalReward) revert BS();
s.setResult(challengeId, root);
challenge.totalReward = totalReward;
emit ERew(challengeId, root);
}
function claim(
uint256 challengeId,
uint256 rewardAmount,
bytes32[] memory rewardProof
) external nonReentrant notPaused notBlocked {
DataTypes.Challenge storage comp = s.challenges[challengeId];
if (comp.startAndEndTime.length < 2 || comp.startAndEndTime[1] >= block.timestamp) revert CA();
if (s.challengeMerkleRoots[challengeId] == bytes32(0)) revert BS();
uint256 payout = s.claimReward(challengeId, msg.sender, rewardAmount, rewardProof);
if (payout > 0 && !IERC20(s.bBit).transfer(msg.sender, payout)) revert TF();
emit EWD(msg.sender, challengeId, payout);
}
function conclude(uint256 challengeId, address feeCollector) external nonReentrant {
DataTypes.Challenge storage challenge = s.challenges[challengeId];
if (s.challengeMerkleRoots[challengeId] == bytes32(0)) revert BS();
if (challenge.startAndEndTime.length < 2 || challenge.startAndEndTime[1] >= block.timestamp) revert CA();
uint256 totalAmountToPayout = s.concludeChallenge(challengeId);
address payFeeTo = challenge.creator;
// Only the creator can modify where the fees payout goes to
if (challenge.creator == msg.sender && feeCollector != address(0)) {
payFeeTo = feeCollector;
}
if (totalAmountToPayout > 0 && !IERC20(s.bBit).transfer(payFeeTo, totalAmountToPayout)) revert TF();
emit ECon(challengeId, payFeeTo, totalAmountToPayout);
}
// -----------------------------------
// Views
// -----------------------------------
function getLatestChallengeId()
external
view
returns (uint256) {
return s.challengeIdCounter;
}
function getChallenge(uint256 challengeId)
external
view
returns (DataTypes.Challenge memory) {
return s.getChallenge(challengeId);
}
function getUserChallenge(address user, uint256 challengeId)
external
view
returns (DataTypes.UserChallenge memory)
{
return s.userChallenges[user][challengeId];
}
function getUserChallengesSizes(address user)
external
view
returns (uint256 activeSize, uint256 archivedSize)
{
(activeSize, archivedSize) = s.getUserChallengesSize(user);
}
function getAffiliateChallenge(address user, uint256 index)
external
view
returns (uint256 challengeId, uint256 size)
{
(challengeId, size) = s.getAffiliateChallenge(user, index);
}
function getConfig() external view returns (DataTypes.ArenaConfig memory) {
return s.config;
}
function resultPublished(uint256 challengeId) external view returns (bool) {
return s.challengeMerkleRoots[challengeId] != bytes32(0);
}
function enrolledIds(
address user,
uint256 startIndex,
uint256 endIndex,
bool fromArchive
) external view returns (uint256[] memory) {
// Compute how many items we need
uint256 length = endIndex - startIndex;
// Allocate the memory array
uint256[] memory challengeIds = new uint256[](length);
// Fill the array
for (uint256 i = 0; i < length;) {
challengeIds[i] = s.getUserChallengeAtIndex(user, startIndex + i, fromArchive);
unchecked {++i;}
}
return challengeIds;
}
function enrolled(
uint256 challengeId,
address[] memory addresses
)
external
view
returns (bool[] memory) {
uint256 length = addresses.length;
bool[] memory isParticipant = new bool[](length);
for (uint256 i = 0; i < length;) {
isParticipant[i] = s.challengeUsers[challengeId][addresses[i]];
unchecked {++i;}
}
return isParticipant;
}
function fetchChallengesCheckEnrolled(
address caller,
uint256[] memory ids
)
external
view
returns (DataTypes.Challenge[] memory, bool[] memory)
{
// Compute length upfront
uint256 length = ids.length;
// Allocate fixed-size memory arrays
DataTypes.Challenge[] memory challenges = new DataTypes.Challenge[](length);
bool[] memory callerIsParticipant = new bool[](length);
for (uint256 i = 0; i < length;) {
challenges[i] = s.getChallenge(ids[i]);
callerIsParticipant[i] = s.challengeUsers[ids[i]][caller];
unchecked {++i;}
}
return (challenges, callerIsParticipant);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {DataTypes} from "./DataTypes.sol";
/**
* @title ArenaCreateLib
* @notice Handles creation and cancellation of challenges.
*/
library ArenaCreateLib {
error StartTimeError();
error EndTimeError();
error BuyInZero();
error MaxUsersZero();
error FeeMismatch();
error MaxPotExceeded();
/**
* @notice Creates a new challenge in storage.
* @return challengeId The ID of the newly created challenge.
*/
function createChallenge(
DataTypes.ArenaStorage storage s,
uint256 buyInAmount,
uint256[] calldata startAndEndTime,
uint256[] calldata joinAndForfeitFees,
uint8[] calldata metricTypeAndCompStyle,
uint256 initialStake,
uint32 maximumNumberOfUsers,
uint32 challengeGoal,
address creator
) internal returns (uint256 challengeId) {
if (startAndEndTime[0] <= block.timestamp) revert StartTimeError();
if (startAndEndTime[1] <= startAndEndTime[0]) revert EndTimeError();
if (buyInAmount == 0) revert BuyInZero();
if (maximumNumberOfUsers == 0) revert MaxUsersZero();
if ((buyInAmount * maximumNumberOfUsers) > s.config.maxPotValue) revert MaxPotExceeded();
if (joinAndForfeitFees.length < 2 || joinAndForfeitFees[0] >= buyInAmount || joinAndForfeitFees[1] >= buyInAmount) revert FeeMismatch();
s.challengeIdCounter++;
challengeId = s.challengeIdCounter;
DataTypes.Challenge storage c = s.challenges[challengeId];
c.totalStake = initialStake;
c.buyInAmount = buyInAmount;
c.startAndEndTime = startAndEndTime;
c.maximumNumberOfUsers = maximumNumberOfUsers;
c.joinAndForfeitFees = joinAndForfeitFees;
c.metricTypeAndCompStyle = metricTypeAndCompStyle;
c.challengeGoal = challengeGoal;
c.creator = creator;
c.totalReward = 0;
s.affiliateChallenges[creator].push(challengeId);
}
/**
* @notice Cancels a challenge (sets cancelled flag to true).
*/
function cancelChallenge(DataTypes.ArenaStorage storage s, uint256 challengeId)
internal
returns (uint256)
{
DataTypes.Challenge storage challenge = s.challenges[challengeId];
challenge.cancelled = true;
uint256 refundAmount = challenge.totalStake
- (challenge.buyInAmount * challenge.enrolledUsersCount);
challenge.totalStake -= refundAmount;
return refundAmount;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {DataTypes, IAirdrop} from "./DataTypes.sol";
/**
* @title ArenaJoinLib
* @notice Handles user enrollment, closing, forfeiture, and reclamation logic.
*/
library ArenaJoinLib {
// Consolidated Errors to reduce bytecode size
error X(); // Combined "Bad State", "Challenge Full", "Too Many Challenges"
/**
* @dev Internal function to remove a challenge from a user's active list
* and optionally move it to the archived list.
* Optimized by reducing storage reads and using unchecked increments.
*/
function _closeChallenge(
DataTypes.ArenaStorage storage s,
address user,
uint256 challengeId,
bool shouldArchive
) internal {
uint256[] storage activeChallenges = s.userActiveChallenges[user];
uint256 length = activeChallenges.length;
for (uint256 i = 0; i < length;) {
if (activeChallenges[i] == challengeId) {
activeChallenges[i] = activeChallenges[length - 1];
activeChallenges.pop();
if (shouldArchive) {
s.userArchivedChallenges[user].push(challengeId);
}
break;
}
unchecked {++i;}
}
}
/**
* @notice Enroll user in a challenge (join).
* @dev Optimized by caching storage variables and simplifying calculations.
*/
function joinChallenge(
DataTypes.ArenaStorage storage s,
uint256 challengeId,
address user
) internal returns (uint256 airdropAmt, uint256 remainingCost) {
DataTypes.Challenge storage challenge = s.challenges[challengeId];
// Simplified and consolidated checks
if (
challenge.startAndEndTime.length < 2 ||
challenge.cancelled ||
challenge.enrolledUsersCount >= challenge.maximumNumberOfUsers ||
s.userActiveChallenges[user].length >= s.config.maxActive ||
s.challengeUsers[challengeId][user] ||
block.timestamp > challenge.startAndEndTime[0]
) {
revert X();
}
// Update challenge and user data
challenge.enrolledUsersCount += 1;
challenge.totalStake += challenge.buyInAmount;
s.challengeUsers[challengeId][user] = true;
s.userActiveChallenges[user].push(challengeId);
// Calculate costs
uint256 totalCost = challenge.buyInAmount + challenge.joinAndForfeitFees[0];
uint256 airdropBal = IAirdrop(s.airdrop).balanceOf(user);
if (airdropBal >= totalCost) {
airdropAmt = totalCost;
remainingCost = 0;
} else {
airdropAmt = airdropBal;
remainingCost = totalCost - airdropBal;
}
// Initialize user's challenge data
s.userChallenges[user][challengeId] = DataTypes.UserChallenge({
amountWithdrawn: 0,
amountFromAirdrop: airdropAmt,
withdrawn: false
});
return (airdropAmt, remainingCost);
}
/**
* @notice Close challenge for a user (only if challenge has ended).
* @dev Optimized by consolidating state changes.
*/
function closeChallenge(
DataTypes.ArenaStorage storage s,
uint256 challengeId,
address user
) internal {
if (!s.challengeUsers[challengeId][user]) {
revert X();
}
s.challengeUsers[challengeId][user] = false;
_closeChallenge(s, user, challengeId, true);
}
/**
* @notice Allow a user to reclaim their stake (if the entire platform or challenge is cancelled).
* @dev Optimized by reducing storage writes and simplifying calculations.
*/
function reclaimStake(
DataTypes.ArenaStorage storage s,
uint256 challengeId,
address user
) internal returns (uint256 amountToWallet, uint256 amountToAirdrop) {
DataTypes.Challenge storage challenge = s.challenges[challengeId];
DataTypes.UserChallenge storage userChallenge = s.userChallenges[user][challengeId];
if (!s.challengeUsers[challengeId][user] || userChallenge.withdrawn) {
revert X();
}
// Update user and challenge data
s.challengeUsers[challengeId][user] = false;
userChallenge.withdrawn = true;
userChallenge.amountWithdrawn = challenge.buyInAmount;
challenge.totalWithdrawn += challenge.buyInAmount;
challenge.withdrawalsCount += 1;
challenge.totalStake -= challenge.buyInAmount;
challenge.enrolledUsersCount -= 1;
// Calculate reclaim amounts
uint256 totalReclaim = challenge.buyInAmount + challenge.joinAndForfeitFees[0];
uint256 airdropUsed = userChallenge.amountFromAirdrop;
if (airdropUsed >= totalReclaim) {
amountToAirdrop = totalReclaim;
amountToWallet = 0;
} else {
amountToAirdrop = airdropUsed;
amountToWallet = totalReclaim - airdropUsed;
}
_closeChallenge(s, user, challengeId, true);
}
/**
* @notice Allow a user to forfeit prior to start.
* @dev Optimized by consolidating state changes and simplifying calculations.
*/
function forfeit(
DataTypes.ArenaStorage storage s,
uint256 challengeId,
address user
)
internal
returns (uint256 amountToWallet, uint256 amountToAirdrop, uint256 forfeitFee)
{
DataTypes.Challenge storage challenge = s.challenges[challengeId];
DataTypes.UserChallenge storage userChallenge = s.userChallenges[user][challengeId];
if (!s.challengeUsers[challengeId][user] || userChallenge.withdrawn) {
revert X();
}
// Update user and challenge data
s.challengeUsers[challengeId][user] = false;
userChallenge.withdrawn = true;
challenge.totalStake -= challenge.buyInAmount;
challenge.enrolledUsersCount--;
forfeitFee = challenge.joinAndForfeitFees[1];
uint256 payoutAmt = challenge.buyInAmount - forfeitFee;
// Calculate payout amounts
uint256 airdropUsed = userChallenge.amountFromAirdrop;
if (airdropUsed >= payoutAmt) {
amountToAirdrop = payoutAmt;
amountToWallet = 0;
} else {
amountToAirdrop = airdropUsed;
amountToWallet = payoutAmt - airdropUsed;
}
_closeChallenge(s, user, challengeId, false);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {DataTypes} from "./DataTypes.sol";
import "../openzepline/contracts/token/ERC20/IERC20.sol";
import "../openzepline/contracts/utils/cryptography/MerkleProof.sol";
/**
* @title ArenaRewardLib
* @notice Handles reward claim logic and fee-taking after competition ends.
*/
library ArenaRewardLib {
error BS(); // "Bad State"
error MP(); // "Merkle Proof"
function setResult(
DataTypes.ArenaStorage storage s,
uint256 challengeId,
bytes32 merkleRoot
) internal {
s.challengeMerkleRoots[challengeId] = merkleRoot;
}
function claimReward(
DataTypes.ArenaStorage storage s,
uint256 challengeId,
address user,
uint256 rewardAmount,
bytes32[] memory proof
) internal returns (uint256) {
DataTypes.Challenge storage challenge = s.challenges[challengeId];
DataTypes.UserChallenge storage userChallenge = s.userChallenges[user][challengeId];
if (!s.challengeUsers[challengeId][user] || userChallenge.withdrawn) revert BS();
bytes32 node = keccak256(abi.encodePacked(user, rewardAmount));
if (!MerkleProof.verify(proof, s.challengeMerkleRoots[challengeId], node)) revert MP();
userChallenge.amountWithdrawn = rewardAmount;
userChallenge.withdrawn = true;
challenge.totalWithdrawn += rewardAmount;
challenge.withdrawalsCount += 1;
return rewardAmount;
}
function concludeChallenge(
DataTypes.ArenaStorage storage s,
uint256 challengeId
) internal returns (uint256) {
DataTypes.Challenge storage challenge = s.challenges[challengeId];
if (challenge.concluded) revert BS();
challenge.concluded = true;
// leftover (staked - rewarded) + sum of join fees from enrolled
uint256 leftover = (challenge.totalStake - challenge.totalReward)
+ (challenge.enrolledUsersCount * challenge.joinAndForfeitFees[0]);
return leftover;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {DataTypes} from "./DataTypes.sol";
/**
* @title ArenaViewLib
* @notice Helper library for read-only view functions.
*/
library ArenaViewLib {
function getChallenge(
DataTypes.ArenaStorage storage s,
uint256 challengeId
) internal view returns (DataTypes.Challenge memory) {
return s.challenges[challengeId];
}
function getAffiliateChallenge(
DataTypes.ArenaStorage storage s,
address user,
uint256 index
) internal view returns (uint256 challengeId, uint256 size) {
size = s.affiliateChallenges[user].length;
challengeId = size > index ? s.affiliateChallenges[user][index] : 0;
}
function getUserChallengesSize(
DataTypes.ArenaStorage storage s,
address user
) internal view returns (uint256 activeChallengesSize, uint256 archivedChallengesSize) {
activeChallengesSize = s.userActiveChallenges[user].length;
archivedChallengesSize = s.userArchivedChallenges[user].length;
}
function getUserChallengeAtIndex(
DataTypes.ArenaStorage storage s,
address user,
uint256 index,
bool fromArchive
) internal view returns (uint256) {
return fromArchive ? s.userArchivedChallenges[user][index] : s.userActiveChallenges[user][index];
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
// Minimal interface for the airdrop
interface IAirdrop {
function deposit(address user, uint256 amount) external;
function withdraw(address user, uint256 amount) external;
function balanceOf(address user) external view returns (uint256);
}
/**
* @notice Shared data types for the BurnBit Arena.
*/
library DataTypes {
// Used to store challenge configuration
struct ArenaConfig {
uint256 maxPotValue;
bool cancelAll;
bool paused;
uint32 maxActive;
}
// Stores per-user data about a challenge
struct UserChallenge {
uint256 amountWithdrawn;
uint256 amountFromAirdrop;
bool withdrawn;
}
// Stores overall data for a single challenge
struct Challenge {
uint256 totalStake;
uint256 totalWithdrawn;
uint256 totalReward;
uint256 buyInAmount;
uint256[] joinAndForfeitFees; // fees[0] => join fee, fees[1] => forfeit fee
uint256[] startAndEndTime; // period[0] => startTime, period[1] => endTime
uint32 maximumNumberOfUsers;
uint32 enrolledUsersCount;
uint32 withdrawalsCount;
uint32 challengeGoal;
uint8[] metricTypeAndCompStyle; // metricTypeAndCompStyle[0] => metricType, metricTypeAndCompStyle[]
bool cancelled;
bool concluded;
address creator;
}
// Storage layout for the entire Arena
struct ArenaStorage {
// Global config
ArenaConfig config;
// Token references
address bBit;
address airdrop;
// Mappings
mapping(address => mapping(uint256 => UserChallenge)) userChallenges;
mapping(address => uint256[]) userActiveChallenges;
mapping(address => uint256[]) userArchivedChallenges;
mapping(uint256 => Challenge) challenges;
mapping(uint256 => mapping(address => bool)) challengeUsers;
mapping(uint256 => bytes32) challengeMerkleRoots;
mapping(address => bool) blocked;
mapping(address => uint256[]) affiliateChallenges;
// Counters
uint256 challengeIdCounter;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "./IAccessControl.sol";
import {Context} from "../utils/Context.sol";
import {ERC165} from "../utils/introspection/ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address account => bool) hasRole;
bytes32 adminRole;
}
mapping(bytes32 role => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with an {AccessControlUnauthorizedAccount} error including the required role.
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual returns (bool) {
return _roles[role].hasRole[account];
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
* is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
* is missing `role`.
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert AccessControlUnauthorizedAccount(account, role);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address callerConfirmation) public virtual {
if (callerConfirmation != _msgSender()) {
revert AccessControlBadConfirmation();
}
_revokeRole(role, callerConfirmation);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
if (!hasRole(role, account)) {
_roles[role].hasRole[account] = true;
emit RoleGranted(role, account, _msgSender());
return true;
} else {
return false;
}
}
/**
* @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
if (hasRole(role, account)) {
_roles[role].hasRole[account] = false;
emit RoleRevoked(role, account, _msgSender());
return true;
} else {
return false;
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/IAccessControl.sol)
pragma solidity ^0.8.20;
/**
* @dev External interface of AccessControl declared to support ERC-165 detection.
*/
interface IAccessControl {
/**
* @dev The `account` is missing a role.
*/
error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);
/**
* @dev The caller of a function is not the expected one.
*
* NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
*/
error AccessControlBadConfirmation();
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call. This account bears the admin role (for the granted role).
* Expected in cases where the role was granted using the internal {AccessControl-_grantRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*/
function renounceRole(bytes32 role, address callerConfirmation) external;
}// 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);
}// 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;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/cryptography/Hashes.sol)
pragma solidity ^0.8.20;
/**
* @dev Library of standard hash functions.
*
* _Available since v5.1._
*/
library Hashes {
/**
* @dev Commutative Keccak256 hash of a sorted pair of bytes32. Frequently used when working with merkle proofs.
*
* NOTE: Equivalent to the `standardNodeHash` in our https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
*/
function commutativeKeccak256(bytes32 a, bytes32 b) internal pure returns (bytes32) {
return a < b ? _efficientKeccak256(a, b) : _efficientKeccak256(b, a);
}
/**
* @dev Implementation of keccak256(abi.encode(a, b)) that doesn't allocate or expand memory.
*/
function _efficientKeccak256(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
assembly ("memory-safe") {
mstore(0x00, a)
mstore(0x20, b)
value := keccak256(0x00, 0x40)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/cryptography/MerkleProof.sol)
// This file was procedurally generated from scripts/generate/templates/MerkleProof.js.
pragma solidity ^0.8.20;
import {Hashes} from "./Hashes.sol";
/**
* @dev These functions deal with verification of Merkle Tree proofs.
*
* The tree and the proofs can be generated using our
* https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
* You will find a quickstart guide in the readme.
*
* WARNING: You should avoid using leaf values that are 64 bytes long prior to
* hashing, or use a hash function other than keccak256 for hashing leaves.
* This is because the concatenation of a sorted pair of internal nodes in
* the Merkle tree could be reinterpreted as a leaf value.
* OpenZeppelin's JavaScript library generates Merkle trees that are safe
* against this attack out of the box.
*
* IMPORTANT: Consider memory side-effects when using custom hashing functions
* that access memory in an unsafe way.
*
* NOTE: This library supports proof verification for merkle trees built using
* custom _commutative_ hashing functions (i.e. `H(a, b) == H(b, a)`). Proving
* leaf inclusion in trees built using non-commutative hashing functions requires
* additional logic that is not supported by this library.
*/
library MerkleProof {
/**
*@dev The multiproof provided is not valid.
*/
error MerkleProofInvalidMultiproof();
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*
* This version handles proofs in memory with the default hashing function.
*/
function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leaves & pre-images are assumed to be sorted.
*
* This version handles proofs in memory with the default hashing function.
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = Hashes.commutativeKeccak256(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*
* This version handles proofs in memory with a custom hashing function.
*/
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bool) {
return processProof(proof, leaf, hasher) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leaves & pre-images are assumed to be sorted.
*
* This version handles proofs in memory with a custom hashing function.
*/
function processProof(
bytes32[] memory proof,
bytes32 leaf,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = hasher(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*
* This version handles proofs in calldata with the default hashing function.
*/
function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
return processProofCalldata(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leaves & pre-images are assumed to be sorted.
*
* This version handles proofs in calldata with the default hashing function.
*/
function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = Hashes.commutativeKeccak256(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*
* This version handles proofs in calldata with a custom hashing function.
*/
function verifyCalldata(
bytes32[] calldata proof,
bytes32 root,
bytes32 leaf,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bool) {
return processProofCalldata(proof, leaf, hasher) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leaves & pre-images are assumed to be sorted.
*
* This version handles proofs in calldata with a custom hashing function.
*/
function processProofCalldata(
bytes32[] calldata proof,
bytes32 leaf,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = hasher(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* This version handles multiproofs in memory with the default hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*
* NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
* The `leaves` must be validated independently. See {processMultiProof}.
*/
function multiProofVerify(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProof(proof, proofFlags, leaves) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
* proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
* leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
* respectively.
*
* This version handles multiproofs in memory with the default hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
* is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
* tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
*
* NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
* and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
* validating the leaves elsewhere.
*/
function processMultiProof(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the Merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofFlagsLen = proofFlags.length;
// Check proof validity.
if (leavesLen + proof.length != proofFlagsLen + 1) {
revert MerkleProofInvalidMultiproof();
}
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](proofFlagsLen);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < proofFlagsLen; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = Hashes.commutativeKeccak256(a, b);
}
if (proofFlagsLen > 0) {
if (proofPos != proof.length) {
revert MerkleProofInvalidMultiproof();
}
unchecked {
return hashes[proofFlagsLen - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* This version handles multiproofs in memory with a custom hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*
* NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
* The `leaves` must be validated independently. See {processMultiProof}.
*/
function multiProofVerify(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32 root,
bytes32[] memory leaves,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bool) {
return processMultiProof(proof, proofFlags, leaves, hasher) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
* proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
* leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
* respectively.
*
* This version handles multiproofs in memory with a custom hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
* is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
* tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
*
* NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
* and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
* validating the leaves elsewhere.
*/
function processMultiProof(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32[] memory leaves,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the Merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofFlagsLen = proofFlags.length;
// Check proof validity.
if (leavesLen + proof.length != proofFlagsLen + 1) {
revert MerkleProofInvalidMultiproof();
}
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](proofFlagsLen);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < proofFlagsLen; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = hasher(a, b);
}
if (proofFlagsLen > 0) {
if (proofPos != proof.length) {
revert MerkleProofInvalidMultiproof();
}
unchecked {
return hashes[proofFlagsLen - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* This version handles multiproofs in calldata with the default hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*
* NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
* The `leaves` must be validated independently. See {processMultiProofCalldata}.
*/
function multiProofVerifyCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProofCalldata(proof, proofFlags, leaves) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
* proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
* leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
* respectively.
*
* This version handles multiproofs in calldata with the default hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
* is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
* tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
*
* NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
* and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
* validating the leaves elsewhere.
*/
function processMultiProofCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the Merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofFlagsLen = proofFlags.length;
// Check proof validity.
if (leavesLen + proof.length != proofFlagsLen + 1) {
revert MerkleProofInvalidMultiproof();
}
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](proofFlagsLen);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < proofFlagsLen; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = Hashes.commutativeKeccak256(a, b);
}
if (proofFlagsLen > 0) {
if (proofPos != proof.length) {
revert MerkleProofInvalidMultiproof();
}
unchecked {
return hashes[proofFlagsLen - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* This version handles multiproofs in calldata with a custom hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*
* NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
* The `leaves` must be validated independently. See {processMultiProofCalldata}.
*/
function multiProofVerifyCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32 root,
bytes32[] memory leaves,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bool) {
return processMultiProofCalldata(proof, proofFlags, leaves, hasher) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
* proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
* leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
* respectively.
*
* This version handles multiproofs in calldata with a custom hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
* is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
* tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
*
* NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
* and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
* validating the leaves elsewhere.
*/
function processMultiProofCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32[] memory leaves,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the Merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofFlagsLen = proofFlags.length;
// Check proof validity.
if (leavesLen + proof.length != proofFlagsLen + 1) {
revert MerkleProofInvalidMultiproof();
}
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](proofFlagsLen);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < proofFlagsLen; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = hasher(a, b);
}
if (proofFlagsLen > 0) {
if (proofPos != proof.length) {
revert MerkleProofInvalidMultiproof();
}
unchecked {
return hashes[proofFlagsLen - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// 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);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
import {Panic} from "../Panic.sol";
import {SafeCast} from "./SafeCast.sol";
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Returns the addition of two unsigned integers, with an success flag (no overflow).
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an success flag (no overflow).
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an success flag (no overflow).
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a success flag (no division by zero).
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
*
* IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
* However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
* one branch when needed, making this function more expensive.
*/
function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {
unchecked {
// branchless ternary works because:
// b ^ (a ^ b) == a
// b ^ 0 == b
return b ^ ((a ^ b) * SafeCast.toUint(condition));
}
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a > b, a, b);
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a < b, a, b);
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
Panic.panic(Panic.DIVISION_BY_ZERO);
}
// The following calculation ensures accurate ceiling division without overflow.
// Since a is non-zero, (a - 1) / b will not overflow.
// The largest possible result occurs when (a - 1) / b is type(uint256).max,
// but the largest value we can obtain is type(uint256).max - 1, which happens
// when a = type(uint256).max and b = 1.
unchecked {
return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);
}
}
/**
* @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
*
* Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
* Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2²⁵⁶ and mod 2²⁵⁶ - 1, then use
// the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2²⁵⁶ + prod0.
uint256 prod0 = x * y; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0.
if (denominator <= prod1) {
Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
uint256 twos = denominator & (0 - denominator);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2²⁵⁶ / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such
// that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv ≡ 1 mod 2⁴.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
// works in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2⁸
inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶
inverse *= 2 - denominator * inverse; // inverse mod 2³²
inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴
inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸
inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2²⁵⁶. Since the preconditions guarantee that the outcome is
// less than 2²⁵⁶, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @dev Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);
}
/**
* @dev Calculate the modular multiplicative inverse of a number in Z/nZ.
*
* If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.
* If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.
*
* If the input value is not inversible, 0 is returned.
*
* NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the
* inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.
*/
function invMod(uint256 a, uint256 n) internal pure returns (uint256) {
unchecked {
if (n == 0) return 0;
// The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)
// Used to compute integers x and y such that: ax + ny = gcd(a, n).
// When the gcd is 1, then the inverse of a modulo n exists and it's x.
// ax + ny = 1
// ax = 1 + (-y)n
// ax ≡ 1 (mod n) # x is the inverse of a modulo n
// If the remainder is 0 the gcd is n right away.
uint256 remainder = a % n;
uint256 gcd = n;
// Therefore the initial coefficients are:
// ax + ny = gcd(a, n) = n
// 0a + 1n = n
int256 x = 0;
int256 y = 1;
while (remainder != 0) {
uint256 quotient = gcd / remainder;
(gcd, remainder) = (
// The old remainder is the next gcd to try.
remainder,
// Compute the next remainder.
// Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd
// where gcd is at most n (capped to type(uint256).max)
gcd - remainder * quotient
);
(x, y) = (
// Increment the coefficient of a.
y,
// Decrement the coefficient of n.
// Can overflow, but the result is casted to uint256 so that the
// next value of y is "wrapped around" to a value between 0 and n - 1.
x - y * int256(quotient)
);
}
if (gcd != 1) return 0; // No inverse exists.
return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.
}
}
/**
* @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.
*
* From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is
* prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that
* `a**(p-2)` is the modular multiplicative inverse of a in Fp.
*
* NOTE: this function does NOT check that `p` is a prime greater than `2`.
*/
function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {
unchecked {
return Math.modExp(a, p - 2, p);
}
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)
*
* Requirements:
* - modulus can't be zero
* - underlying staticcall to precompile must succeed
*
* IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make
* sure the chain you're using it on supports the precompiled contract for modular exponentiation
* at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,
* the underlying function will succeed given the lack of a revert, but the result may be incorrectly
* interpreted as 0.
*/
function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {
(bool success, uint256 result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).
* It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying
* to operate modulo 0 or if the underlying precompile reverted.
*
* IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain
* you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in
* https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack
* of a revert, but the result may be incorrectly interpreted as 0.
*/
function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {
if (m == 0) return (false, 0);
assembly ("memory-safe") {
let ptr := mload(0x40)
// | Offset | Content | Content (Hex) |
// |-----------|------------|--------------------------------------------------------------------|
// | 0x00:0x1f | size of b | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x20:0x3f | size of e | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x40:0x5f | size of m | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x60:0x7f | value of b | 0x<.............................................................b> |
// | 0x80:0x9f | value of e | 0x<.............................................................e> |
// | 0xa0:0xbf | value of m | 0x<.............................................................m> |
mstore(ptr, 0x20)
mstore(add(ptr, 0x20), 0x20)
mstore(add(ptr, 0x40), 0x20)
mstore(add(ptr, 0x60), b)
mstore(add(ptr, 0x80), e)
mstore(add(ptr, 0xa0), m)
// Given the result < m, it's guaranteed to fit in 32 bytes,
// so we can use the memory scratch space located at offset 0.
success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)
result := mload(0x00)
}
}
/**
* @dev Variant of {modExp} that supports inputs of arbitrary length.
*/
function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {
(bool success, bytes memory result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Variant of {tryModExp} that supports inputs of arbitrary length.
*/
function tryModExp(
bytes memory b,
bytes memory e,
bytes memory m
) internal view returns (bool success, bytes memory result) {
if (_zeroBytes(m)) return (false, new bytes(0));
uint256 mLen = m.length;
// Encode call args in result and move the free memory pointer
result = abi.encodePacked(b.length, e.length, mLen, b, e, m);
assembly ("memory-safe") {
let dataPtr := add(result, 0x20)
// Write result on top of args to avoid allocating extra memory.
success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)
// Overwrite the length.
// result.length > returndatasize() is guaranteed because returndatasize() == m.length
mstore(result, mLen)
// Set the memory pointer after the returned data.
mstore(0x40, add(dataPtr, mLen))
}
}
/**
* @dev Returns whether the provided byte array is zero.
*/
function _zeroBytes(bytes memory byteArray) private pure returns (bool) {
for (uint256 i = 0; i < byteArray.length; ++i) {
if (byteArray[i] != 0) {
return false;
}
}
return true;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* This method is based on Newton's method for computing square roots; the algorithm is restricted to only
* using integer operations.
*/
function sqrt(uint256 a) internal pure returns (uint256) {
unchecked {
// Take care of easy edge cases when a == 0 or a == 1
if (a <= 1) {
return a;
}
// In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a
// sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between
// the current value as `ε_n = | x_n - sqrt(a) |`.
//
// For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root
// of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is
// bigger than any uint256.
//
// By noticing that
// `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)`
// we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar
// to the msb function.
uint256 aa = a;
uint256 xn = 1;
if (aa >= (1 << 128)) {
aa >>= 128;
xn <<= 64;
}
if (aa >= (1 << 64)) {
aa >>= 64;
xn <<= 32;
}
if (aa >= (1 << 32)) {
aa >>= 32;
xn <<= 16;
}
if (aa >= (1 << 16)) {
aa >>= 16;
xn <<= 8;
}
if (aa >= (1 << 8)) {
aa >>= 8;
xn <<= 4;
}
if (aa >= (1 << 4)) {
aa >>= 4;
xn <<= 2;
}
if (aa >= (1 << 2)) {
xn <<= 1;
}
// We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1).
//
// We can refine our estimation by noticing that the middle of that interval minimizes the error.
// If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2).
// This is going to be our x_0 (and ε_0)
xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2)
// From here, Newton's method give us:
// x_{n+1} = (x_n + a / x_n) / 2
//
// One should note that:
// x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a
// = ((x_n² + a) / (2 * x_n))² - a
// = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a
// = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)
// = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²)
// = (x_n² - a)² / (2 * x_n)²
// = ((x_n² - a) / (2 * x_n))²
// ≥ 0
// Which proves that for all n ≥ 1, sqrt(a) ≤ x_n
//
// This gives us the proof of quadratic convergence of the sequence:
// ε_{n+1} = | x_{n+1} - sqrt(a) |
// = | (x_n + a / x_n) / 2 - sqrt(a) |
// = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |
// = | (x_n - sqrt(a))² / (2 * x_n) |
// = | ε_n² / (2 * x_n) |
// = ε_n² / | (2 * x_n) |
//
// For the first iteration, we have a special case where x_0 is known:
// ε_1 = ε_0² / | (2 * x_0) |
// ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))
// ≤ 2**(2*e-4) / (3 * 2**(e-1))
// ≤ 2**(e-3) / 3
// ≤ 2**(e-3-log2(3))
// ≤ 2**(e-4.5)
//
// For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n:
// ε_{n+1} = ε_n² / | (2 * x_n) |
// ≤ (2**(e-k))² / (2 * 2**(e-1))
// ≤ 2**(2*e-2*k) / 2**e
// ≤ 2**(e-2*k)
xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5) -- special case, see above
xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9) -- general case with k = 4.5
xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18) -- general case with k = 9
xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36) -- general case with k = 18
xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72) -- general case with k = 36
xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144) -- general case with k = 72
// Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision
// ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either
// sqrt(a) or sqrt(a) + 1.
return xn - SafeCast.toUint(xn > a / xn);
}
}
/**
* @dev Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
uint256 exp;
unchecked {
exp = 128 * SafeCast.toUint(value > (1 << 128) - 1);
value >>= exp;
result += exp;
exp = 64 * SafeCast.toUint(value > (1 << 64) - 1);
value >>= exp;
result += exp;
exp = 32 * SafeCast.toUint(value > (1 << 32) - 1);
value >>= exp;
result += exp;
exp = 16 * SafeCast.toUint(value > (1 << 16) - 1);
value >>= exp;
result += exp;
exp = 8 * SafeCast.toUint(value > (1 << 8) - 1);
value >>= exp;
result += exp;
exp = 4 * SafeCast.toUint(value > (1 << 4) - 1);
value >>= exp;
result += exp;
exp = 2 * SafeCast.toUint(value > (1 << 2) - 1);
value >>= exp;
result += exp;
result += SafeCast.toUint(value > 1);
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
uint256 isGt;
unchecked {
isGt = SafeCast.toUint(value > (1 << 128) - 1);
value >>= isGt * 128;
result += isGt * 16;
isGt = SafeCast.toUint(value > (1 << 64) - 1);
value >>= isGt * 64;
result += isGt * 8;
isGt = SafeCast.toUint(value > (1 << 32) - 1);
value >>= isGt * 32;
result += isGt * 4;
isGt = SafeCast.toUint(value > (1 << 16) - 1);
value >>= isGt * 16;
result += isGt * 2;
result += SafeCast.toUint(value > (1 << 8) - 1);
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.20;
/**
* @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeCast {
/**
* @dev Value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);
/**
* @dev An int value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedIntToUint(int256 value);
/**
* @dev Value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);
/**
* @dev An uint value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedUintToInt(uint256 value);
/**
* @dev Returns the downcasted uint248 from uint256, reverting on
* overflow (when the input is greater than largest uint248).
*
* Counterpart to Solidity's `uint248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toUint248(uint256 value) internal pure returns (uint248) {
if (value > type(uint248).max) {
revert SafeCastOverflowedUintDowncast(248, value);
}
return uint248(value);
}
/**
* @dev Returns the downcasted uint240 from uint256, reverting on
* overflow (when the input is greater than largest uint240).
*
* Counterpart to Solidity's `uint240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toUint240(uint256 value) internal pure returns (uint240) {
if (value > type(uint240).max) {
revert SafeCastOverflowedUintDowncast(240, value);
}
return uint240(value);
}
/**
* @dev Returns the downcasted uint232 from uint256, reverting on
* overflow (when the input is greater than largest uint232).
*
* Counterpart to Solidity's `uint232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toUint232(uint256 value) internal pure returns (uint232) {
if (value > type(uint232).max) {
revert SafeCastOverflowedUintDowncast(232, value);
}
return uint232(value);
}
/**
* @dev Returns the downcasted uint224 from uint256, reverting on
* overflow (when the input is greater than largest uint224).
*
* Counterpart to Solidity's `uint224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toUint224(uint256 value) internal pure returns (uint224) {
if (value > type(uint224).max) {
revert SafeCastOverflowedUintDowncast(224, value);
}
return uint224(value);
}
/**
* @dev Returns the downcasted uint216 from uint256, reverting on
* overflow (when the input is greater than largest uint216).
*
* Counterpart to Solidity's `uint216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toUint216(uint256 value) internal pure returns (uint216) {
if (value > type(uint216).max) {
revert SafeCastOverflowedUintDowncast(216, value);
}
return uint216(value);
}
/**
* @dev Returns the downcasted uint208 from uint256, reverting on
* overflow (when the input is greater than largest uint208).
*
* Counterpart to Solidity's `uint208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toUint208(uint256 value) internal pure returns (uint208) {
if (value > type(uint208).max) {
revert SafeCastOverflowedUintDowncast(208, value);
}
return uint208(value);
}
/**
* @dev Returns the downcasted uint200 from uint256, reverting on
* overflow (when the input is greater than largest uint200).
*
* Counterpart to Solidity's `uint200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toUint200(uint256 value) internal pure returns (uint200) {
if (value > type(uint200).max) {
revert SafeCastOverflowedUintDowncast(200, value);
}
return uint200(value);
}
/**
* @dev Returns the downcasted uint192 from uint256, reverting on
* overflow (when the input is greater than largest uint192).
*
* Counterpart to Solidity's `uint192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toUint192(uint256 value) internal pure returns (uint192) {
if (value > type(uint192).max) {
revert SafeCastOverflowedUintDowncast(192, value);
}
return uint192(value);
}
/**
* @dev Returns the downcasted uint184 from uint256, reverting on
* overflow (when the input is greater than largest uint184).
*
* Counterpart to Solidity's `uint184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toUint184(uint256 value) internal pure returns (uint184) {
if (value > type(uint184).max) {
revert SafeCastOverflowedUintDowncast(184, value);
}
return uint184(value);
}
/**
* @dev Returns the downcasted uint176 from uint256, reverting on
* overflow (when the input is greater than largest uint176).
*
* Counterpart to Solidity's `uint176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toUint176(uint256 value) internal pure returns (uint176) {
if (value > type(uint176).max) {
revert SafeCastOverflowedUintDowncast(176, value);
}
return uint176(value);
}
/**
* @dev Returns the downcasted uint168 from uint256, reverting on
* overflow (when the input is greater than largest uint168).
*
* Counterpart to Solidity's `uint168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toUint168(uint256 value) internal pure returns (uint168) {
if (value > type(uint168).max) {
revert SafeCastOverflowedUintDowncast(168, value);
}
return uint168(value);
}
/**
* @dev Returns the downcasted uint160 from uint256, reverting on
* overflow (when the input is greater than largest uint160).
*
* Counterpart to Solidity's `uint160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toUint160(uint256 value) internal pure returns (uint160) {
if (value > type(uint160).max) {
revert SafeCastOverflowedUintDowncast(160, value);
}
return uint160(value);
}
/**
* @dev Returns the downcasted uint152 from uint256, reverting on
* overflow (when the input is greater than largest uint152).
*
* Counterpart to Solidity's `uint152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toUint152(uint256 value) internal pure returns (uint152) {
if (value > type(uint152).max) {
revert SafeCastOverflowedUintDowncast(152, value);
}
return uint152(value);
}
/**
* @dev Returns the downcasted uint144 from uint256, reverting on
* overflow (when the input is greater than largest uint144).
*
* Counterpart to Solidity's `uint144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toUint144(uint256 value) internal pure returns (uint144) {
if (value > type(uint144).max) {
revert SafeCastOverflowedUintDowncast(144, value);
}
return uint144(value);
}
/**
* @dev Returns the downcasted uint136 from uint256, reverting on
* overflow (when the input is greater than largest uint136).
*
* Counterpart to Solidity's `uint136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toUint136(uint256 value) internal pure returns (uint136) {
if (value > type(uint136).max) {
revert SafeCastOverflowedUintDowncast(136, value);
}
return uint136(value);
}
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toUint128(uint256 value) internal pure returns (uint128) {
if (value > type(uint128).max) {
revert SafeCastOverflowedUintDowncast(128, value);
}
return uint128(value);
}
/**
* @dev Returns the downcasted uint120 from uint256, reverting on
* overflow (when the input is greater than largest uint120).
*
* Counterpart to Solidity's `uint120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toUint120(uint256 value) internal pure returns (uint120) {
if (value > type(uint120).max) {
revert SafeCastOverflowedUintDowncast(120, value);
}
return uint120(value);
}
/**
* @dev Returns the downcasted uint112 from uint256, reverting on
* overflow (when the input is greater than largest uint112).
*
* Counterpart to Solidity's `uint112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toUint112(uint256 value) internal pure returns (uint112) {
if (value > type(uint112).max) {
revert SafeCastOverflowedUintDowncast(112, value);
}
return uint112(value);
}
/**
* @dev Returns the downcasted uint104 from uint256, reverting on
* overflow (when the input is greater than largest uint104).
*
* Counterpart to Solidity's `uint104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toUint104(uint256 value) internal pure returns (uint104) {
if (value > type(uint104).max) {
revert SafeCastOverflowedUintDowncast(104, value);
}
return uint104(value);
}
/**
* @dev Returns the downcasted uint96 from uint256, reverting on
* overflow (when the input is greater than largest uint96).
*
* Counterpart to Solidity's `uint96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toUint96(uint256 value) internal pure returns (uint96) {
if (value > type(uint96).max) {
revert SafeCastOverflowedUintDowncast(96, value);
}
return uint96(value);
}
/**
* @dev Returns the downcasted uint88 from uint256, reverting on
* overflow (when the input is greater than largest uint88).
*
* Counterpart to Solidity's `uint88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toUint88(uint256 value) internal pure returns (uint88) {
if (value > type(uint88).max) {
revert SafeCastOverflowedUintDowncast(88, value);
}
return uint88(value);
}
/**
* @dev Returns the downcasted uint80 from uint256, reverting on
* overflow (when the input is greater than largest uint80).
*
* Counterpart to Solidity's `uint80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toUint80(uint256 value) internal pure returns (uint80) {
if (value > type(uint80).max) {
revert SafeCastOverflowedUintDowncast(80, value);
}
return uint80(value);
}
/**
* @dev Returns the downcasted uint72 from uint256, reverting on
* overflow (when the input is greater than largest uint72).
*
* Counterpart to Solidity's `uint72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toUint72(uint256 value) internal pure returns (uint72) {
if (value > type(uint72).max) {
revert SafeCastOverflowedUintDowncast(72, value);
}
return uint72(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toUint64(uint256 value) internal pure returns (uint64) {
if (value > type(uint64).max) {
revert SafeCastOverflowedUintDowncast(64, value);
}
return uint64(value);
}
/**
* @dev Returns the downcasted uint56 from uint256, reverting on
* overflow (when the input is greater than largest uint56).
*
* Counterpart to Solidity's `uint56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toUint56(uint256 value) internal pure returns (uint56) {
if (value > type(uint56).max) {
revert SafeCastOverflowedUintDowncast(56, value);
}
return uint56(value);
}
/**
* @dev Returns the downcasted uint48 from uint256, reverting on
* overflow (when the input is greater than largest uint48).
*
* Counterpart to Solidity's `uint48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toUint48(uint256 value) internal pure returns (uint48) {
if (value > type(uint48).max) {
revert SafeCastOverflowedUintDowncast(48, value);
}
return uint48(value);
}
/**
* @dev Returns the downcasted uint40 from uint256, reverting on
* overflow (when the input is greater than largest uint40).
*
* Counterpart to Solidity's `uint40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toUint40(uint256 value) internal pure returns (uint40) {
if (value > type(uint40).max) {
revert SafeCastOverflowedUintDowncast(40, value);
}
return uint40(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toUint32(uint256 value) internal pure returns (uint32) {
if (value > type(uint32).max) {
revert SafeCastOverflowedUintDowncast(32, value);
}
return uint32(value);
}
/**
* @dev Returns the downcasted uint24 from uint256, reverting on
* overflow (when the input is greater than largest uint24).
*
* Counterpart to Solidity's `uint24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toUint24(uint256 value) internal pure returns (uint24) {
if (value > type(uint24).max) {
revert SafeCastOverflowedUintDowncast(24, value);
}
return uint24(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toUint16(uint256 value) internal pure returns (uint16) {
if (value > type(uint16).max) {
revert SafeCastOverflowedUintDowncast(16, value);
}
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toUint8(uint256 value) internal pure returns (uint8) {
if (value > type(uint8).max) {
revert SafeCastOverflowedUintDowncast(8, value);
}
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*/
function toUint256(int256 value) internal pure returns (uint256) {
if (value < 0) {
revert SafeCastOverflowedIntToUint(value);
}
return uint256(value);
}
/**
* @dev Returns the downcasted int248 from int256, reverting on
* overflow (when the input is less than smallest int248 or
* greater than largest int248).
*
* Counterpart to Solidity's `int248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(248, value);
}
}
/**
* @dev Returns the downcasted int240 from int256, reverting on
* overflow (when the input is less than smallest int240 or
* greater than largest int240).
*
* Counterpart to Solidity's `int240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(240, value);
}
}
/**
* @dev Returns the downcasted int232 from int256, reverting on
* overflow (when the input is less than smallest int232 or
* greater than largest int232).
*
* Counterpart to Solidity's `int232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(232, value);
}
}
/**
* @dev Returns the downcasted int224 from int256, reverting on
* overflow (when the input is less than smallest int224 or
* greater than largest int224).
*
* Counterpart to Solidity's `int224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(224, value);
}
}
/**
* @dev Returns the downcasted int216 from int256, reverting on
* overflow (when the input is less than smallest int216 or
* greater than largest int216).
*
* Counterpart to Solidity's `int216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(216, value);
}
}
/**
* @dev Returns the downcasted int208 from int256, reverting on
* overflow (when the input is less than smallest int208 or
* greater than largest int208).
*
* Counterpart to Solidity's `int208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(208, value);
}
}
/**
* @dev Returns the downcasted int200 from int256, reverting on
* overflow (when the input is less than smallest int200 or
* greater than largest int200).
*
* Counterpart to Solidity's `int200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(200, value);
}
}
/**
* @dev Returns the downcasted int192 from int256, reverting on
* overflow (when the input is less than smallest int192 or
* greater than largest int192).
*
* Counterpart to Solidity's `int192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(192, value);
}
}
/**
* @dev Returns the downcasted int184 from int256, reverting on
* overflow (when the input is less than smallest int184 or
* greater than largest int184).
*
* Counterpart to Solidity's `int184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(184, value);
}
}
/**
* @dev Returns the downcasted int176 from int256, reverting on
* overflow (when the input is less than smallest int176 or
* greater than largest int176).
*
* Counterpart to Solidity's `int176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(176, value);
}
}
/**
* @dev Returns the downcasted int168 from int256, reverting on
* overflow (when the input is less than smallest int168 or
* greater than largest int168).
*
* Counterpart to Solidity's `int168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(168, value);
}
}
/**
* @dev Returns the downcasted int160 from int256, reverting on
* overflow (when the input is less than smallest int160 or
* greater than largest int160).
*
* Counterpart to Solidity's `int160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(160, value);
}
}
/**
* @dev Returns the downcasted int152 from int256, reverting on
* overflow (when the input is less than smallest int152 or
* greater than largest int152).
*
* Counterpart to Solidity's `int152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(152, value);
}
}
/**
* @dev Returns the downcasted int144 from int256, reverting on
* overflow (when the input is less than smallest int144 or
* greater than largest int144).
*
* Counterpart to Solidity's `int144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(144, value);
}
}
/**
* @dev Returns the downcasted int136 from int256, reverting on
* overflow (when the input is less than smallest int136 or
* greater than largest int136).
*
* Counterpart to Solidity's `int136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(136, value);
}
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(128, value);
}
}
/**
* @dev Returns the downcasted int120 from int256, reverting on
* overflow (when the input is less than smallest int120 or
* greater than largest int120).
*
* Counterpart to Solidity's `int120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(120, value);
}
}
/**
* @dev Returns the downcasted int112 from int256, reverting on
* overflow (when the input is less than smallest int112 or
* greater than largest int112).
*
* Counterpart to Solidity's `int112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(112, value);
}
}
/**
* @dev Returns the downcasted int104 from int256, reverting on
* overflow (when the input is less than smallest int104 or
* greater than largest int104).
*
* Counterpart to Solidity's `int104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(104, value);
}
}
/**
* @dev Returns the downcasted int96 from int256, reverting on
* overflow (when the input is less than smallest int96 or
* greater than largest int96).
*
* Counterpart to Solidity's `int96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(96, value);
}
}
/**
* @dev Returns the downcasted int88 from int256, reverting on
* overflow (when the input is less than smallest int88 or
* greater than largest int88).
*
* Counterpart to Solidity's `int88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(88, value);
}
}
/**
* @dev Returns the downcasted int80 from int256, reverting on
* overflow (when the input is less than smallest int80 or
* greater than largest int80).
*
* Counterpart to Solidity's `int80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(80, value);
}
}
/**
* @dev Returns the downcasted int72 from int256, reverting on
* overflow (when the input is less than smallest int72 or
* greater than largest int72).
*
* Counterpart to Solidity's `int72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(72, value);
}
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(64, value);
}
}
/**
* @dev Returns the downcasted int56 from int256, reverting on
* overflow (when the input is less than smallest int56 or
* greater than largest int56).
*
* Counterpart to Solidity's `int56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(56, value);
}
}
/**
* @dev Returns the downcasted int48 from int256, reverting on
* overflow (when the input is less than smallest int48 or
* greater than largest int48).
*
* Counterpart to Solidity's `int48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(48, value);
}
}
/**
* @dev Returns the downcasted int40 from int256, reverting on
* overflow (when the input is less than smallest int40 or
* greater than largest int40).
*
* Counterpart to Solidity's `int40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(40, value);
}
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(32, value);
}
}
/**
* @dev Returns the downcasted int24 from int256, reverting on
* overflow (when the input is less than smallest int24 or
* greater than largest int24).
*
* Counterpart to Solidity's `int24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(24, value);
}
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(16, value);
}
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(8, value);
}
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
if (value > uint256(type(int256).max)) {
revert SafeCastOverflowedUintToInt(value);
}
return int256(value);
}
/**
* @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
*/
function toUint(bool b) internal pure returns (uint256 u) {
assembly ("memory-safe") {
u := iszero(iszero(b))
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol)
pragma solidity ^0.8.20;
/**
* @dev Helper library for emitting standardized panic codes.
*
* ```solidity
* contract Example {
* using Panic for uint256;
*
* // Use any of the declared internal constants
* function foo() { Panic.GENERIC.panic(); }
*
* // Alternatively
* function foo() { Panic.panic(Panic.GENERIC); }
* }
* ```
*
* Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].
*
* _Available since v5.1._
*/
// slither-disable-next-line unused-state
library Panic {
/// @dev generic / unspecified error
uint256 internal constant GENERIC = 0x00;
/// @dev used by the assert() builtin
uint256 internal constant ASSERT = 0x01;
/// @dev arithmetic underflow or overflow
uint256 internal constant UNDER_OVERFLOW = 0x11;
/// @dev division or modulo by zero
uint256 internal constant DIVISION_BY_ZERO = 0x12;
/// @dev enum conversion error
uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;
/// @dev invalid encoding in storage
uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;
/// @dev empty array pop
uint256 internal constant EMPTY_ARRAY_POP = 0x31;
/// @dev array out of bounds access
uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;
/// @dev resource error (too large allocation or too large array)
uint256 internal constant RESOURCE_ERROR = 0x41;
/// @dev calling invalid internal function
uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;
/// @dev Reverts with a panic code. Recommended to use with
/// the internal constants with predefined codes.
function panic(uint256 code) internal pure {
assembly ("memory-safe") {
mstore(0x00, 0x4e487b71)
mstore(0x20, code)
revert(0x1c, 0x24)
}
}
}// 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;
}
}{
"evmVersion": "paris",
"optimizer": {
"enabled": false,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"contract IERC20","name":"bBitToken","type":"address"},{"internalType":"uint256","name":"maxPotValue","type":"uint256"},{"internalType":"contract IAirdrop","name":"airdropAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[],"name":"BS","type":"error"},{"inputs":[],"name":"BS","type":"error"},{"inputs":[],"name":"Bl","type":"error"},{"inputs":[],"name":"BuyInZero","type":"error"},{"inputs":[],"name":"CA","type":"error"},{"inputs":[],"name":"CF","type":"error"},{"inputs":[],"name":"E1","type":"error"},{"inputs":[],"name":"E2","type":"error"},{"inputs":[],"name":"E3","type":"error"},{"inputs":[],"name":"EndTimeError","type":"error"},{"inputs":[],"name":"FeeMismatch","type":"error"},{"inputs":[],"name":"IAdd","type":"error"},{"inputs":[],"name":"MP","type":"error"},{"inputs":[],"name":"MaxPotExceeded","type":"error"},{"inputs":[],"name":"MaxUsersZero","type":"error"},{"inputs":[],"name":"P","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[],"name":"StartTimeError","type":"error"},{"inputs":[],"name":"TF","type":"error"},{"inputs":[],"name":"TMC","type":"error"},{"inputs":[],"name":"X","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"u","type":"address"}],"name":"EBlk","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"u","type":"address"},{"indexed":true,"internalType":"uint256","name":"c","type":"uint256"}],"name":"ECL","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"u","type":"address"},{"indexed":true,"internalType":"uint256","name":"c","type":"uint256"}],"name":"ECR","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"c","type":"uint256"}],"name":"ECan","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"c","type":"uint256"},{"indexed":true,"internalType":"address","name":"u","type":"address"},{"indexed":false,"internalType":"uint256","name":"p","type":"uint256"}],"name":"ECon","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"a","type":"address"},{"indexed":false,"internalType":"bool","name":"s","type":"bool"},{"indexed":false,"internalType":"bool","name":"c","type":"bool"},{"indexed":false,"internalType":"uint8","name":"v","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"p","type":"uint256"}],"name":"ECu","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"c","type":"uint256"},{"indexed":true,"internalType":"address","name":"u","type":"address"},{"indexed":false,"internalType":"uint256","name":"p","type":"uint256"}],"name":"EFor","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"u","type":"address"},{"indexed":true,"internalType":"uint256","name":"c","type":"uint256"}],"name":"EJN","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"u","type":"address"},{"indexed":true,"internalType":"uint256","name":"c","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"a","type":"uint256"}],"name":"ERCM","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"c","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"r","type":"bytes32"}],"name":"ERew","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"u","type":"address"},{"indexed":true,"internalType":"uint256","name":"c","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"a","type":"uint256"}],"name":"EWD","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"R_ADMIN","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"R_AFFILIATE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"R_ORACLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"blockUser","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"challengeId","type":"uint256"}],"name":"cancel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"challengeId","type":"uint256"},{"internalType":"uint256","name":"rewardAmount","type":"uint256"},{"internalType":"bytes32[]","name":"rewardProof","type":"bytes32[]"}],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"challengeId","type":"uint256"}],"name":"close","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"challengeId","type":"uint256"},{"internalType":"address","name":"feeCollector","type":"address"}],"name":"conclude","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"buyInAmount","type":"uint256"},{"internalType":"uint256[]","name":"startAndEndDates","type":"uint256[]"},{"internalType":"uint256[]","name":"joinAndForfeitFees","type":"uint256[]"},{"internalType":"uint8[]","name":"metricAndCompStyle","type":"uint8[]"},{"internalType":"uint256","name":"initialStake","type":"uint256"},{"internalType":"uint32","name":"maximumNumberOfUsers","type":"uint32"},{"internalType":"uint32","name":"challengeGoal","type":"uint32"}],"name":"create","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"challengeId","type":"uint256"},{"internalType":"address[]","name":"addresses","type":"address[]"}],"name":"enrolled","outputs":[{"internalType":"bool[]","name":"","type":"bool[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"startIndex","type":"uint256"},{"internalType":"uint256","name":"endIndex","type":"uint256"},{"internalType":"bool","name":"fromArchive","type":"bool"}],"name":"enrolledIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"caller","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"fetchChallengesCheckEnrolled","outputs":[{"components":[{"internalType":"uint256","name":"totalStake","type":"uint256"},{"internalType":"uint256","name":"totalWithdrawn","type":"uint256"},{"internalType":"uint256","name":"totalReward","type":"uint256"},{"internalType":"uint256","name":"buyInAmount","type":"uint256"},{"internalType":"uint256[]","name":"joinAndForfeitFees","type":"uint256[]"},{"internalType":"uint256[]","name":"startAndEndTime","type":"uint256[]"},{"internalType":"uint32","name":"maximumNumberOfUsers","type":"uint32"},{"internalType":"uint32","name":"enrolledUsersCount","type":"uint32"},{"internalType":"uint32","name":"withdrawalsCount","type":"uint32"},{"internalType":"uint32","name":"challengeGoal","type":"uint32"},{"internalType":"uint8[]","name":"metricTypeAndCompStyle","type":"uint8[]"},{"internalType":"bool","name":"cancelled","type":"bool"},{"internalType":"bool","name":"concluded","type":"bool"},{"internalType":"address","name":"creator","type":"address"}],"internalType":"struct DataTypes.Challenge[]","name":"","type":"tuple[]"},{"internalType":"bool[]","name":"","type":"bool[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"challengeId","type":"uint256"}],"name":"forfeit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getAffiliateChallenge","outputs":[{"internalType":"uint256","name":"challengeId","type":"uint256"},{"internalType":"uint256","name":"size","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"challengeId","type":"uint256"}],"name":"getChallenge","outputs":[{"components":[{"internalType":"uint256","name":"totalStake","type":"uint256"},{"internalType":"uint256","name":"totalWithdrawn","type":"uint256"},{"internalType":"uint256","name":"totalReward","type":"uint256"},{"internalType":"uint256","name":"buyInAmount","type":"uint256"},{"internalType":"uint256[]","name":"joinAndForfeitFees","type":"uint256[]"},{"internalType":"uint256[]","name":"startAndEndTime","type":"uint256[]"},{"internalType":"uint32","name":"maximumNumberOfUsers","type":"uint32"},{"internalType":"uint32","name":"enrolledUsersCount","type":"uint32"},{"internalType":"uint32","name":"withdrawalsCount","type":"uint32"},{"internalType":"uint32","name":"challengeGoal","type":"uint32"},{"internalType":"uint8[]","name":"metricTypeAndCompStyle","type":"uint8[]"},{"internalType":"bool","name":"cancelled","type":"bool"},{"internalType":"bool","name":"concluded","type":"bool"},{"internalType":"address","name":"creator","type":"address"}],"internalType":"struct DataTypes.Challenge","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getConfig","outputs":[{"components":[{"internalType":"uint256","name":"maxPotValue","type":"uint256"},{"internalType":"bool","name":"cancelAll","type":"bool"},{"internalType":"bool","name":"paused","type":"bool"},{"internalType":"uint32","name":"maxActive","type":"uint32"}],"internalType":"struct DataTypes.ArenaConfig","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLatestChallengeId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"challengeId","type":"uint256"}],"name":"getUserChallenge","outputs":[{"components":[{"internalType":"uint256","name":"amountWithdrawn","type":"uint256"},{"internalType":"uint256","name":"amountFromAirdrop","type":"uint256"},{"internalType":"bool","name":"withdrawn","type":"bool"}],"internalType":"struct DataTypes.UserChallenge","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getUserChallengesSizes","outputs":[{"internalType":"uint256","name":"activeSize","type":"uint256"},{"internalType":"uint256","name":"archivedSize","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"challengeId","type":"uint256"}],"name":"join","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"challengeId","type":"uint256"}],"name":"reclaimStake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"challengeId","type":"uint256"}],"name":"resultPublished","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"challengeId","type":"uint256"},{"internalType":"bytes32","name":"root","type":"bytes32"},{"internalType":"uint256","name":"totalReward","type":"uint256"}],"name":"setResult","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"max","type":"uint8"},{"internalType":"bool","name":"cancelAll","type":"bool"},{"internalType":"bool","name":"pause","type":"bool"},{"internalType":"uint256","name":"maxPotValue","type":"uint256"}],"name":"updateState","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
60806040523480156200001157600080fd5b506040516200651a3803806200651a83398181016040528101906200003791906200067b565b60018081905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161480620000a65750600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b15620000de576040517f440a57bf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b826002800160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600260030160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506040518060800160405280838152602001600015158152602001600015158152602001600363ffffffff1681525060026000016000820151816000015560208201518160010160006101000a81548160ff02191690831515021790555060408201518160010160016101000a81548160ff02191690831515021790555060608201518160010160026101000a81548163ffffffff021916908363ffffffff1602179055509050506002800160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600260030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b8152600401620002b2929190620006f9565b6020604051808303816000875af1158015620002d2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620002f8919062000763565b6200032f576040517f8b98626500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060405180608001604052806000801b81526020017fdf8b4c520ffe197c5343c6f5aec59570151ef9a492f2c624fd45ddde6135ec4281526020017f352d05fe3946dbe49277552ba941e744d5a96d9c60bc1ba0ea5f1d3ae000f7c881526020017ffdf5cf7b97a3a158dc25b3f02458feb3a6f48426bf701a6ae2403d3dff43cf0d815250905060005b6004811015620003fd57620003f0828260048110620003de57620003dd62000795565b5b6020020151336200040860201b60201c565b50806001019050620003ba565b5050505050620007c4565b60006200041c83836200050b60201b60201c565b6200050057600160008085815260200190815260200160002060000160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506200049c6200057560201b60201c565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001905062000505565b600090505b92915050565b600080600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600033905090565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620005af8262000582565b9050919050565b6000620005c382620005a2565b9050919050565b620005d581620005b6565b8114620005e157600080fd5b50565b600081519050620005f581620005ca565b92915050565b6000819050919050565b6200061081620005fb565b81146200061c57600080fd5b50565b600081519050620006308162000605565b92915050565b60006200064382620005a2565b9050919050565b620006558162000636565b81146200066157600080fd5b50565b60008151905062000675816200064a565b92915050565b6000806000606084860312156200069757620006966200057d565b5b6000620006a786828701620005e4565b9350506020620006ba868287016200061f565b9250506040620006cd8682870162000664565b9150509250925092565b620006e281620005a2565b82525050565b620006f381620005fb565b82525050565b6000604082019050620007106000830185620006d7565b6200071f6020830184620006e8565b9392505050565b60008115159050919050565b6200073d8162000726565b81146200074957600080fd5b50565b6000815190506200075d8162000732565b92915050565b6000602082840312156200077c576200077b6200057d565b5b60006200078c848285016200074c565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b615d4680620007d46000396000f3fe608060405234801561001057600080fd5b50600436106101e55760003560e01c80633ed546ab1161010f57806391d14854116100a2578063c3f909d411610071578063c3f909d4146105b2578063c9cae95d146105d0578063d547741f146105ec578063f401b6a314610608576101e5565b806391d148541461052a578063a217fddf1461055a578063ae0b51df14610578578063bd80423d14610594576101e5565b8063839bcce9116100de578063839bcce9146104a157806383b2663c146104bf57806385c6ccca146104dd5780638e212977146104f9576101e5565b80633ed546ab1461041d57806340e58ee5146104395780634cf732ae1461045557806366e58a8714610471576101e5565b8063248a9ca31161018757806336257fe41161015657806336257fe41461039657806336568abe146103b45780633c0baeae146103d05780633da0132514610401576101e5565b8063248a9ca3146102ea57806326ea41091461031a57806327f3d5eb1461034a5780632f2ff15d1461037a576101e5565b80630fd1a011116101c35780630fd1a011146102525780631bdd4b741461026e5780631cd82dec1461029e5780631d2a1d5c146102ba576101e5565b806301ffc9a7146101ea578063049878f31461021a5780630aebeb4e14610236575b600080fd5b61020460048036038101906101ff9190614700565b610639565b6040516102119190614748565b60405180910390f35b610234600480360381019061022f9190614799565b6106b3565b005b610250600480360381019061024b9190614799565b610981565b005b61026c6004803603810190610267919061482b565b610ac2565b005b61028860048036038101906102839190614799565b610c45565b6040516102959190614bb9565b60405180910390f35b6102b860048036038101906102b39190614c11565b610c68565b005b6102d460048036038101906102cf9190614de9565b610db6565b6040516102e19190614ef4565b60405180910390f35b61030460048036038101906102ff9190614f16565b610ecd565b6040516103119190614f52565b60405180910390f35b610334600480360381019061032f9190614f6d565b610eec565b6040516103419190614fef565b60405180910390f35b610364600480360381019061035f919061500a565b610f89565b60405161037191906150e0565b60405180910390f35b610394600480360381019061038f9190615102565b61104e565b005b61039e611070565b6040516103ab9190614f52565b60405180910390f35b6103ce60048036038101906103c99190615102565b611094565b005b6103ea60048036038101906103e59190615205565b61110f565b6040516103f892919061545f565b60405180910390f35b61041b60048036038101906104169190615496565b6112d0565b005b61043760048036038101906104329190614799565b61139c565b005b610453600480360381019061044e9190614799565b611771565b005b61046f600480360381019061046a91906155a0565b611ac0565b005b61048b60048036038101906104869190614799565b611d34565b6040516104989190614748565b60405180910390f35b6104a9611d5a565b6040516104b69190614f52565b60405180910390f35b6104c7611d7e565b6040516104d491906156b2565b60405180910390f35b6104f760048036038101906104f29190614799565b611d8b565b005b610513600480360381019061050e9190614f6d565b61202f565b6040516105219291906156cd565b60405180910390f35b610544600480360381019061053f9190615102565b612057565b6040516105519190614748565b60405180910390f35b6105626120c1565b60405161056f9190614f52565b60405180910390f35b610592600480360381019061058d91906157b9565b6120c8565b005b61059c6123e0565b6040516105a99190614f52565b60405180910390f35b6105ba612404565b6040516105c7919061587d565b60405180910390f35b6105ea60048036038101906105e59190615898565b612487565b005b61060660048036038101906106019190615102565b612783565b005b610622600480360381019061061d9190615496565b6127a5565b6040516106309291906156cd565b60405180910390f35b60007f7965db0b000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806106ac57506106ab826127c9565b5b9050919050565b6106bb612833565b600260000160010160019054906101000a900460ff1615610708576040517f8b8fbd9200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002600a0160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561078f576040517f59ff5ef100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000806107a8833360026128799092919063ffffffff16565b91509150600082111561084857600260030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f3fef3a333846040518363ffffffff1660e01b81526004016108159291906158e7565b600060405180830381600087803b15801561082f57600080fd5b505af1158015610843573d6000803e3d6000fd5b505050505b6000811180156108f957506002800160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330846040518463ffffffff1660e01b81526004016108b493929190615910565b6020604051808303816000875af11580156108d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108f7919061595c565b155b15610930576040517f8b98626500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b823373ffffffffffffffffffffffffffffffffffffffff167f9d8c35214e33b6ccdb5929d7c7f783f76aa65c51877f59a20990c2326730a43660405160405180910390a3505061097e612d10565b50565b6002600a0160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610a08576040517f59ff5ef100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000600260070160008381526020019081526020016000209050600281600501805490501015610a64576040517f5742932000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610a7a82336002612d199092919063ffffffff16565b813373ffffffffffffffffffffffffffffffffffffffff167f827480b2327e65cc3d89b10982a051de1e01f0501d661299d93a4bdae2014a9860405160405180910390a35050565b7fdf8b4c520ffe197c5343c6f5aec59570151ef9a492f2c624fd45ddde6135ec42610aec81612e2c565b6002600a0160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610b73576040517f59ff5ef100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b83600260000160010160006101000a81548160ff02191690831515021790555082600260000160010160016101000a81548160ff0219169083151502179055508460ff16600260000160010160026101000a81548163ffffffff021916908363ffffffff160217905550816002600001600001819055503373ffffffffffffffffffffffffffffffffffffffff167f236cb63c4d87e4914b02680a9ef83854e2d06cb081f908496258a9f12c61583885858886604051610c369493929190615998565b60405180910390a25050505050565b610c4d61448a565b610c61826002612e4090919063ffffffff16565b9050919050565b7f352d05fe3946dbe49277552ba941e744d5a96d9c60bc1ba0ea5f1d3ae000f7c8610c9281612e2c565b6000600260070160008681526020019081526020016000209050600281600501805490501080610ce357504281600501600181548110610cd557610cd46159dd565b5b906000526020600020015410155b15610d1a576040517fb027023700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8281600001541015610d58576040517f5742932000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610d6e858560026130eb9092919063ffffffff16565b828160020181905550847f0c02564a2acfe49496db41ad767401fbe6afcc61cc0b880e53fa2d374e3d9fc285604051610da79190614f52565b60405180910390a25050505050565b606060008251905060008167ffffffffffffffff811115610dda57610dd9614c7a565b5b604051908082528060200260200182016040528015610e085781602001602082028036833780820191505090505b50905060005b82811015610ec157600260080160008781526020019081526020016000206000868381518110610e4157610e406159dd565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16828281518110610ea457610ea36159dd565b5b602002602001019015159081151581525050806001019050610e0e565b50809250505092915050565b6000806000838152602001908152602001600020600101549050919050565b610ef461452b565b600260040160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002060405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900460ff161515151581525050905092915050565b606060008484610f999190615a3b565b905060008167ffffffffffffffff811115610fb757610fb6614c7a565b5b604051908082528060200260200182016040528015610fe55781602001602082028036833780820191505090505b50905060005b82811015611040576110168882896110039190615a6f565b87600261310a909392919063ffffffff16565b828281518110611029576110286159dd565b5b602002602001018181525050806001019050610feb565b508092505050949350505050565b61105782610ecd565b61106081612e2c565b61106a83836131dd565b50505050565b7f352d05fe3946dbe49277552ba941e744d5a96d9c60bc1ba0ea5f1d3ae000f7c881565b61109c6132ce565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614611100576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61110a82826132d6565b505050565b60608060008351905060008167ffffffffffffffff81111561113457611133614c7a565b5b60405190808252806020026020018201604052801561116d57816020015b61115a61448a565b8152602001906001900390816111525790505b50905060008267ffffffffffffffff81111561118c5761118b614c7a565b5b6040519080825280602002602001820160405280156111ba5781602001602082028036833780820191505090505b50905060005b838110156112bf576111f68782815181106111de576111dd6159dd565b5b60200260200101516002612e4090919063ffffffff16565b838281518110611209576112086159dd565b5b60200260200101819052506002600801600088838151811061122e5761122d6159dd565b5b6020026020010151815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168282815181106112a2576112a16159dd565b5b6020026020010190151590811515815250508060010190506111c0565b508181945094505050509250929050565b7fdf8b4c520ffe197c5343c6f5aec59570151ef9a492f2c624fd45ddde6135ec426112fa81612e2c565b60016002600a0160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff167f29b54cff5ce9f35b24ef8da573f8d283d81622e8f668caf2e9363c32288e99c160405160405180910390a25050565b6113a4612833565b6000600260070160008381526020019081526020016000209050600281600501805490501015611400576040517f5742932000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80600501600081548110611417576114166159dd565b5b906000526020600020015442111561145b576040517fb027023700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000806000611476853360026133c89092919063ffffffff16565b925092509250600082111561151857600260030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166347e7ef2433846040518363ffffffff1660e01b81526004016114e59291906158e7565b600060405180830381600087803b1580156114ff57600080fd5b505af1158015611513573d6000803e3d6000fd5b505050505b6000831180156115c757506002800160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33856040518363ffffffff1660e01b81526004016115829291906158e7565b6020604051808303816000875af11580156115a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115c5919061595c565b155b156115fe576040517f8b98626500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000811180156116d157506002800160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb8560080160029054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b815260040161168c9291906158e7565b6020604051808303816000875af11580156116ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116cf919061595c565b155b15611708576040517f8b98626500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff16857f8ec0d995e3ccf1e0d9d71d847e7848a9f1687c4c83d133c7b1b4766da0e5ded1848661174d9190615a6f565b60405161175a91906156b2565b60405180910390a35050505061176e612d10565b50565b611779612833565b6002600a0160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611800576040517f59ff5ef100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006002600701600083815260200190815260200160002090506000801b600260090160008481526020019081526020016000205414158061185057508060080160009054906101000a900460ff165b8061192d57506118807fdf8b4c520ffe197c5343c6f5aec59570151ef9a492f2c624fd45ddde6135ec4233612057565b8061192b57503373ffffffffffffffffffffffffffffffffffffffff168160080160029054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614801561192a575042816005016000815481106118f8576118f76159dd565b5b90600052602060002001541180611929575060028160060160049054906101000a900463ffffffff1663ffffffff16105b5b5b155b15611964576040517f5742932000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061197a83600261365690919063ffffffff16565b9050600081118015611a4f57506002800160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb8360080160029054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b8152600401611a0a9291906158e7565b6020604051808303816000875af1158015611a29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a4d919061595c565b155b15611a86576040517f8b98626500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b827fcb7c4c1a906919f635cac1249b060b33df976f616e648a19f47bbe8d051cb9bd60405160405180910390a25050611abd612d10565b50565b7ffdf5cf7b97a3a158dc25b3f02458feb3a6f48426bf701a6ae2403d3dff43cf0d611aea81612e2c565b600260000160010160019054906101000a900460ff1615611b37576040517f8b8fbd9200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611b3f612833565b6002600a0160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611bc6576040517f59ff5ef100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611bf08c8c8c8c8c8c8c8c8c8c3360026136f0909b9a9998979695949392919063ffffffff16565b9050600085118015611ca357506002800160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330886040518463ffffffff1660e01b8152600401611c5e93929190615910565b6020604051808303816000875af1158015611c7d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ca1919061595c565b155b15611cda576040517f8b98626500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b803373ffffffffffffffffffffffffffffffffffffffff167fc4639ecc98c353cbacec1cd0c1e02a4cef05ed195ef5a55e7f2ea3e48ba10bfa60405160405180910390a350611d27612d10565b5050505050505050505050565b60008060001b600260090160008481526020019081526020016000205414159050919050565b7ffdf5cf7b97a3a158dc25b3f02458feb3a6f48426bf701a6ae2403d3dff43cf0d81565b60006002600c0154905090565b611d93612833565b6000600260070160008381526020019081526020016000209050600281600501805490501080611df15750600260000160010160009054906101000a900460ff16158015611df057508060080160009054906101000a900460ff16155b5b15611e28576040517f5742932000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080611e4184336002613a9a9092919063ffffffff16565b915091506000811115611ee157600260030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166347e7ef2433836040518363ffffffff1660e01b8152600401611eae9291906158e7565b600060405180830381600087803b158015611ec857600080fd5b505af1158015611edc573d6000803e3d6000fd5b505050505b600082118015611f9057506002800160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33846040518363ffffffff1660e01b8152600401611f4b9291906158e7565b6020604051808303816000875af1158015611f6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f8e919061595c565b155b15611fc7576040517f8b98626500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b833373ffffffffffffffffffffffffffffffffffffffff167f8d738d1ebf5bd78fc5a5b8fca4be539e1c8ed25ef3b8f1646a676eb40c083f01838561200c9190615a6f565b60405161201991906156b2565b60405180910390a350505061202c612d10565b50565b60008061204884846002613d909092919063ffffffff16565b80925081935050509250929050565b600080600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b6000801b81565b6120d0612833565b600260000160010160019054906101000a900460ff161561211d576040517f8b8fbd9200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002600a0160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156121a4576040517f59ff5ef100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006002600701600085815260200190815260200160002090506002816005018054905010806121f5575042816005016001815481106121e7576121e66159dd565b5b906000526020600020015410155b1561222c576040517fb027023700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000801b60026009016000868152602001908152602001600020540361227e576040517f5742932000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061229a853386866002613e5190949392919063ffffffff16565b905060008111801561234b57506002800160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff1660e01b81526004016123069291906158e7565b6020604051808303816000875af1158015612325573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612349919061595c565b155b15612382576040517f8b98626500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b843373ffffffffffffffffffffffffffffffffffffffff167f9a1248c4ca3e05fea10fd292a49d4bfca845f27d89ccfc5b9c60887b52b02946836040516123c991906156b2565b60405180910390a350506123db612d10565b505050565b7fdf8b4c520ffe197c5343c6f5aec59570151ef9a492f2c624fd45ddde6135ec4281565b61240c61454e565b6002600001604051806080016040529081600082015481526020016001820160009054906101000a900460ff161515151581526020016001820160019054906101000a900460ff161515151581526020016001820160029054906101000a900463ffffffff1663ffffffff1663ffffffff1681525050905090565b61248f612833565b60006002600701600084815260200190815260200160002090506000801b6002600901600085815260200190815260200160002054036124fb576040517f5742932000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60028160050180549050108061253257504281600501600181548110612524576125236159dd565b5b906000526020600020015410155b15612569576040517fb027023700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061257f84600261408790919063ffffffff16565b905060008260080160029054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690503373ffffffffffffffffffffffffffffffffffffffff168360080160029054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161480156126365750600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b1561263f578390505b6000821180156126ee57506002800160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb82846040518363ffffffff1660e01b81526004016126a99291906158e7565b6020604051808303816000875af11580156126c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126ec919061595c565b155b15612725576040517f8b98626500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16857febeefc035e9ac1a46ed7fed63f235b431e8288c8f3bbc0ad40d477cc0824f3dd8460405161276c91906156b2565b60405180910390a350505061277f612d10565b5050565b61278c82610ecd565b61279581612e2c565b61279f83836132d6565b50505050565b6000806127bc83600261417b90919063ffffffff16565b8092508193505050915091565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60026001540361286f576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002600181905550565b600080600085600701600086815260200190815260200160002090506002816005018054905010806128b957508060080160009054906101000a900460ff165b806128f857508060060160009054906101000a900463ffffffff1663ffffffff168160060160049054906101000a900463ffffffff1663ffffffff1610155b8061296457508560000160010160029054906101000a900463ffffffff1663ffffffff168660050160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208054905010155b806129cb575085600801600086815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b806129f65750806005016000815481106129e8576129e76159dd565b5b906000526020600020015442115b15612a2d576040517fc1599bd900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60018160060160048282829054906101000a900463ffffffff16612a519190615aa3565b92506101000a81548163ffffffff021916908363ffffffff1602179055508060030154816000016000828254612a879190615a6f565b92505081905550600186600801600087815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508560050160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020859080600181540180825580915050600190039060005260206000200160009091909190915055600081600401600081548110612b7a57612b796159dd565b5b90600052602060002001548260030154612b949190615a6f565b905060008760030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231876040518263ffffffff1660e01b8152600401612bf59190615adb565b602060405180830381865afa158015612c12573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c369190615b0b565b9050818110612c4b5781945060009350612c5d565b8094508082612c5a9190615a3b565b93505b604051806060016040528060008152602001868152602001600015158152508860040160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000898152602001908152602001600020600082015181600001556020820151816001015560408201518160020160006101000a81548160ff021916908315150217905550905050505050935093915050565b60018081905550565b82600801600083815260200190815260200160002060008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16612daf576040517fc1599bd900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600083600801600084815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550612e278382846001614213565b505050565b612e3d81612e386132ce565b61438a565b50565b612e4861448a565b826007016000838152602001908152602001600020604051806101c00160405290816000820154815260200160018201548152602001600282015481526020016003820154815260200160048201805480602002602001604051908101604052809291908181526020018280548015612ee057602002820191906000526020600020905b815481526020019060010190808311612ecc575b5050505050815260200160058201805480602002602001604051908101604052809291908181526020018280548015612f3857602002820191906000526020600020905b815481526020019060010190808311612f24575b505050505081526020016006820160009054906101000a900463ffffffff1663ffffffff1663ffffffff1681526020016006820160049054906101000a900463ffffffff1663ffffffff1663ffffffff1681526020016006820160089054906101000a900463ffffffff1663ffffffff1663ffffffff16815260200160068201600c9054906101000a900463ffffffff1663ffffffff1663ffffffff1681526020016007820180548060200260200160405190810160405280929190818152602001828054801561304e57602002820191906000526020600020906000905b82829054906101000a900460ff1660ff16815260200190600101906020826000010492830192600103820291508084116130175790505b505050505081526020016008820160009054906101000a900460ff161515151581526020016008820160019054906101000a900460ff161515151581526020016008820160029054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681525050905092915050565b8083600901600084815260200190815260200160002081905550505050565b600081613174578460050160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208381548110613164576131636159dd565b5b90600052602060002001546131d3565b8460060160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002083815481106131c7576131c66159dd565b5b90600052602060002001545b9050949350505050565b60006131e98383612057565b6132c357600160008085815260200190815260200160002060000160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506132606132ce565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4600190506132c8565b600090505b92915050565b600033905090565b60006132e28383612057565b156133bd57600080600085815260200190815260200160002060000160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555061335a6132ce565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16847ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a4600190506133c2565b600090505b92915050565b600080600080866007016000878152602001908152602001600020905060008760040160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000888152602001908152602001600020905087600801600088815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615806134b557508060020160009054906101000a900460ff165b156134ec576040517fc1599bd900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600088600801600089815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060018160020160006101000a81548160ff021916908315150217905550816003015482600001600082825461358c9190615a3b565b9250508190555081600601600481819054906101000a900463ffffffff16809291906135b790615b38565b91906101000a81548163ffffffff021916908363ffffffff16021790555050816004016001815481106135ed576135ec6159dd565b5b90600052602060002001549250600083836003015461360c9190615a3b565b905060008260010154905081811061362a578195506000965061363c565b80955080826136399190615a3b565b96505b6136498a898b6000614213565b5050505093509350939050565b600080836007016000848152602001908152602001600020905060018160080160006101000a81548160ff02191690831515021790555060008160060160049054906101000a900463ffffffff1663ffffffff1682600301546136b99190615b61565b82600001546136c89190615a3b565b9050808260000160008282546136de9190615a3b565b92505081905550809250505092915050565b6000428b8b6000818110613707576137066159dd565b5b9050602002013511613745576040517f4e2d398e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8a8a6000818110613759576137586159dd565b5b905060200201358b8b6001818110613774576137736159dd565b5b90506020020135116137b2576040517f3797f07000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008c036137ec576040517fee33a53100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008463ffffffff160361382c576040517fe4b646f900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8c600001600001548463ffffffff168d6138469190615b61565b111561387e576040517feba0778d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60028989905010806138aa57508b898960008181106138a05761389f6159dd565b5b9050602002013510155b806138cf57508b898960018181106138c5576138c46159dd565b5b9050602002013510155b15613906576040517f36a9d01100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8c600c01600081548092919061391b90615ba3565b91905055508c600c0154905060008d600701600083815260200190815260200160002090508581600001819055508c81600301819055508b8b826005019190613965929190614580565b50848160060160006101000a81548163ffffffff021916908363ffffffff160217905550898982600401919061399c929190614580565b5087878260070191906139b09291906145cd565b508381600601600c6101000a81548163ffffffff021916908363ffffffff160217905550828160080160026101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600081600201819055508d600b0160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020829080600181540180825580915050600190039060005260206000200160009091909190915055509c9b505050505050505050505050565b6000806000856007016000868152602001908152602001600020905060008660040160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000878152602001908152602001600020905086600801600087815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580613b8657508060020160009054906101000a900460ff165b15613bbd576040517fc1599bd900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600087600801600088815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060018160020160006101000a81548160ff021916908315150217905550816003015481600001819055508160030154826001016000828254613c6a9190615a6f565b9250508190555060018260060160088282829054906101000a900463ffffffff16613c959190615aa3565b92506101000a81548163ffffffff021916908363ffffffff1602179055508160030154826000016000828254613ccb9190615a3b565b9250508190555060018260060160048282829054906101000a900463ffffffff16613cf69190615beb565b92506101000a81548163ffffffff021916908363ffffffff160217905550600082600401600081548110613d2d57613d2c6159dd565b5b90600052602060002001548360030154613d479190615a6f565b9050600082600101549050818110613d655781945060009550613d77565b8094508082613d749190615a3b565b95505b613d8489888a6001614213565b50505050935093915050565b60008084600b0160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805490509050828111613de8576000613e47565b84600b0160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208381548110613e3b57613e3a6159dd565b5b90600052602060002001545b9150935093915050565b600080866007016000878152602001908152602001600020905060008760040160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000888152602001908152602001600020905087600801600088815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580613f3b57508060020160009054906101000a900460ff165b15613f72576040517f5742932000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008686604051602001613f87929190615c8c565b604051602081830303815290604052805190602001209050613fbf858a60090160008b815260200190815260200160002054836143db565b613ff5576040517f56d7b03500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b85826000018190555060018260020160006101000a81548160ff0219169083151502179055508583600101600082825461402f9190615a6f565b9250508190555060018360060160088282829054906101000a900463ffffffff1661405a9190615aa3565b92506101000a81548163ffffffff021916908363ffffffff16021790555085935050505095945050505050565b60008083600701600084815260200190815260200160002090508060080160019054906101000a900460ff16156140ea576040517f5742932000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60018160080160016101000a81548160ff0219169083151502179055506000816004016000815481106141205761411f6159dd565b5b90600052602060002001548260060160049054906101000a900463ffffffff1663ffffffff166141509190615b61565b826002015483600001546141649190615a3b565b61416e9190615a6f565b9050809250505092915050565b6000808360050160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208054905091508360060160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208054905090509250929050565b60008460050160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905060008180549050905060005b8181101561438157848382815481106142805761427f6159dd565b5b906000526020600020015403614376578260018361429e9190615a3b565b815481106142af576142ae6159dd565b5b90600052602060002001548382815481106142cd576142cc6159dd565b5b9060005260206000200181905550828054806142ec576142eb615cb8565b5b600190038181906000526020600020016000905590558315614371578660060160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208590806001815401808255809150506001900390600052602060002001600090919091909150555b614381565b806001019050614264565b50505050505050565b6143948282612057565b6143d75780826040517fe2517d3f0000000000000000000000000000000000000000000000000000000081526004016143ce929190615ce7565b60405180910390fd5b5050565b6000826143e885846143f2565b1490509392505050565b60008082905060005b845181101561443d576144288286838151811061441b5761441a6159dd565b5b6020026020010151614448565b9150808061443590615ba3565b9150506143fb565b508091505092915050565b60008183106144605761445b8284614473565b61446b565b61446a8383614473565b5b905092915050565b600082600052816020526040600020905092915050565b604051806101c00160405280600081526020016000815260200160008152602001600081526020016060815260200160608152602001600063ffffffff168152602001600063ffffffff168152602001600063ffffffff168152602001600063ffffffff16815260200160608152602001600015158152602001600015158152602001600073ffffffffffffffffffffffffffffffffffffffff1681525090565b604051806060016040528060008152602001600081526020016000151581525090565b604051806080016040528060008152602001600015158152602001600015158152602001600063ffffffff1681525090565b8280548282559060005260206000209081019282156145bc579160200282015b828111156145bb5782358255916020019190600101906145a0565b5b5090506145c99190614677565b5090565b82805482825590600052602060002090601f016020900481019282156146665791602002820160005b8382111561463757833560ff1683826101000a81548160ff021916908360ff16021790555092602001926001016020816000010492830192600103026145f6565b80156146645782816101000a81549060ff0219169055600101602081600001049283019260010302614637565b505b5090506146739190614677565b5090565b5b80821115614690576000816000905550600101614678565b5090565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6146dd816146a8565b81146146e857600080fd5b50565b6000813590506146fa816146d4565b92915050565b6000602082840312156147165761471561469e565b5b6000614724848285016146eb565b91505092915050565b60008115159050919050565b6147428161472d565b82525050565b600060208201905061475d6000830184614739565b92915050565b6000819050919050565b61477681614763565b811461478157600080fd5b50565b6000813590506147938161476d565b92915050565b6000602082840312156147af576147ae61469e565b5b60006147bd84828501614784565b91505092915050565b600060ff82169050919050565b6147dc816147c6565b81146147e757600080fd5b50565b6000813590506147f9816147d3565b92915050565b6148088161472d565b811461481357600080fd5b50565b600081359050614825816147ff565b92915050565b600080600080608085870312156148455761484461469e565b5b6000614853878288016147ea565b945050602061486487828801614816565b935050604061487587828801614816565b925050606061488687828801614784565b91505092959194509250565b61489b81614763565b82525050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60006148d98383614892565b60208301905092915050565b6000602082019050919050565b60006148fd826148a1565b61490781856148ac565b9350614912836148bd565b8060005b8381101561494357815161492a88826148cd565b9750614935836148e5565b925050600181019050614916565b5085935050505092915050565b600063ffffffff82169050919050565b61496981614950565b82525050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6149a4816147c6565b82525050565b60006149b6838361499b565b60208301905092915050565b6000602082019050919050565b60006149da8261496f565b6149e4818561497a565b93506149ef8361498b565b8060005b83811015614a20578151614a0788826149aa565b9750614a12836149c2565b9250506001810190506149f3565b5085935050505092915050565b614a368161472d565b82525050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000614a6782614a3c565b9050919050565b614a7781614a5c565b82525050565b60006101c083016000830151614a966000860182614892565b506020830151614aa96020860182614892565b506040830151614abc6040860182614892565b506060830151614acf6060860182614892565b5060808301518482036080860152614ae782826148f2565b91505060a083015184820360a0860152614b0182826148f2565b91505060c0830151614b1660c0860182614960565b5060e0830151614b2960e0860182614960565b50610100830151614b3e610100860182614960565b50610120830151614b53610120860182614960565b50610140830151848203610140860152614b6d82826149cf565b915050610160830151614b84610160860182614a2d565b50610180830151614b99610180860182614a2d565b506101a0830151614bae6101a0860182614a6e565b508091505092915050565b60006020820190508181036000830152614bd38184614a7d565b905092915050565b6000819050919050565b614bee81614bdb565b8114614bf957600080fd5b50565b600081359050614c0b81614be5565b92915050565b600080600060608486031215614c2a57614c2961469e565b5b6000614c3886828701614784565b9350506020614c4986828701614bfc565b9250506040614c5a86828701614784565b9150509250925092565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b614cb282614c69565b810181811067ffffffffffffffff82111715614cd157614cd0614c7a565b5b80604052505050565b6000614ce4614694565b9050614cf08282614ca9565b919050565b600067ffffffffffffffff821115614d1057614d0f614c7a565b5b602082029050602081019050919050565b600080fd5b614d2f81614a5c565b8114614d3a57600080fd5b50565b600081359050614d4c81614d26565b92915050565b6000614d65614d6084614cf5565b614cda565b90508083825260208201905060208402830185811115614d8857614d87614d21565b5b835b81811015614db15780614d9d8882614d3d565b845260208401935050602081019050614d8a565b5050509392505050565b600082601f830112614dd057614dcf614c64565b5b8135614de0848260208601614d52565b91505092915050565b60008060408385031215614e0057614dff61469e565b5b6000614e0e85828601614784565b925050602083013567ffffffffffffffff811115614e2f57614e2e6146a3565b5b614e3b85828601614dbb565b9150509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6000614e7d8383614a2d565b60208301905092915050565b6000602082019050919050565b6000614ea182614e45565b614eab8185614e50565b9350614eb683614e61565b8060005b83811015614ee7578151614ece8882614e71565b9750614ed983614e89565b925050600181019050614eba565b5085935050505092915050565b60006020820190508181036000830152614f0e8184614e96565b905092915050565b600060208284031215614f2c57614f2b61469e565b5b6000614f3a84828501614bfc565b91505092915050565b614f4c81614bdb565b82525050565b6000602082019050614f676000830184614f43565b92915050565b60008060408385031215614f8457614f8361469e565b5b6000614f9285828601614d3d565b9250506020614fa385828601614784565b9150509250929050565b606082016000820151614fc36000850182614892565b506020820151614fd66020850182614892565b506040820151614fe96040850182614a2d565b50505050565b60006060820190506150046000830184614fad565b92915050565b600080600080608085870312156150245761502361469e565b5b600061503287828801614d3d565b945050602061504387828801614784565b935050604061505487828801614784565b925050606061506587828801614816565b91505092959194509250565b600082825260208201905092915050565b600061508d826148a1565b6150978185615071565b93506150a2836148bd565b8060005b838110156150d35781516150ba88826148cd565b97506150c5836148e5565b9250506001810190506150a6565b5085935050505092915050565b600060208201905081810360008301526150fa8184615082565b905092915050565b600080604083850312156151195761511861469e565b5b600061512785828601614bfc565b925050602061513885828601614d3d565b9150509250929050565b600067ffffffffffffffff82111561515d5761515c614c7a565b5b602082029050602081019050919050565b600061518161517c84615142565b614cda565b905080838252602082019050602084028301858111156151a4576151a3614d21565b5b835b818110156151cd57806151b98882614784565b8452602084019350506020810190506151a6565b5050509392505050565b600082601f8301126151ec576151eb614c64565b5b81356151fc84826020860161516e565b91505092915050565b6000806040838503121561521c5761521b61469e565b5b600061522a85828601614d3d565b925050602083013567ffffffffffffffff81111561524b5761524a6146a3565b5b615257858286016151d7565b9150509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60006101c0830160008301516152a66000860182614892565b5060208301516152b96020860182614892565b5060408301516152cc6040860182614892565b5060608301516152df6060860182614892565b50608083015184820360808601526152f782826148f2565b91505060a083015184820360a086015261531182826148f2565b91505060c083015161532660c0860182614960565b5060e083015161533960e0860182614960565b5061010083015161534e610100860182614960565b50610120830151615363610120860182614960565b5061014083015184820361014086015261537d82826149cf565b915050610160830151615394610160860182614a2d565b506101808301516153a9610180860182614a2d565b506101a08301516153be6101a0860182614a6e565b508091505092915050565b60006153d5838361528d565b905092915050565b6000602082019050919050565b60006153f582615261565b6153ff818561526c565b9350836020820285016154118561527d565b8060005b8581101561544d578484038952815161542e85826153c9565b9450615439836153dd565b925060208a01995050600181019050615415565b50829750879550505050505092915050565b6000604082019050818103600083015261547981856153ea565b9050818103602083015261548d8184614e96565b90509392505050565b6000602082840312156154ac576154ab61469e565b5b60006154ba84828501614d3d565b91505092915050565b600080fd5b60008083601f8401126154de576154dd614c64565b5b8235905067ffffffffffffffff8111156154fb576154fa6154c3565b5b60208301915083602082028301111561551757615516614d21565b5b9250929050565b60008083601f84011261553457615533614c64565b5b8235905067ffffffffffffffff811115615551576155506154c3565b5b60208301915083602082028301111561556d5761556c614d21565b5b9250929050565b61557d81614950565b811461558857600080fd5b50565b60008135905061559a81615574565b92915050565b60008060008060008060008060008060e08b8d0312156155c3576155c261469e565b5b60006155d18d828e01614784565b9a505060208b013567ffffffffffffffff8111156155f2576155f16146a3565b5b6155fe8d828e016154c8565b995099505060408b013567ffffffffffffffff811115615621576156206146a3565b5b61562d8d828e016154c8565b975097505060608b013567ffffffffffffffff8111156156505761564f6146a3565b5b61565c8d828e0161551e565b9550955050608061566f8d828e01614784565b93505060a06156808d828e0161558b565b92505060c06156918d828e0161558b565b9150509295989b9194979a5092959850565b6156ac81614763565b82525050565b60006020820190506156c760008301846156a3565b92915050565b60006040820190506156e260008301856156a3565b6156ef60208301846156a3565b9392505050565b600067ffffffffffffffff82111561571157615710614c7a565b5b602082029050602081019050919050565b6000615735615730846156f6565b614cda565b9050808382526020820190506020840283018581111561575857615757614d21565b5b835b81811015615781578061576d8882614bfc565b84526020840193505060208101905061575a565b5050509392505050565b600082601f8301126157a05761579f614c64565b5b81356157b0848260208601615722565b91505092915050565b6000806000606084860312156157d2576157d161469e565b5b60006157e086828701614784565b93505060206157f186828701614784565b925050604084013567ffffffffffffffff811115615812576158116146a3565b5b61581e8682870161578b565b9150509250925092565b60808201600082015161583e6000850182614892565b5060208201516158516020850182614a2d565b5060408201516158646040850182614a2d565b5060608201516158776060850182614960565b50505050565b60006080820190506158926000830184615828565b92915050565b600080604083850312156158af576158ae61469e565b5b60006158bd85828601614784565b92505060206158ce85828601614d3d565b9150509250929050565b6158e181614a5c565b82525050565b60006040820190506158fc60008301856158d8565b61590960208301846156a3565b9392505050565b600060608201905061592560008301866158d8565b61593260208301856158d8565b61593f60408301846156a3565b949350505050565b600081519050615956816147ff565b92915050565b6000602082840312156159725761597161469e565b5b600061598084828501615947565b91505092915050565b615992816147c6565b82525050565b60006080820190506159ad6000830187614739565b6159ba6020830186614739565b6159c76040830185615989565b6159d460608301846156a3565b95945050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000615a4682614763565b9150615a5183614763565b9250828203905081811115615a6957615a68615a0c565b5b92915050565b6000615a7a82614763565b9150615a8583614763565b9250828201905080821115615a9d57615a9c615a0c565b5b92915050565b6000615aae82614950565b9150615ab983614950565b9250828201905063ffffffff811115615ad557615ad4615a0c565b5b92915050565b6000602082019050615af060008301846158d8565b92915050565b600081519050615b058161476d565b92915050565b600060208284031215615b2157615b2061469e565b5b6000615b2f84828501615af6565b91505092915050565b6000615b4382614950565b915060008203615b5657615b55615a0c565b5b600182039050919050565b6000615b6c82614763565b9150615b7783614763565b9250828202615b8581614763565b91508282048414831517615b9c57615b9b615a0c565b5b5092915050565b6000615bae82614763565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203615be057615bdf615a0c565b5b600182019050919050565b6000615bf682614950565b9150615c0183614950565b9250828203905063ffffffff811115615c1d57615c1c615a0c565b5b92915050565b60008160601b9050919050565b6000615c3b82615c23565b9050919050565b6000615c4d82615c30565b9050919050565b615c65615c6082614a5c565b615c42565b82525050565b6000819050919050565b615c86615c8182614763565b615c6b565b82525050565b6000615c988285615c54565b601482019150615ca88284615c75565b6020820191508190509392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6000604082019050615cfc60008301856158d8565b615d096020830184614f43565b939250505056fea2646970667358221220ebd274a72f438190ccd29e5f596902f69f5c50724152ba7cbd23d85dcef8684064736f6c634300081400330000000000000000000000005b590e05450220b4a39b54b1ac86ec6a4690997b000000000000000000000000000000000000000000295be96e64066972000000000000000000000000000000a41b28e4e2a5806e849414c28b1bf92134f262bc
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101e55760003560e01c80633ed546ab1161010f57806391d14854116100a2578063c3f909d411610071578063c3f909d4146105b2578063c9cae95d146105d0578063d547741f146105ec578063f401b6a314610608576101e5565b806391d148541461052a578063a217fddf1461055a578063ae0b51df14610578578063bd80423d14610594576101e5565b8063839bcce9116100de578063839bcce9146104a157806383b2663c146104bf57806385c6ccca146104dd5780638e212977146104f9576101e5565b80633ed546ab1461041d57806340e58ee5146104395780634cf732ae1461045557806366e58a8714610471576101e5565b8063248a9ca31161018757806336257fe41161015657806336257fe41461039657806336568abe146103b45780633c0baeae146103d05780633da0132514610401576101e5565b8063248a9ca3146102ea57806326ea41091461031a57806327f3d5eb1461034a5780632f2ff15d1461037a576101e5565b80630fd1a011116101c35780630fd1a011146102525780631bdd4b741461026e5780631cd82dec1461029e5780631d2a1d5c146102ba576101e5565b806301ffc9a7146101ea578063049878f31461021a5780630aebeb4e14610236575b600080fd5b61020460048036038101906101ff9190614700565b610639565b6040516102119190614748565b60405180910390f35b610234600480360381019061022f9190614799565b6106b3565b005b610250600480360381019061024b9190614799565b610981565b005b61026c6004803603810190610267919061482b565b610ac2565b005b61028860048036038101906102839190614799565b610c45565b6040516102959190614bb9565b60405180910390f35b6102b860048036038101906102b39190614c11565b610c68565b005b6102d460048036038101906102cf9190614de9565b610db6565b6040516102e19190614ef4565b60405180910390f35b61030460048036038101906102ff9190614f16565b610ecd565b6040516103119190614f52565b60405180910390f35b610334600480360381019061032f9190614f6d565b610eec565b6040516103419190614fef565b60405180910390f35b610364600480360381019061035f919061500a565b610f89565b60405161037191906150e0565b60405180910390f35b610394600480360381019061038f9190615102565b61104e565b005b61039e611070565b6040516103ab9190614f52565b60405180910390f35b6103ce60048036038101906103c99190615102565b611094565b005b6103ea60048036038101906103e59190615205565b61110f565b6040516103f892919061545f565b60405180910390f35b61041b60048036038101906104169190615496565b6112d0565b005b61043760048036038101906104329190614799565b61139c565b005b610453600480360381019061044e9190614799565b611771565b005b61046f600480360381019061046a91906155a0565b611ac0565b005b61048b60048036038101906104869190614799565b611d34565b6040516104989190614748565b60405180910390f35b6104a9611d5a565b6040516104b69190614f52565b60405180910390f35b6104c7611d7e565b6040516104d491906156b2565b60405180910390f35b6104f760048036038101906104f29190614799565b611d8b565b005b610513600480360381019061050e9190614f6d565b61202f565b6040516105219291906156cd565b60405180910390f35b610544600480360381019061053f9190615102565b612057565b6040516105519190614748565b60405180910390f35b6105626120c1565b60405161056f9190614f52565b60405180910390f35b610592600480360381019061058d91906157b9565b6120c8565b005b61059c6123e0565b6040516105a99190614f52565b60405180910390f35b6105ba612404565b6040516105c7919061587d565b60405180910390f35b6105ea60048036038101906105e59190615898565b612487565b005b61060660048036038101906106019190615102565b612783565b005b610622600480360381019061061d9190615496565b6127a5565b6040516106309291906156cd565b60405180910390f35b60007f7965db0b000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806106ac57506106ab826127c9565b5b9050919050565b6106bb612833565b600260000160010160019054906101000a900460ff1615610708576040517f8b8fbd9200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002600a0160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561078f576040517f59ff5ef100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000806107a8833360026128799092919063ffffffff16565b91509150600082111561084857600260030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f3fef3a333846040518363ffffffff1660e01b81526004016108159291906158e7565b600060405180830381600087803b15801561082f57600080fd5b505af1158015610843573d6000803e3d6000fd5b505050505b6000811180156108f957506002800160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330846040518463ffffffff1660e01b81526004016108b493929190615910565b6020604051808303816000875af11580156108d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108f7919061595c565b155b15610930576040517f8b98626500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b823373ffffffffffffffffffffffffffffffffffffffff167f9d8c35214e33b6ccdb5929d7c7f783f76aa65c51877f59a20990c2326730a43660405160405180910390a3505061097e612d10565b50565b6002600a0160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610a08576040517f59ff5ef100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000600260070160008381526020019081526020016000209050600281600501805490501015610a64576040517f5742932000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610a7a82336002612d199092919063ffffffff16565b813373ffffffffffffffffffffffffffffffffffffffff167f827480b2327e65cc3d89b10982a051de1e01f0501d661299d93a4bdae2014a9860405160405180910390a35050565b7fdf8b4c520ffe197c5343c6f5aec59570151ef9a492f2c624fd45ddde6135ec42610aec81612e2c565b6002600a0160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610b73576040517f59ff5ef100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b83600260000160010160006101000a81548160ff02191690831515021790555082600260000160010160016101000a81548160ff0219169083151502179055508460ff16600260000160010160026101000a81548163ffffffff021916908363ffffffff160217905550816002600001600001819055503373ffffffffffffffffffffffffffffffffffffffff167f236cb63c4d87e4914b02680a9ef83854e2d06cb081f908496258a9f12c61583885858886604051610c369493929190615998565b60405180910390a25050505050565b610c4d61448a565b610c61826002612e4090919063ffffffff16565b9050919050565b7f352d05fe3946dbe49277552ba941e744d5a96d9c60bc1ba0ea5f1d3ae000f7c8610c9281612e2c565b6000600260070160008681526020019081526020016000209050600281600501805490501080610ce357504281600501600181548110610cd557610cd46159dd565b5b906000526020600020015410155b15610d1a576040517fb027023700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8281600001541015610d58576040517f5742932000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610d6e858560026130eb9092919063ffffffff16565b828160020181905550847f0c02564a2acfe49496db41ad767401fbe6afcc61cc0b880e53fa2d374e3d9fc285604051610da79190614f52565b60405180910390a25050505050565b606060008251905060008167ffffffffffffffff811115610dda57610dd9614c7a565b5b604051908082528060200260200182016040528015610e085781602001602082028036833780820191505090505b50905060005b82811015610ec157600260080160008781526020019081526020016000206000868381518110610e4157610e406159dd565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16828281518110610ea457610ea36159dd565b5b602002602001019015159081151581525050806001019050610e0e565b50809250505092915050565b6000806000838152602001908152602001600020600101549050919050565b610ef461452b565b600260040160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002060405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900460ff161515151581525050905092915050565b606060008484610f999190615a3b565b905060008167ffffffffffffffff811115610fb757610fb6614c7a565b5b604051908082528060200260200182016040528015610fe55781602001602082028036833780820191505090505b50905060005b82811015611040576110168882896110039190615a6f565b87600261310a909392919063ffffffff16565b828281518110611029576110286159dd565b5b602002602001018181525050806001019050610feb565b508092505050949350505050565b61105782610ecd565b61106081612e2c565b61106a83836131dd565b50505050565b7f352d05fe3946dbe49277552ba941e744d5a96d9c60bc1ba0ea5f1d3ae000f7c881565b61109c6132ce565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614611100576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61110a82826132d6565b505050565b60608060008351905060008167ffffffffffffffff81111561113457611133614c7a565b5b60405190808252806020026020018201604052801561116d57816020015b61115a61448a565b8152602001906001900390816111525790505b50905060008267ffffffffffffffff81111561118c5761118b614c7a565b5b6040519080825280602002602001820160405280156111ba5781602001602082028036833780820191505090505b50905060005b838110156112bf576111f68782815181106111de576111dd6159dd565b5b60200260200101516002612e4090919063ffffffff16565b838281518110611209576112086159dd565b5b60200260200101819052506002600801600088838151811061122e5761122d6159dd565b5b6020026020010151815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168282815181106112a2576112a16159dd565b5b6020026020010190151590811515815250508060010190506111c0565b508181945094505050509250929050565b7fdf8b4c520ffe197c5343c6f5aec59570151ef9a492f2c624fd45ddde6135ec426112fa81612e2c565b60016002600a0160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff167f29b54cff5ce9f35b24ef8da573f8d283d81622e8f668caf2e9363c32288e99c160405160405180910390a25050565b6113a4612833565b6000600260070160008381526020019081526020016000209050600281600501805490501015611400576040517f5742932000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80600501600081548110611417576114166159dd565b5b906000526020600020015442111561145b576040517fb027023700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000806000611476853360026133c89092919063ffffffff16565b925092509250600082111561151857600260030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166347e7ef2433846040518363ffffffff1660e01b81526004016114e59291906158e7565b600060405180830381600087803b1580156114ff57600080fd5b505af1158015611513573d6000803e3d6000fd5b505050505b6000831180156115c757506002800160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33856040518363ffffffff1660e01b81526004016115829291906158e7565b6020604051808303816000875af11580156115a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115c5919061595c565b155b156115fe576040517f8b98626500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000811180156116d157506002800160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb8560080160029054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b815260040161168c9291906158e7565b6020604051808303816000875af11580156116ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116cf919061595c565b155b15611708576040517f8b98626500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff16857f8ec0d995e3ccf1e0d9d71d847e7848a9f1687c4c83d133c7b1b4766da0e5ded1848661174d9190615a6f565b60405161175a91906156b2565b60405180910390a35050505061176e612d10565b50565b611779612833565b6002600a0160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611800576040517f59ff5ef100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006002600701600083815260200190815260200160002090506000801b600260090160008481526020019081526020016000205414158061185057508060080160009054906101000a900460ff165b8061192d57506118807fdf8b4c520ffe197c5343c6f5aec59570151ef9a492f2c624fd45ddde6135ec4233612057565b8061192b57503373ffffffffffffffffffffffffffffffffffffffff168160080160029054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614801561192a575042816005016000815481106118f8576118f76159dd565b5b90600052602060002001541180611929575060028160060160049054906101000a900463ffffffff1663ffffffff16105b5b5b155b15611964576040517f5742932000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061197a83600261365690919063ffffffff16565b9050600081118015611a4f57506002800160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb8360080160029054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b8152600401611a0a9291906158e7565b6020604051808303816000875af1158015611a29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a4d919061595c565b155b15611a86576040517f8b98626500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b827fcb7c4c1a906919f635cac1249b060b33df976f616e648a19f47bbe8d051cb9bd60405160405180910390a25050611abd612d10565b50565b7ffdf5cf7b97a3a158dc25b3f02458feb3a6f48426bf701a6ae2403d3dff43cf0d611aea81612e2c565b600260000160010160019054906101000a900460ff1615611b37576040517f8b8fbd9200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611b3f612833565b6002600a0160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611bc6576040517f59ff5ef100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611bf08c8c8c8c8c8c8c8c8c8c3360026136f0909b9a9998979695949392919063ffffffff16565b9050600085118015611ca357506002800160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330886040518463ffffffff1660e01b8152600401611c5e93929190615910565b6020604051808303816000875af1158015611c7d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ca1919061595c565b155b15611cda576040517f8b98626500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b803373ffffffffffffffffffffffffffffffffffffffff167fc4639ecc98c353cbacec1cd0c1e02a4cef05ed195ef5a55e7f2ea3e48ba10bfa60405160405180910390a350611d27612d10565b5050505050505050505050565b60008060001b600260090160008481526020019081526020016000205414159050919050565b7ffdf5cf7b97a3a158dc25b3f02458feb3a6f48426bf701a6ae2403d3dff43cf0d81565b60006002600c0154905090565b611d93612833565b6000600260070160008381526020019081526020016000209050600281600501805490501080611df15750600260000160010160009054906101000a900460ff16158015611df057508060080160009054906101000a900460ff16155b5b15611e28576040517f5742932000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080611e4184336002613a9a9092919063ffffffff16565b915091506000811115611ee157600260030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166347e7ef2433836040518363ffffffff1660e01b8152600401611eae9291906158e7565b600060405180830381600087803b158015611ec857600080fd5b505af1158015611edc573d6000803e3d6000fd5b505050505b600082118015611f9057506002800160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33846040518363ffffffff1660e01b8152600401611f4b9291906158e7565b6020604051808303816000875af1158015611f6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f8e919061595c565b155b15611fc7576040517f8b98626500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b833373ffffffffffffffffffffffffffffffffffffffff167f8d738d1ebf5bd78fc5a5b8fca4be539e1c8ed25ef3b8f1646a676eb40c083f01838561200c9190615a6f565b60405161201991906156b2565b60405180910390a350505061202c612d10565b50565b60008061204884846002613d909092919063ffffffff16565b80925081935050509250929050565b600080600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b6000801b81565b6120d0612833565b600260000160010160019054906101000a900460ff161561211d576040517f8b8fbd9200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002600a0160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156121a4576040517f59ff5ef100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006002600701600085815260200190815260200160002090506002816005018054905010806121f5575042816005016001815481106121e7576121e66159dd565b5b906000526020600020015410155b1561222c576040517fb027023700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000801b60026009016000868152602001908152602001600020540361227e576040517f5742932000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061229a853386866002613e5190949392919063ffffffff16565b905060008111801561234b57506002800160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff1660e01b81526004016123069291906158e7565b6020604051808303816000875af1158015612325573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612349919061595c565b155b15612382576040517f8b98626500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b843373ffffffffffffffffffffffffffffffffffffffff167f9a1248c4ca3e05fea10fd292a49d4bfca845f27d89ccfc5b9c60887b52b02946836040516123c991906156b2565b60405180910390a350506123db612d10565b505050565b7fdf8b4c520ffe197c5343c6f5aec59570151ef9a492f2c624fd45ddde6135ec4281565b61240c61454e565b6002600001604051806080016040529081600082015481526020016001820160009054906101000a900460ff161515151581526020016001820160019054906101000a900460ff161515151581526020016001820160029054906101000a900463ffffffff1663ffffffff1663ffffffff1681525050905090565b61248f612833565b60006002600701600084815260200190815260200160002090506000801b6002600901600085815260200190815260200160002054036124fb576040517f5742932000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60028160050180549050108061253257504281600501600181548110612524576125236159dd565b5b906000526020600020015410155b15612569576040517fb027023700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061257f84600261408790919063ffffffff16565b905060008260080160029054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690503373ffffffffffffffffffffffffffffffffffffffff168360080160029054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161480156126365750600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b1561263f578390505b6000821180156126ee57506002800160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb82846040518363ffffffff1660e01b81526004016126a99291906158e7565b6020604051808303816000875af11580156126c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126ec919061595c565b155b15612725576040517f8b98626500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16857febeefc035e9ac1a46ed7fed63f235b431e8288c8f3bbc0ad40d477cc0824f3dd8460405161276c91906156b2565b60405180910390a350505061277f612d10565b5050565b61278c82610ecd565b61279581612e2c565b61279f83836132d6565b50505050565b6000806127bc83600261417b90919063ffffffff16565b8092508193505050915091565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60026001540361286f576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002600181905550565b600080600085600701600086815260200190815260200160002090506002816005018054905010806128b957508060080160009054906101000a900460ff165b806128f857508060060160009054906101000a900463ffffffff1663ffffffff168160060160049054906101000a900463ffffffff1663ffffffff1610155b8061296457508560000160010160029054906101000a900463ffffffff1663ffffffff168660050160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208054905010155b806129cb575085600801600086815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b806129f65750806005016000815481106129e8576129e76159dd565b5b906000526020600020015442115b15612a2d576040517fc1599bd900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60018160060160048282829054906101000a900463ffffffff16612a519190615aa3565b92506101000a81548163ffffffff021916908363ffffffff1602179055508060030154816000016000828254612a879190615a6f565b92505081905550600186600801600087815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508560050160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020859080600181540180825580915050600190039060005260206000200160009091909190915055600081600401600081548110612b7a57612b796159dd565b5b90600052602060002001548260030154612b949190615a6f565b905060008760030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231876040518263ffffffff1660e01b8152600401612bf59190615adb565b602060405180830381865afa158015612c12573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c369190615b0b565b9050818110612c4b5781945060009350612c5d565b8094508082612c5a9190615a3b565b93505b604051806060016040528060008152602001868152602001600015158152508860040160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000898152602001908152602001600020600082015181600001556020820151816001015560408201518160020160006101000a81548160ff021916908315150217905550905050505050935093915050565b60018081905550565b82600801600083815260200190815260200160002060008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16612daf576040517fc1599bd900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600083600801600084815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550612e278382846001614213565b505050565b612e3d81612e386132ce565b61438a565b50565b612e4861448a565b826007016000838152602001908152602001600020604051806101c00160405290816000820154815260200160018201548152602001600282015481526020016003820154815260200160048201805480602002602001604051908101604052809291908181526020018280548015612ee057602002820191906000526020600020905b815481526020019060010190808311612ecc575b5050505050815260200160058201805480602002602001604051908101604052809291908181526020018280548015612f3857602002820191906000526020600020905b815481526020019060010190808311612f24575b505050505081526020016006820160009054906101000a900463ffffffff1663ffffffff1663ffffffff1681526020016006820160049054906101000a900463ffffffff1663ffffffff1663ffffffff1681526020016006820160089054906101000a900463ffffffff1663ffffffff1663ffffffff16815260200160068201600c9054906101000a900463ffffffff1663ffffffff1663ffffffff1681526020016007820180548060200260200160405190810160405280929190818152602001828054801561304e57602002820191906000526020600020906000905b82829054906101000a900460ff1660ff16815260200190600101906020826000010492830192600103820291508084116130175790505b505050505081526020016008820160009054906101000a900460ff161515151581526020016008820160019054906101000a900460ff161515151581526020016008820160029054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681525050905092915050565b8083600901600084815260200190815260200160002081905550505050565b600081613174578460050160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208381548110613164576131636159dd565b5b90600052602060002001546131d3565b8460060160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002083815481106131c7576131c66159dd565b5b90600052602060002001545b9050949350505050565b60006131e98383612057565b6132c357600160008085815260200190815260200160002060000160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506132606132ce565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4600190506132c8565b600090505b92915050565b600033905090565b60006132e28383612057565b156133bd57600080600085815260200190815260200160002060000160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555061335a6132ce565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16847ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a4600190506133c2565b600090505b92915050565b600080600080866007016000878152602001908152602001600020905060008760040160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000888152602001908152602001600020905087600801600088815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615806134b557508060020160009054906101000a900460ff165b156134ec576040517fc1599bd900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600088600801600089815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060018160020160006101000a81548160ff021916908315150217905550816003015482600001600082825461358c9190615a3b565b9250508190555081600601600481819054906101000a900463ffffffff16809291906135b790615b38565b91906101000a81548163ffffffff021916908363ffffffff16021790555050816004016001815481106135ed576135ec6159dd565b5b90600052602060002001549250600083836003015461360c9190615a3b565b905060008260010154905081811061362a578195506000965061363c565b80955080826136399190615a3b565b96505b6136498a898b6000614213565b5050505093509350939050565b600080836007016000848152602001908152602001600020905060018160080160006101000a81548160ff02191690831515021790555060008160060160049054906101000a900463ffffffff1663ffffffff1682600301546136b99190615b61565b82600001546136c89190615a3b565b9050808260000160008282546136de9190615a3b565b92505081905550809250505092915050565b6000428b8b6000818110613707576137066159dd565b5b9050602002013511613745576040517f4e2d398e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8a8a6000818110613759576137586159dd565b5b905060200201358b8b6001818110613774576137736159dd565b5b90506020020135116137b2576040517f3797f07000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008c036137ec576040517fee33a53100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008463ffffffff160361382c576040517fe4b646f900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8c600001600001548463ffffffff168d6138469190615b61565b111561387e576040517feba0778d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60028989905010806138aa57508b898960008181106138a05761389f6159dd565b5b9050602002013510155b806138cf57508b898960018181106138c5576138c46159dd565b5b9050602002013510155b15613906576040517f36a9d01100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8c600c01600081548092919061391b90615ba3565b91905055508c600c0154905060008d600701600083815260200190815260200160002090508581600001819055508c81600301819055508b8b826005019190613965929190614580565b50848160060160006101000a81548163ffffffff021916908363ffffffff160217905550898982600401919061399c929190614580565b5087878260070191906139b09291906145cd565b508381600601600c6101000a81548163ffffffff021916908363ffffffff160217905550828160080160026101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600081600201819055508d600b0160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020829080600181540180825580915050600190039060005260206000200160009091909190915055509c9b505050505050505050505050565b6000806000856007016000868152602001908152602001600020905060008660040160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000878152602001908152602001600020905086600801600087815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580613b8657508060020160009054906101000a900460ff165b15613bbd576040517fc1599bd900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600087600801600088815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060018160020160006101000a81548160ff021916908315150217905550816003015481600001819055508160030154826001016000828254613c6a9190615a6f565b9250508190555060018260060160088282829054906101000a900463ffffffff16613c959190615aa3565b92506101000a81548163ffffffff021916908363ffffffff1602179055508160030154826000016000828254613ccb9190615a3b565b9250508190555060018260060160048282829054906101000a900463ffffffff16613cf69190615beb565b92506101000a81548163ffffffff021916908363ffffffff160217905550600082600401600081548110613d2d57613d2c6159dd565b5b90600052602060002001548360030154613d479190615a6f565b9050600082600101549050818110613d655781945060009550613d77565b8094508082613d749190615a3b565b95505b613d8489888a6001614213565b50505050935093915050565b60008084600b0160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805490509050828111613de8576000613e47565b84600b0160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208381548110613e3b57613e3a6159dd565b5b90600052602060002001545b9150935093915050565b600080866007016000878152602001908152602001600020905060008760040160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000888152602001908152602001600020905087600801600088815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580613f3b57508060020160009054906101000a900460ff165b15613f72576040517f5742932000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008686604051602001613f87929190615c8c565b604051602081830303815290604052805190602001209050613fbf858a60090160008b815260200190815260200160002054836143db565b613ff5576040517f56d7b03500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b85826000018190555060018260020160006101000a81548160ff0219169083151502179055508583600101600082825461402f9190615a6f565b9250508190555060018360060160088282829054906101000a900463ffffffff1661405a9190615aa3565b92506101000a81548163ffffffff021916908363ffffffff16021790555085935050505095945050505050565b60008083600701600084815260200190815260200160002090508060080160019054906101000a900460ff16156140ea576040517f5742932000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60018160080160016101000a81548160ff0219169083151502179055506000816004016000815481106141205761411f6159dd565b5b90600052602060002001548260060160049054906101000a900463ffffffff1663ffffffff166141509190615b61565b826002015483600001546141649190615a3b565b61416e9190615a6f565b9050809250505092915050565b6000808360050160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208054905091508360060160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208054905090509250929050565b60008460050160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905060008180549050905060005b8181101561438157848382815481106142805761427f6159dd565b5b906000526020600020015403614376578260018361429e9190615a3b565b815481106142af576142ae6159dd565b5b90600052602060002001548382815481106142cd576142cc6159dd565b5b9060005260206000200181905550828054806142ec576142eb615cb8565b5b600190038181906000526020600020016000905590558315614371578660060160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208590806001815401808255809150506001900390600052602060002001600090919091909150555b614381565b806001019050614264565b50505050505050565b6143948282612057565b6143d75780826040517fe2517d3f0000000000000000000000000000000000000000000000000000000081526004016143ce929190615ce7565b60405180910390fd5b5050565b6000826143e885846143f2565b1490509392505050565b60008082905060005b845181101561443d576144288286838151811061441b5761441a6159dd565b5b6020026020010151614448565b9150808061443590615ba3565b9150506143fb565b508091505092915050565b60008183106144605761445b8284614473565b61446b565b61446a8383614473565b5b905092915050565b600082600052816020526040600020905092915050565b604051806101c00160405280600081526020016000815260200160008152602001600081526020016060815260200160608152602001600063ffffffff168152602001600063ffffffff168152602001600063ffffffff168152602001600063ffffffff16815260200160608152602001600015158152602001600015158152602001600073ffffffffffffffffffffffffffffffffffffffff1681525090565b604051806060016040528060008152602001600081526020016000151581525090565b604051806080016040528060008152602001600015158152602001600015158152602001600063ffffffff1681525090565b8280548282559060005260206000209081019282156145bc579160200282015b828111156145bb5782358255916020019190600101906145a0565b5b5090506145c99190614677565b5090565b82805482825590600052602060002090601f016020900481019282156146665791602002820160005b8382111561463757833560ff1683826101000a81548160ff021916908360ff16021790555092602001926001016020816000010492830192600103026145f6565b80156146645782816101000a81549060ff0219169055600101602081600001049283019260010302614637565b505b5090506146739190614677565b5090565b5b80821115614690576000816000905550600101614678565b5090565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6146dd816146a8565b81146146e857600080fd5b50565b6000813590506146fa816146d4565b92915050565b6000602082840312156147165761471561469e565b5b6000614724848285016146eb565b91505092915050565b60008115159050919050565b6147428161472d565b82525050565b600060208201905061475d6000830184614739565b92915050565b6000819050919050565b61477681614763565b811461478157600080fd5b50565b6000813590506147938161476d565b92915050565b6000602082840312156147af576147ae61469e565b5b60006147bd84828501614784565b91505092915050565b600060ff82169050919050565b6147dc816147c6565b81146147e757600080fd5b50565b6000813590506147f9816147d3565b92915050565b6148088161472d565b811461481357600080fd5b50565b600081359050614825816147ff565b92915050565b600080600080608085870312156148455761484461469e565b5b6000614853878288016147ea565b945050602061486487828801614816565b935050604061487587828801614816565b925050606061488687828801614784565b91505092959194509250565b61489b81614763565b82525050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60006148d98383614892565b60208301905092915050565b6000602082019050919050565b60006148fd826148a1565b61490781856148ac565b9350614912836148bd565b8060005b8381101561494357815161492a88826148cd565b9750614935836148e5565b925050600181019050614916565b5085935050505092915050565b600063ffffffff82169050919050565b61496981614950565b82525050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6149a4816147c6565b82525050565b60006149b6838361499b565b60208301905092915050565b6000602082019050919050565b60006149da8261496f565b6149e4818561497a565b93506149ef8361498b565b8060005b83811015614a20578151614a0788826149aa565b9750614a12836149c2565b9250506001810190506149f3565b5085935050505092915050565b614a368161472d565b82525050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000614a6782614a3c565b9050919050565b614a7781614a5c565b82525050565b60006101c083016000830151614a966000860182614892565b506020830151614aa96020860182614892565b506040830151614abc6040860182614892565b506060830151614acf6060860182614892565b5060808301518482036080860152614ae782826148f2565b91505060a083015184820360a0860152614b0182826148f2565b91505060c0830151614b1660c0860182614960565b5060e0830151614b2960e0860182614960565b50610100830151614b3e610100860182614960565b50610120830151614b53610120860182614960565b50610140830151848203610140860152614b6d82826149cf565b915050610160830151614b84610160860182614a2d565b50610180830151614b99610180860182614a2d565b506101a0830151614bae6101a0860182614a6e565b508091505092915050565b60006020820190508181036000830152614bd38184614a7d565b905092915050565b6000819050919050565b614bee81614bdb565b8114614bf957600080fd5b50565b600081359050614c0b81614be5565b92915050565b600080600060608486031215614c2a57614c2961469e565b5b6000614c3886828701614784565b9350506020614c4986828701614bfc565b9250506040614c5a86828701614784565b9150509250925092565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b614cb282614c69565b810181811067ffffffffffffffff82111715614cd157614cd0614c7a565b5b80604052505050565b6000614ce4614694565b9050614cf08282614ca9565b919050565b600067ffffffffffffffff821115614d1057614d0f614c7a565b5b602082029050602081019050919050565b600080fd5b614d2f81614a5c565b8114614d3a57600080fd5b50565b600081359050614d4c81614d26565b92915050565b6000614d65614d6084614cf5565b614cda565b90508083825260208201905060208402830185811115614d8857614d87614d21565b5b835b81811015614db15780614d9d8882614d3d565b845260208401935050602081019050614d8a565b5050509392505050565b600082601f830112614dd057614dcf614c64565b5b8135614de0848260208601614d52565b91505092915050565b60008060408385031215614e0057614dff61469e565b5b6000614e0e85828601614784565b925050602083013567ffffffffffffffff811115614e2f57614e2e6146a3565b5b614e3b85828601614dbb565b9150509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6000614e7d8383614a2d565b60208301905092915050565b6000602082019050919050565b6000614ea182614e45565b614eab8185614e50565b9350614eb683614e61565b8060005b83811015614ee7578151614ece8882614e71565b9750614ed983614e89565b925050600181019050614eba565b5085935050505092915050565b60006020820190508181036000830152614f0e8184614e96565b905092915050565b600060208284031215614f2c57614f2b61469e565b5b6000614f3a84828501614bfc565b91505092915050565b614f4c81614bdb565b82525050565b6000602082019050614f676000830184614f43565b92915050565b60008060408385031215614f8457614f8361469e565b5b6000614f9285828601614d3d565b9250506020614fa385828601614784565b9150509250929050565b606082016000820151614fc36000850182614892565b506020820151614fd66020850182614892565b506040820151614fe96040850182614a2d565b50505050565b60006060820190506150046000830184614fad565b92915050565b600080600080608085870312156150245761502361469e565b5b600061503287828801614d3d565b945050602061504387828801614784565b935050604061505487828801614784565b925050606061506587828801614816565b91505092959194509250565b600082825260208201905092915050565b600061508d826148a1565b6150978185615071565b93506150a2836148bd565b8060005b838110156150d35781516150ba88826148cd565b97506150c5836148e5565b9250506001810190506150a6565b5085935050505092915050565b600060208201905081810360008301526150fa8184615082565b905092915050565b600080604083850312156151195761511861469e565b5b600061512785828601614bfc565b925050602061513885828601614d3d565b9150509250929050565b600067ffffffffffffffff82111561515d5761515c614c7a565b5b602082029050602081019050919050565b600061518161517c84615142565b614cda565b905080838252602082019050602084028301858111156151a4576151a3614d21565b5b835b818110156151cd57806151b98882614784565b8452602084019350506020810190506151a6565b5050509392505050565b600082601f8301126151ec576151eb614c64565b5b81356151fc84826020860161516e565b91505092915050565b6000806040838503121561521c5761521b61469e565b5b600061522a85828601614d3d565b925050602083013567ffffffffffffffff81111561524b5761524a6146a3565b5b615257858286016151d7565b9150509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60006101c0830160008301516152a66000860182614892565b5060208301516152b96020860182614892565b5060408301516152cc6040860182614892565b5060608301516152df6060860182614892565b50608083015184820360808601526152f782826148f2565b91505060a083015184820360a086015261531182826148f2565b91505060c083015161532660c0860182614960565b5060e083015161533960e0860182614960565b5061010083015161534e610100860182614960565b50610120830151615363610120860182614960565b5061014083015184820361014086015261537d82826149cf565b915050610160830151615394610160860182614a2d565b506101808301516153a9610180860182614a2d565b506101a08301516153be6101a0860182614a6e565b508091505092915050565b60006153d5838361528d565b905092915050565b6000602082019050919050565b60006153f582615261565b6153ff818561526c565b9350836020820285016154118561527d565b8060005b8581101561544d578484038952815161542e85826153c9565b9450615439836153dd565b925060208a01995050600181019050615415565b50829750879550505050505092915050565b6000604082019050818103600083015261547981856153ea565b9050818103602083015261548d8184614e96565b90509392505050565b6000602082840312156154ac576154ab61469e565b5b60006154ba84828501614d3d565b91505092915050565b600080fd5b60008083601f8401126154de576154dd614c64565b5b8235905067ffffffffffffffff8111156154fb576154fa6154c3565b5b60208301915083602082028301111561551757615516614d21565b5b9250929050565b60008083601f84011261553457615533614c64565b5b8235905067ffffffffffffffff811115615551576155506154c3565b5b60208301915083602082028301111561556d5761556c614d21565b5b9250929050565b61557d81614950565b811461558857600080fd5b50565b60008135905061559a81615574565b92915050565b60008060008060008060008060008060e08b8d0312156155c3576155c261469e565b5b60006155d18d828e01614784565b9a505060208b013567ffffffffffffffff8111156155f2576155f16146a3565b5b6155fe8d828e016154c8565b995099505060408b013567ffffffffffffffff811115615621576156206146a3565b5b61562d8d828e016154c8565b975097505060608b013567ffffffffffffffff8111156156505761564f6146a3565b5b61565c8d828e0161551e565b9550955050608061566f8d828e01614784565b93505060a06156808d828e0161558b565b92505060c06156918d828e0161558b565b9150509295989b9194979a5092959850565b6156ac81614763565b82525050565b60006020820190506156c760008301846156a3565b92915050565b60006040820190506156e260008301856156a3565b6156ef60208301846156a3565b9392505050565b600067ffffffffffffffff82111561571157615710614c7a565b5b602082029050602081019050919050565b6000615735615730846156f6565b614cda565b9050808382526020820190506020840283018581111561575857615757614d21565b5b835b81811015615781578061576d8882614bfc565b84526020840193505060208101905061575a565b5050509392505050565b600082601f8301126157a05761579f614c64565b5b81356157b0848260208601615722565b91505092915050565b6000806000606084860312156157d2576157d161469e565b5b60006157e086828701614784565b93505060206157f186828701614784565b925050604084013567ffffffffffffffff811115615812576158116146a3565b5b61581e8682870161578b565b9150509250925092565b60808201600082015161583e6000850182614892565b5060208201516158516020850182614a2d565b5060408201516158646040850182614a2d565b5060608201516158776060850182614960565b50505050565b60006080820190506158926000830184615828565b92915050565b600080604083850312156158af576158ae61469e565b5b60006158bd85828601614784565b92505060206158ce85828601614d3d565b9150509250929050565b6158e181614a5c565b82525050565b60006040820190506158fc60008301856158d8565b61590960208301846156a3565b9392505050565b600060608201905061592560008301866158d8565b61593260208301856158d8565b61593f60408301846156a3565b949350505050565b600081519050615956816147ff565b92915050565b6000602082840312156159725761597161469e565b5b600061598084828501615947565b91505092915050565b615992816147c6565b82525050565b60006080820190506159ad6000830187614739565b6159ba6020830186614739565b6159c76040830185615989565b6159d460608301846156a3565b95945050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000615a4682614763565b9150615a5183614763565b9250828203905081811115615a6957615a68615a0c565b5b92915050565b6000615a7a82614763565b9150615a8583614763565b9250828201905080821115615a9d57615a9c615a0c565b5b92915050565b6000615aae82614950565b9150615ab983614950565b9250828201905063ffffffff811115615ad557615ad4615a0c565b5b92915050565b6000602082019050615af060008301846158d8565b92915050565b600081519050615b058161476d565b92915050565b600060208284031215615b2157615b2061469e565b5b6000615b2f84828501615af6565b91505092915050565b6000615b4382614950565b915060008203615b5657615b55615a0c565b5b600182039050919050565b6000615b6c82614763565b9150615b7783614763565b9250828202615b8581614763565b91508282048414831517615b9c57615b9b615a0c565b5b5092915050565b6000615bae82614763565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203615be057615bdf615a0c565b5b600182019050919050565b6000615bf682614950565b9150615c0183614950565b9250828203905063ffffffff811115615c1d57615c1c615a0c565b5b92915050565b60008160601b9050919050565b6000615c3b82615c23565b9050919050565b6000615c4d82615c30565b9050919050565b615c65615c6082614a5c565b615c42565b82525050565b6000819050919050565b615c86615c8182614763565b615c6b565b82525050565b6000615c988285615c54565b601482019150615ca88284615c75565b6020820191508190509392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6000604082019050615cfc60008301856158d8565b615d096020830184614f43565b939250505056fea2646970667358221220ebd274a72f438190ccd29e5f596902f69f5c50724152ba7cbd23d85dcef8684064736f6c63430008140033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000005b590e05450220b4a39b54b1ac86ec6a4690997b000000000000000000000000000000000000000000295be96e64066972000000000000000000000000000000a41b28e4e2a5806e849414c28b1bf92134f262bc
-----Decoded View---------------
Arg [0] : bBitToken (address): 0x5B590e05450220B4A39B54B1AC86eC6A4690997b
Arg [1] : maxPotValue (uint256): 50000000000000000000000000
Arg [2] : airdropAddress (address): 0xa41b28e4e2a5806E849414c28b1BF92134f262BC
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 0000000000000000000000005b590e05450220b4a39b54b1ac86ec6a4690997b
Arg [1] : 000000000000000000000000000000000000000000295be96e64066972000000
Arg [2] : 000000000000000000000000a41b28e4e2a5806e849414c28b1bf92134f262bc
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in S
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.