Address Details
contract
0x098148534aC15A44CFF52387bA81Ed929589eCAf
- Contract Name
- GoodDollarMintBurnWrapper
- Creator
- 0x5128e3–22e4bb at 0x7494a0–4f9598
- Balance
- 0 CELO ( )
- Locked CELO Balance
- 0.00 CELO
- Voting CELO Balance
- 0.00 CELO
- Pending Unlocked Gold
- 0.00 CELO
- Tokens
-
Fetching tokens...
- Transactions
- 0 Transactions
- Transfers
- 0 Transfers
- Gas Used
- Fetching gas used...
- Last Balance Update
- 19726773
This contract has been partially verified via Sourcify.
View contract in Sourcify repository
- Contract name:
- GoodDollarMintBurnWrapper
- Optimization enabled
- true
- Compiler version
- v0.8.16+commit.07a7930e
- Optimization runs
- 0
- EVM Version
- london
- Verified at
- 2023-01-16T11:38:07.213335Z
project:/contracts/utils/GoodDollarMintBurnWrapper.sol
// SPDX-License-Identifier: MIT /** Wrap the G$ token to provide mint permissions to multichain.org router/bridge based on https://github.com/anyswap/multichain-smart-contracts/blob/1459fe6281867319af8ffb1849e5c16d242d6530/contracts/wrapper/MintBurnWrapper.sol Added onTokenTransfer Notice: contract needs to be registered as a scheme on Controller to be able to call mintTokens Fixed: https://github.com/anyswap/multichain-smart-contracts/issues/4 https://github.com/anyswap/multichain-smart-contracts/issues/3 */ pragma solidity ^0.8; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts/utils/math/Math.sol"; // import "hardhat/console.sol"; import "./DAOUpgradeableContract.sol"; library TokenOperation { using AddressUpgradeable for address; function safeBurnSelf(address token, uint256 value) internal { // burn(uint256) _callOptionalReturn(token, abi.encodeWithSelector(0x42966c68, value)); } function safeBurnFrom( address token, address from, uint256 value ) internal { // burnFrom(address,uint256) _callOptionalReturn(token, abi.encodeWithSelector(0x79cc6790, from, value)); } function _callOptionalReturn(address token, bytes memory data) private { bytes memory returndata = token.functionCall( data, "TokenOperation: low-level call failed" ); if (returndata.length > 0) { // Return data is optional require( abi.decode(returndata, (bool)), "TokenOperation: did not succeed" ); } } } interface IRouter { function mint(address to, uint256 amount) external returns (bool); function burn(address from, uint256 amount) external returns (bool); } //License-Identifier: GPL-3.0-or-later abstract contract PausableControl { mapping(bytes32 => bool) private _pausedRoles; bytes32 public constant PAUSE_ALL_ROLE = 0x00; event Paused(bytes32 role); event Unpaused(bytes32 role); modifier whenNotPaused(bytes32 role) { require( !paused(role) && !paused(PAUSE_ALL_ROLE), "PausableControl: paused" ); _; } modifier whenPaused(bytes32 role) { require( paused(role) || paused(PAUSE_ALL_ROLE), "PausableControl: not paused" ); _; } function paused(bytes32 role) public view virtual returns (bool) { return _pausedRoles[role]; } function _pause(bytes32 role) internal virtual whenNotPaused(role) { _pausedRoles[role] = true; emit Paused(role); } function _unpause(bytes32 role) internal virtual whenPaused(role) { _pausedRoles[role] = false; emit Unpaused(role); } } /// @dev MintBurnWrapper has the following aims: /// 1. wrap token which does not support interface `IRouter` /// 2. wrap token which wants to support multiple minters /// 3. add security enhancement (mint cap, pausable, etc.) contract GoodDollarMintBurnWrapper is IRouter, AccessControlEnumerableUpgradeable, PausableControl, DAOUpgradeableContract { using SafeERC20Upgradeable for IERC20Upgradeable; // access control roles bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant BRIDGE_ROLE = keccak256("BRIDGE_ROLE"); bytes32 public constant ROUTER_ROLE = keccak256("ROUTER_ROLE"); bytes32 public constant REWARDS_ROLE = keccak256("REWARDS_ROLE"); bytes32 public constant GUARDIAN_ROLE = keccak256("GUARDIAN_ROLE"); // pausable control roles bytes32 public constant PAUSE_MINT_ROLE = keccak256("PAUSE_MINT_ROLE"); bytes32 public constant PAUSE_BURN_ROLE = keccak256("PAUSE_BURN_ROLE"); bytes32 public constant PAUSE_ROUTER_ROLE = keccak256("PAUSE_ROUTER_ROLE"); bytes32 public constant PAUSE_REWARDS_ROLE = keccak256("PAUSE_REWARDS_ROLE"); struct InLimits { uint256 maxIn; // single limit of each mint uint256 capIn; // total limit of all mint uint256 totalIn; // total minted minus burned uint128 dailyCapIn; //cap per day (rewards sendOrMint only) uint128 mintedToday; //total minted today uint128 lastUpdate; //last update of dailyCap uint128 totalRewards; // total rewards sent (sent + minted) (rewards sendOrMint only) uint32 bpsPerDayIn; //basis points relative to token supply daily limit (rewards sendOrMint only) uint128 lastDayReset; //last day we reset the daily limits } struct OutLimits { uint256 maxOut; // single limit of each burn uint256 capOut; // total limit of all burn uint256 totalOut; // total burned minus minted uint128 dailyCapOut; //burn cap per day uint128 burnedToday; //total burned today uint32 bpsPerDayOut; //basis points relative to token supply daily limit } mapping(address => InLimits) public minterSupply; uint256 public totalMintCap_unused; // total mint cap, not used, kept because of upgradable storage uint256 public totalMinted; // total minted amount address public token; // the target token this contract is wrapping uint256 private unused_tokenType; //kept because of upgradable storage layout, contract already deployed to Celo contains it uint128 public currentDay; //used to reset daily minter limit uint128 public updateFrequency; //how often to update the relative to supply daily limit uint128 public totalMintDebt; // total outstanding rewards mint debt uint128 public totalRewards; // total rewards sent (sent + minted) mapping(address => OutLimits) public minterOutLimits; event Minted(address minter, address to, uint256 amount); event Burned(address minter, address to, uint256 amount); event SendOrMint( address rewarder, address to, uint256 amount, uint256 sent, uint256 minted, uint256 outstandingMintDebt ); event MinterSet( address minter, uint256 totalMintCapIn, uint256 perTxCapIn, uint32 bpsIn, uint256 totalMintCapOut, uint256 perTxCapOut, uint32 bpsOut, bool rewardsRole, bool isUpdate ); event UpdateFrequencySet(uint128 newFrequency); modifier onlyRoles(bytes32[2] memory roles) { require( hasRole(roles[0], _msgSender()) || hasRole(roles[1], _msgSender()), "role missing" ); _; } function initialize(address _admin, INameService _nameService) external initializer { __AccessControlEnumerable_init(); setDAO(_nameService); require(_admin != address(0), "zero admin address"); token = address(nativeToken()); updateFrequency = 90 days; _setupRole(DEFAULT_ADMIN_ROLE, avatar); _setupRole(DEFAULT_ADMIN_ROLE, _admin); } function decimals() external view returns (uint8) { return ERC20(token).decimals(); } function name() external view returns (string memory) { return ERC20(token).name(); } function symbol() external view returns (string memory) { return ERC20(token).symbol(); } function balanceOf(address account) external view returns (uint256 balance) { return ERC20(token).balanceOf(account); } function owner() external view returns (address) { return getRoleMember(DEFAULT_ADMIN_ROLE, 0); } /** @notice set how frequent to udpate rewarder daily limit based on bps out of total supply @param inSeconds frequency in seconds */ function setUpdateFrequency(uint128 inSeconds) external onlyRoles([GUARDIAN_ROLE, DEFAULT_ADMIN_ROLE]) { updateFrequency = inSeconds; emit UpdateFrequencySet(inSeconds); } /** * @notice pause one of the functions of the wrapper (see pause roles), only dev/guardian roles can call this * @param role which function to pause */ function pause(bytes32 role) external onlyRoles([GUARDIAN_ROLE, DEFAULT_ADMIN_ROLE]) { _pause(role); } /** * @notice unpause one of the functions of the wrapper (see pause roles), only dev/guardian roles can call this * @param role which function to unpause */ function unpause(bytes32 role) external onlyRoles([GUARDIAN_ROLE, DEFAULT_ADMIN_ROLE]) { _unpause(role); } /** * @notice implement the IRouter mint required for work with multichain router. This method is used by the multichain bridge to mint new tokens on sidechain * on bridge transfer from another chain. Can only be called by the ROUTER role * @param to recipient * @param amount amount to mint */ function mint(address to, uint256 amount) external onlyRole(MINTER_ROLE) returns (bool) { _updateDailyLimitCap(msg.sender); _mint(to, amount); emit Minted(msg.sender, to, amount); return true; } /** * @notice implement the IRouter burn required for work with multichain router. This method is used by the multichain bridge to burn tokens on sidechain * on bridge transfer to other chain. Can only be called by the ROUTER role * @param from sender - requires sender to first approve tokens to the wrapper or use transferAndCall * @param amount amount to mint */ function burn(address from, uint256 amount) external onlyRole(MINTER_ROLE) whenNotPaused(PAUSE_ROUTER_ROLE) returns (bool) { _updateDailyLimitCap(msg.sender); _burn(from, amount); emit Burned(msg.sender, from, amount); return true; } /** * @notice helper function to transfer from sidechain to another chain without the need to first approve tokens for burn. * sender call transferAndCall(wrapperAddress,abi.encode(recipient,target chain id)) * @param sender sender * @param amount sent by sender * @param data expected to be recipient + target chain abi encoded */ function onTokenTransfer( address sender, uint256 amount, bytes memory data ) external returns (bool) { require(msg.sender == token); //verify this was called from a token transfer (address bindaddr, uint256 chainId) = abi.decode(data, (address, uint256)); require(chainId != 0, "zero chainId"); bindaddr = bindaddr != address(0) ? bindaddr : sender; IMultichainRouter(nameService.getAddress("MULTICHAIN_ROUTER")).anySwapOut( address(this), bindaddr, amount, chainId ); return true; } /** * @notice allow REWARDS_ROLE to send existing funds in balance or mint new G$ on sidechain to recipient. * @param to recipient * @param amount amount to send or mint. if not enough balance the rest will be minted up to the rewarder dailyLimit */ function sendOrMint(address to, uint256 amount) external onlyRole(REWARDS_ROLE) whenNotPaused(PAUSE_REWARDS_ROLE) returns (uint256 totalSent) { _updateDailyLimitCap(msg.sender); uint256 maxMintToday = minterSupply[msg.sender].dailyCapIn == 0 ? amount : minterSupply[msg.sender].dailyCapIn - minterSupply[msg.sender].mintedToday; //calcualte how much to send and mint uint256 toSend = Math.min( IERC20Upgradeable(token).balanceOf(address(this)), amount ); uint256 toMint = Math.min(amount - toSend, maxMintToday); // console.log("sendOrMint %s %s %s", toMint, toSend, maxMintToday); totalSent = toSend + toMint; minterSupply[msg.sender].totalRewards += uint128(totalSent); totalRewards += uint128(totalSent); totalMintDebt += uint128(toMint); if (toMint > 0) _mint(to, toMint); if (toSend > 0) { IERC20Upgradeable(token).safeTransfer(to, toSend); } if (toMint == 0) { //if we are not minting then we might have positive balance, check if we can cover out debt and burn some //from balance in exchange for what we minted in the past ie mintDebt _balanceDebt(); } emit SendOrMint(_msgSender(), to, amount, toSend, toMint, totalMintDebt); } /** * @notice add minter or rewards role * @param minter address of minter * @param globalLimitIn minter global limit * @param perTxLimitIn minter per tx limit * @param bpsPerDayIn limit for rewards role in bps relative to G$ total supply * @param globalLimitOut minter global limit * @param perTxLimitOut minter per tx limit * @param bpsPerDayOut limit for rewards role in bps relative to G$ total supply * @param withRewardsRole should also grant REWARDS_ROLE to minter */ function addMinter( address minter, uint256 globalLimitIn, uint256 perTxLimitIn, uint32 bpsPerDayIn, uint256 globalLimitOut, uint256 perTxLimitOut, uint32 bpsPerDayOut, bool withRewardsRole ) external onlyRole(DEFAULT_ADMIN_ROLE) { if (withRewardsRole) { grantRole(REWARDS_ROLE, minter); revokeRole(MINTER_ROLE, minter); } else { grantRole(MINTER_ROLE, minter); revokeRole(REWARDS_ROLE, minter); } _setMinterCaps( minter, globalLimitIn, perTxLimitIn, bpsPerDayIn, globalLimitOut, perTxLimitOut, bpsPerDayOut ); } /** * @notice update minter or rewards role limits * @param minter address of minter * @param globalLimitIn minter global limit * @param perTxLimitIn minter per tx limit * @param bpsPerDayIn limit for rewards role in bps relative to G$ total supply * @param globalLimitOut minter global limit * @param perTxLimitOut minter per tx limit * @param bpsPerDayOut limit for rewards role in bps relative to G$ total supply */ function setMinterCaps( address minter, uint256 globalLimitIn, uint256 perTxLimitIn, uint32 bpsPerDayIn, uint256 globalLimitOut, uint256 perTxLimitOut, uint32 bpsPerDayOut ) external onlyRoles([GUARDIAN_ROLE, DEFAULT_ADMIN_ROLE]) { _setMinterCaps( minter, globalLimitIn, perTxLimitIn, bpsPerDayIn, globalLimitOut, perTxLimitOut, bpsPerDayOut ); } /** * @notice update minter or rewards role limits * @param minter address of minter * @param globalLimitIn minter global limit * @param perTxLimitIn minter per tx limit * @param bpsPerDayIn limit for rewards role in bps relative to G$ total supply * @param globalLimitOut minter global limit * @param perTxLimitOut minter per tx limit * @param bpsPerDayOut limit for rewards role in bps relative to G$ total supply */ function _setMinterCaps( address minter, uint256 globalLimitIn, uint256 perTxLimitIn, uint32 bpsPerDayIn, uint256 globalLimitOut, uint256 perTxLimitOut, uint32 bpsPerDayOut ) internal { InLimits storage m = minterSupply[minter]; OutLimits storage o = minterOutLimits[minter]; bool isUpdate = m.lastUpdate > 0; bool withRewardsRole = hasRole(REWARDS_ROLE, minter); m.capIn = globalLimitIn; m.maxIn = perTxLimitIn; m.bpsPerDayIn = bpsPerDayIn; m.lastUpdate = uint128(block.timestamp); m.dailyCapIn = uint128(IERC20Upgradeable(token).totalSupply() * bpsPerDayIn) / 10000; o.dailyCapOut = uint128(IERC20Upgradeable(token).totalSupply() * bpsPerDayOut) / 10000; o.capOut = globalLimitOut; o.maxOut = perTxLimitOut; o.bpsPerDayOut = bpsPerDayOut; emit MinterSet( minter, globalLimitIn, perTxLimitIn, bpsPerDayIn, globalLimitOut, perTxLimitOut, bpsPerDayOut, withRewardsRole, isUpdate ); } /** * @notice helper to update the current day, used to reset rewards role daily limit */ function _updateCurrentDay() internal { currentDay = uint128(block.timestamp / 1 days); } /** * @notice helper for mint/sendOrMint action */ function _mint(address to, uint256 amount) internal whenNotPaused(PAUSE_MINT_ROLE) { require(to != address(this), "mint to self"); require( minterSupply[msg.sender].maxIn == 0 || amount <= minterSupply[msg.sender].maxIn, "minter max exceeded" ); require( minterSupply[msg.sender].dailyCapIn == 0 || minterSupply[msg.sender].dailyCapIn >= (minterSupply[msg.sender].mintedToday + amount), "minter daily cap exceeded" ); minterSupply[msg.sender].mintedToday += uint128(amount); minterSupply[msg.sender].totalIn += amount; require( minterSupply[msg.sender].capIn == 0 || minterSupply[msg.sender].totalIn <= minterSupply[msg.sender].capIn, "minter cap exceeded" ); totalMinted += amount; if (minterOutLimits[msg.sender].totalOut >= amount) { minterOutLimits[msg.sender].totalOut -= amount; } else { minterOutLimits[msg.sender].totalOut = 0; } bool ok = dao.mintTokens(amount, to, avatar); require(ok, "mint failed"); } /** * @notice helper for burn action */ function _burn(address from, uint256 amount) internal whenNotPaused(PAUSE_BURN_ROLE) { require( minterOutLimits[msg.sender].maxOut == 0 || amount <= minterOutLimits[msg.sender].maxOut, "minter burn max exceeded" ); require( minterOutLimits[msg.sender].dailyCapOut == 0 || minterOutLimits[msg.sender].dailyCapOut >= (minterOutLimits[msg.sender].burnedToday + amount), "minter burn daily cap exceeded" ); minterOutLimits[msg.sender].burnedToday += uint128(amount); minterOutLimits[msg.sender].totalOut += amount; require( minterOutLimits[msg.sender].capOut == 0 || minterOutLimits[msg.sender].totalOut <= minterOutLimits[msg.sender].capOut, "minter cap exceeded" ); //update stats correctly, but dont fail if it tries to transfer tokens minted elsewhere as long as we burn some if (totalMinted >= amount) { totalMinted -= amount; } else { totalMinted = 0; } if (minterSupply[msg.sender].totalIn >= amount) { minterSupply[msg.sender].totalIn -= amount; } else { minterSupply[msg.sender].totalIn = 0; } //handle onTokenTransfer (ERC677), assume tokens has been transfered if (from == address(this)) { TokenOperation.safeBurnSelf(token, amount); } else { TokenOperation.safeBurnFrom(token, from, amount); } } /** * @notice helper for sendOrMint action to burn from balance to cover minting debt */ function _balanceDebt() internal { uint256 toBurn = Math.min( totalMintDebt, IERC20Upgradeable(token).balanceOf(address(this)) ); if (toBurn > 0) { totalMintDebt -= uint128(toBurn); totalMinted -= toBurn; ERC20(token).burn(toBurn); //from DAOUpgradableContract -> Interfaces } } /** * @notice helper for sendOrMint action to update the rewarder daily limit if updateFrequency passed */ function _updateDailyLimitCap(address minter) internal { uint256 secondsPassed = block.timestamp - minterSupply[minter].lastUpdate; uint256 totalSupply = IERC20Upgradeable(token).totalSupply(); if (secondsPassed >= updateFrequency) { minterSupply[minter].dailyCapIn = uint128( (totalSupply * minterSupply[minter].bpsPerDayIn) / 10000 ); minterOutLimits[minter].dailyCapOut = uint128( (totalSupply * minterOutLimits[minter].bpsPerDayOut) / 10000 ); minterSupply[minter].lastUpdate = uint128(block.timestamp); // console.log( // "secondsPassed %s %s %s", // secondsPassed, // minter.dailyCap, // minter.lastUpdate // ); } //check if daily limit needs reset _updateCurrentDay(); if (currentDay != minterSupply[minter].lastDayReset) { minterSupply[minter].mintedToday = 0; minterOutLimits[minter].burnedToday = 0; minterSupply[minter].lastDayReset = currentDay; } } function upgradeSuperGoodDollar() external onlyRole(DEFAULT_ADMIN_ROLE) { address _newns = 0x0F5dB7a64A6a64052693676CA898EC7F7A94FF4e; _revokeRole(DEFAULT_ADMIN_ROLE, avatar); //old avatar setDAO(INameService(_newns)); //changes avatar + nativeToken token = address(nativeToken()); _setupRole(DEFAULT_ADMIN_ROLE, avatar); //new avatar updateFrequency = 3 days; _setMinterCaps( 0xf27Ee99622C3C9b264583dACB2cCE056e194494f, 0, 0, 0, 0, 300 * 1e6 * 1e18, //300M 5000 //50% ); } }
/_openzeppelin/contracts/utils/math/Math.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return 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 up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev 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^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 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. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); 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^256 / 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^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. 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^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // 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^256. Since the preconditions guarantee that the outcome is // less than 2^256, 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; } } /** * @notice 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) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice 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 + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 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 + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * 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 + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * 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; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { 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 log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0); } } }
/_openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol) pragma solidity ^0.8.0; import "./IAccessControlEnumerableUpgradeable.sol"; import "./AccessControlUpgradeable.sol"; import "../utils/structs/EnumerableSetUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */ abstract contract AccessControlEnumerableUpgradeable is Initializable, IAccessControlEnumerableUpgradeable, AccessControlUpgradeable { function __AccessControlEnumerable_init() internal onlyInitializing { } function __AccessControlEnumerable_init_unchained() internal onlyInitializing { } using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; mapping(bytes32 => EnumerableSetUpgradeable.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerableUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) { return _roleMembers[role].at(index); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) { return _roleMembers[role].length(); } /** * @dev Overload {_grantRole} to track enumerable memberships */ function _grantRole(bytes32 role, address account) internal virtual override { super._grantRole(role, account); _roleMembers[role].add(account); } /** * @dev Overload {_revokeRole} to track enumerable memberships */ function _revokeRole(bytes32 role, address account) internal virtual override { super._revokeRole(role, account); _roleMembers[role].remove(account); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
/_openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; import "../utils/ContextUpgradeable.sol"; import "../utils/StringsUpgradeable.sol"; import "../utils/introspection/ERC165Upgradeable.sol"; import "../proxy/utils/Initializable.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: * * ``` * 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}: * * ``` * 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. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable { function __AccessControl_init() internal onlyInitializing { } function __AccessControl_init_unchained() internal onlyInitializing { } struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", StringsUpgradeable.toHexString(account), " is missing role ", StringsUpgradeable.toHexString(uint256(role), 32) ) ) ); } } /** * @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 override 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 override 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 override 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 `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @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 Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
/_openzeppelin/contracts-upgradeable/access/IAccessControlEnumerableUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol) pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; /** * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. */ interface IAccessControlEnumerableUpgradeable is IAccessControlUpgradeable { /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) external view returns (address); /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) external view returns (uint256); }
/_openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @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. * * _Available since v3.1._ */ 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, an admin role * bearer except when using {AccessControl-_setupRole}. */ 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 `account`. */ function renounceRole(bytes32 role, address account) external; }
/_openzeppelin/contracts-upgradeable/interfaces/draft-IERC1822Upgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.0; /** * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified * proxy whose upgrades are fully controlled by the current implementation. */ interface IERC1822ProxiableUpgradeable { /** * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation * address. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. */ function proxiableUUID() external view returns (bytes32); }
/_openzeppelin/contracts-upgradeable/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol) pragma solidity ^0.8.2; import "../beacon/IBeaconUpgradeable.sol"; import "../../interfaces/draft-IERC1822Upgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/StorageSlotUpgradeable.sol"; import "../utils/Initializable.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. * * _Available since v4.1._ * * @custom:oz-upgrades-unsafe-allow delegatecall */ abstract contract ERC1967UpgradeUpgradeable is Initializable { function __ERC1967Upgrade_init() internal onlyInitializing { } function __ERC1967Upgrade_init_unchained() internal onlyInitializing { } // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1 bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143; /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Returns the current implementation address. */ function _getImplementation() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Perform implementation upgrade * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Perform implementation upgrade with additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCall( address newImplementation, bytes memory data, bool forceCall ) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { _functionDelegateCall(newImplementation, data); } } /** * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCallUUPS( address newImplementation, bytes memory data, bool forceCall ) internal { // Upgrades from old implementations will perform a rollback test. This test requires the new // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing // this special case will break upgrade paths from old UUPS implementation to new ones. if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) { _setImplementation(newImplementation); } else { try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) { require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID"); } catch { revert("ERC1967Upgrade: new implementation is not UUPS"); } _upgradeToAndCall(newImplementation, data, forceCall); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Returns the current admin. */ function _getAdmin() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. */ function _changeAdmin(address newAdmin) internal { emit AdminChanged(_getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor. */ bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Emitted when the beacon is upgraded. */ event BeaconUpgraded(address indexed beacon); /** * @dev Returns the current beacon. */ function _getBeacon() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon; } /** * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that). * * Emits a {BeaconUpgraded} event. */ function _upgradeBeaconToAndCall( address newBeacon, bytes memory data, bool forceCall ) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data); } } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) { require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed"); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
/_openzeppelin/contracts-upgradeable/proxy/beacon/IBeaconUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeaconUpgradeable { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); }
/_openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ``` * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized < type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Internal function that returns the initialized version. Returns `_initialized` */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Internal function that returns the initialized version. Returns `_initializing` */ function _isInitializing() internal view returns (bool) { return _initializing; } }
/_openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.0; import "../../interfaces/draft-IERC1822Upgradeable.sol"; import "../ERC1967/ERC1967UpgradeUpgradeable.sol"; import "./Initializable.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. * * _Available since v4.1._ */ abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable { function __UUPSUpgradeable_init() internal onlyInitializing { } function __UUPSUpgradeable_init_unchained() internal onlyInitializing { } /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment address private immutable __self = address(this); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { require(address(this) != __self, "Function must be called through delegatecall"); require(_getImplementation() == __self, "Function must be called through active proxy"); _; } /** * @dev Check that the execution is not being performed through a delegate call. This allows a function to be * callable on the implementing contract but not through proxies. */ modifier notDelegated() { require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall"); _; } /** * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the * implementation. It is used to validate the implementation's compatibility when performing an upgrade. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier. */ function proxiableUUID() external view virtual override notDelegated returns (bytes32) { return _IMPLEMENTATION_SLOT; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeTo(address newImplementation) external virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, new bytes(0), false); } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, data, true); } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeTo} and {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal override onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
/_openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @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 amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
/_openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20PermitUpgradeable { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
/_openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; import "../extensions/draft-IERC20PermitUpgradeable.sol"; import "../../../utils/AddressUpgradeable.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20Upgradeable { using AddressUpgradeable for address; function safeTransfer( IERC20Upgradeable token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20Upgradeable token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20Upgradeable token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } function safePermit( IERC20PermitUpgradeable token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
/_openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
/_openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @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 ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
/_openzeppelin/contracts-upgradeable/utils/StorageSlotUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlotUpgradeable { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } }
/_openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/MathUpgradeable.sol"; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = MathUpgradeable.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, MathUpgradeable.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
/_openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 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); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
/_openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @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[EIP 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); }
/_openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library MathUpgradeable { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return 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 up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev 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^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 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. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); 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^256 / 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^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. 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^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // 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^256. Since the preconditions guarantee that the outcome is // less than 2^256, 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; } } /** * @notice 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) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice 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 + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 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 + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * 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 + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * 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; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { 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 log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0); } } }
/_openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js. pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableSet. * ==== */ library EnumerableSetUpgradeable { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastValue; // Update the index for the moved value set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values in the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
/project_/contracts/DAOStackInterfaces.sol
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; interface Avatar { function nativeToken() external view returns (address); function nativeReputation() external view returns (address); function owner() external view returns (address); } interface Controller { event RegisterScheme(address indexed _sender, address indexed _scheme); event UnregisterScheme(address indexed _sender, address indexed _scheme); function genericCall( address _contract, bytes calldata _data, address _avatar, uint256 _value ) external returns (bool, bytes memory); function avatar() external view returns (address); function unregisterScheme(address _scheme, address _avatar) external returns (bool); function unregisterSelf(address _avatar) external returns (bool); function registerScheme( address _scheme, bytes32 _paramsHash, bytes4 _permissions, address _avatar ) external returns (bool); function isSchemeRegistered(address _scheme, address _avatar) external view returns (bool); function getSchemePermissions(address _scheme, address _avatar) external view returns (bytes4); function addGlobalConstraint( address _constraint, bytes32 _paramHash, address _avatar ) external returns (bool); function mintTokens( uint256 _amount, address _beneficiary, address _avatar ) external returns (bool); function externalTokenTransfer( address _token, address _recipient, uint256 _amount, address _avatar ) external returns (bool); function sendEther( uint256 _amountInWei, address payable _to, address _avatar ) external returns (bool); } interface GlobalConstraintInterface { enum CallPhase { Pre, Post, PreAndPost } function pre( address _scheme, bytes32 _params, bytes32 _method ) external returns (bool); /** * @dev when return if this globalConstraints is pre, post or both. * @return CallPhase enum indication Pre, Post or PreAndPost. */ function when() external returns (CallPhase); } interface ReputationInterface { function balanceOf(address _user) external view returns (uint256); function balanceOfAt(address _user, uint256 _blockNumber) external view returns (uint256); function getVotes(address _user) external view returns (uint256); function getVotesAt( address _user, bool _global, uint256 _blockNumber ) external view returns (uint256); function totalSupply() external view returns (uint256); function totalSupplyAt(uint256 _blockNumber) external view returns (uint256); function delegateOf(address _user) external returns (address); } interface SchemeRegistrar { function proposeScheme( Avatar _avatar, address _scheme, bytes32 _parametersHash, bytes4 _permissions, string memory _descriptionHash ) external returns (bytes32); event NewSchemeProposal( address indexed _avatar, bytes32 indexed _proposalId, address indexed _intVoteInterface, address _scheme, bytes32 _parametersHash, bytes4 _permissions, string _descriptionHash ); } interface IntVoteInterface { event NewProposal( bytes32 indexed _proposalId, address indexed _organization, uint256 _numOfChoices, address _proposer, bytes32 _paramsHash ); event ExecuteProposal( bytes32 indexed _proposalId, address indexed _organization, uint256 _decision, uint256 _totalReputation ); event VoteProposal( bytes32 indexed _proposalId, address indexed _organization, address indexed _voter, uint256 _vote, uint256 _reputation ); event CancelProposal( bytes32 indexed _proposalId, address indexed _organization ); event CancelVoting( bytes32 indexed _proposalId, address indexed _organization, address indexed _voter ); /** * @dev register a new proposal with the given parameters. Every proposal has a unique ID which is being * generated by calculating keccak256 of a incremented counter. * @param _numOfChoices number of voting choices * @param _proposalParameters defines the parameters of the voting machine used for this proposal * @param _proposer address * @param _organization address - if this address is zero the msg.sender will be used as the organization address. * @return proposal's id. */ function propose( uint256 _numOfChoices, bytes32 _proposalParameters, address _proposer, address _organization ) external returns (bytes32); function vote( bytes32 _proposalId, uint256 _vote, uint256 _rep, address _voter ) external returns (bool); function cancelVote(bytes32 _proposalId) external; function getNumberOfChoices(bytes32 _proposalId) external view returns (uint256); function isVotable(bytes32 _proposalId) external view returns (bool); /** * @dev voteStatus returns the reputation voted for a proposal for a specific voting choice. * @param _proposalId the ID of the proposal * @param _choice the index in the * @return voted reputation for the given choice */ function voteStatus(bytes32 _proposalId, uint256 _choice) external view returns (uint256); /** * @dev isAbstainAllow returns if the voting machine allow abstain (0) * @return bool true or false */ function isAbstainAllow() external pure returns (bool); /** * @dev getAllowedRangeOfChoices returns the allowed range of choices for a voting machine. * @return min - minimum number of choices max - maximum number of choices */ function getAllowedRangeOfChoices() external pure returns (uint256 min, uint256 max); }
/project_/contracts/Interfaces.sol
// SPDX-License-Identifier: MIT import { DataTypes } from "./utils/DataTypes.sol"; pragma solidity >=0.8.0; pragma experimental ABIEncoderV2; interface ERC20 { function balanceOf(address addr) external view returns (uint256); function transfer(address to, uint256 amount) external returns (bool); function approve(address spender, uint256 amount) external returns (bool); function decimals() external view returns (uint8); function mint(address to, uint256 mintAmount) external returns (uint256); function burn(uint256 amount) external; function totalSupply() external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); function name() external view returns (string memory); function symbol() external view returns (string memory); event Transfer(address indexed from, address indexed to, uint256 amount); event Transfer( address indexed from, address indexed to, uint256 amount, bytes data ); } interface cERC20 is ERC20 { function mint(uint256 mintAmount) external returns (uint256); function redeemUnderlying(uint256 mintAmount) external returns (uint256); function redeem(uint256 mintAmount) external returns (uint256); function exchangeRateCurrent() external returns (uint256); function exchangeRateStored() external view returns (uint256); function underlying() external returns (address); } interface IGoodDollar is ERC20 { // view functions function feeRecipient() external view returns (address); function getFees( uint256 value, address sender, address recipient ) external view returns (uint256 fee, bool senderPays); function cap() external view returns (uint256); function isPauser(address _pauser) external view returns (bool); function getFees(uint256 value) external view returns (uint256, bool); function isMinter(address minter) external view returns (bool); function formula() external view returns (address); function identity() external view returns (address); function owner() external view returns (address); // state changing functions function setFeeRecipient(address _feeRecipient) external; function setFormula(address _formula) external; function transferOwnership(address _owner) external; function addPauser(address _pauser) external; function pause() external; function unpause() external; function burn(uint256 amount) external; function burnFrom(address account, uint256 amount) external; function renounceMinter() external; function addMinter(address minter) external; function transferAndCall( address to, uint256 value, bytes calldata data ) external returns (bool); function setIdentity(address identity) external; } interface IERC2917 is ERC20 { /// @dev This emit when interests amount per block is changed by the owner of the contract. /// It emits with the old interests amount and the new interests amount. event InterestRatePerBlockChanged(uint256 oldValue, uint256 newValue); /// @dev This emit when a users' productivity has changed /// It emits with the user's address and the the value after the change. event ProductivityIncreased(address indexed user, uint256 value); /// @dev This emit when a users' productivity has changed /// It emits with the user's address and the the value after the change. event ProductivityDecreased(address indexed user, uint256 value); /// @dev Return the current contract's interests rate per block. /// @return The amount of interests currently producing per each block. function interestsPerBlock() external view returns (uint256); /// @notice Change the current contract's interests rate. /// @dev Note the best practice will be restrict the gross product provider's contract address to call this. /// @return The true/fase to notice that the value has successfully changed or not, when it succeed, it will emite the InterestRatePerBlockChanged event. function changeInterestRatePerBlock(uint256 value) external returns (bool); /// @notice It will get the productivity of given user. /// @dev it will return 0 if user has no productivity proved in the contract. /// @return user's productivity and overall productivity. function getProductivity(address user) external view returns (uint256, uint256); /// @notice increase a user's productivity. /// @dev Note the best practice will be restrict the callee to prove of productivity's contract address. /// @return true to confirm that the productivity added success. function increaseProductivity(address user, uint256 value) external returns (bool); /// @notice decrease a user's productivity. /// @dev Note the best practice will be restrict the callee to prove of productivity's contract address. /// @return true to confirm that the productivity removed success. function decreaseProductivity(address user, uint256 value) external returns (bool); /// @notice take() will return the interests that callee will get at current block height. /// @dev it will always calculated by block.number, so it will change when block height changes. /// @return amount of the interests that user are able to mint() at current block height. function take() external view returns (uint256); /// @notice similar to take(), but with the block height joined to calculate return. /// @dev for instance, it returns (_amount, _block), which means at block height _block, the callee has accumulated _amount of interests. /// @return amount of interests and the block height. function takeWithBlock() external view returns (uint256, uint256); /// @notice mint the avaiable interests to callee. /// @dev once it mint, the amount of interests will transfer to callee's address. /// @return the amount of interests minted. function mint() external returns (uint256); } interface Staking { struct Staker { // The staked DAI amount uint256 stakedDAI; // The latest block number which the // staker has staked tokens uint256 lastStake; } function stakeDAI(uint256 amount) external; function withdrawStake() external; function stakers(address staker) external view returns (Staker memory); } interface Uniswap { function swapExactETHForTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable returns (uint256[] memory amounts); function swapExactTokensForETH( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapExactTokensForTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function WETH() external pure returns (address); function factory() external pure returns (address); function quote( uint256 amountA, uint256 reserveA, uint256 reserveB ) external pure returns (uint256 amountB); function getAmountIn( uint256 amountOut, uint256 reserveIn, uint256 reserveOut ) external pure returns (uint256 amountIn); function getAmountOut( uint256 amountI, uint256 reserveIn, uint256 reserveOut ) external pure returns (uint256 amountOut); function getAmountsOut(uint256 amountIn, address[] memory path) external pure returns (uint256[] memory amounts); } interface UniswapFactory { function getPair(address tokenA, address tokenB) external view returns (address); } interface UniswapPair { function getReserves() external view returns ( uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast ); function kLast() external view returns (uint256); function token0() external view returns (address); function token1() external view returns (address); function totalSupply() external view returns (uint256); function balanceOf(address owner) external view returns (uint256); } interface Reserve { function buy( address _buyWith, uint256 _tokenAmount, uint256 _minReturn ) external returns (uint256); } interface IIdentity { function isWhitelisted(address user) external view returns (bool); function addWhitelistedWithDID(address account, string memory did) external; function removeWhitelisted(address account) external; function addBlacklisted(address account) external; function removeBlacklisted(address account) external; function isBlacklisted(address user) external view returns (bool); function addIdentityAdmin(address account) external returns (bool); function setAvatar(address _avatar) external; function isIdentityAdmin(address account) external view returns (bool); function owner() external view returns (address); function removeContract(address account) external; function isDAOContract(address account) external view returns (bool); function addrToDID(address account) external view returns (string memory); function didHashToAddress(bytes32 hash) external view returns (address); event WhitelistedAdded(address user); } interface IIdentityV2 is IIdentity { function addWhitelistedWithDIDAndChain( address account, string memory did, uint256 orgChainId, uint256 dateAuthenticated ) external; function getWhitelistedRoot(address account) external view returns (address root); } interface IUBIScheme { function currentDay() external view returns (uint256); function periodStart() external view returns (uint256); function hasClaimed(address claimer) external view returns (bool); } interface IFirstClaimPool { function awardUser(address user) external returns (uint256); function claimAmount() external view returns (uint256); } interface ProxyAdmin { function getProxyImplementation(address proxy) external view returns (address); function getProxyAdmin(address proxy) external view returns (address); function upgrade(address proxy, address implementation) external; function owner() external view returns (address); function transferOwnership(address newOwner) external; function upgradeAndCall( address proxy, address implementation, bytes memory data ) external; } /** * @dev Interface for chainlink oracles to obtain price datas */ interface AggregatorV3Interface { function decimals() external view returns (uint8); function description() external view returns (string memory); function version() external view returns (uint256); // getRoundData and latestRoundData should both raise "No data present" // if they do not have data to report, instead of returning unset values // which could be misinterpreted as actual reported values. function getRoundData(uint80 _roundId) external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); function latestAnswer() external view returns (int256); } /** @dev interface for AAVE lending Pool */ interface ILendingPool { /** * @dev Deposits an `amount` of underlying asset into the reserve, receiving in return overlying aTokens. * - E.g. User deposits 100 USDC and gets in return 100 aUSDC * @param asset The address of the underlying asset to deposit * @param amount The amount to be deposited * @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user * wants to receive them on his own wallet, or a different address if the beneficiary of aTokens * is a different wallet * @param referralCode Code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man **/ function deposit( address asset, uint256 amount, address onBehalfOf, uint16 referralCode ) external; /** * @dev Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned * E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC * @param asset The address of the underlying asset to withdraw * @param amount The underlying amount to be withdrawn * - Send the value type(uint256).max in order to withdraw the whole aToken balance * @param to Address that will receive the underlying, same as msg.sender if the user * wants to receive it on his own wallet, or a different address if the beneficiary is a * different wallet * @return The final amount withdrawn **/ function withdraw( address asset, uint256 amount, address to ) external returns (uint256); /** * @dev Returns the state and configuration of the reserve * @param asset The address of the underlying asset of the reserve * @return The state of the reserve **/ function getReserveData(address asset) external view returns (DataTypes.ReserveData memory); } interface IDonationStaking { function stakeDonations() external payable; } interface INameService { function getAddress(string memory _name) external view returns (address); } interface IAaveIncentivesController { /** * @dev Claims reward for an user, on all the assets of the lending pool, accumulating the pending rewards * @param amount Amount of rewards to claim * @param to Address that will be receiving the rewards * @return Rewards claimed **/ function claimRewards( address[] calldata assets, uint256 amount, address to ) external returns (uint256); /** * @dev Returns the total of rewards of an user, already accrued + not yet accrued * @param user The address of the user * @return The rewards **/ function getRewardsBalance(address[] calldata assets, address user) external view returns (uint256); } interface IGoodStaking { function collectUBIInterest(address recipient) external returns ( uint256, uint256, uint256 ); function iToken() external view returns (address); function currentGains( bool _returnTokenBalanceInUSD, bool _returnTokenGainsInUSD ) external view returns ( uint256, uint256, uint256, uint256, uint256 ); function getRewardEarned(address user) external view returns (uint256); function getGasCostForInterestTransfer() external view returns (uint256); function rewardsMinted( address user, uint256 rewardsPerBlock, uint256 blockStart, uint256 blockEnd ) external returns (uint256); } interface IHasRouter { function getRouter() external view returns (Uniswap); } interface IAdminWallet { function addAdmins(address payable[] memory _admins) external; function removeAdmins(address[] memory _admins) external; function owner() external view returns (address); function transferOwnership(address _owner) external; } interface IMultichainRouter { // Swaps `amount` `token` from this chain to `toChainID` chain with recipient `to` function anySwapOut( address token, address to, uint256 amount, uint256 toChainID ) external; // Swaps `amount` `token` from this chain to `toChainID` chain with recipient `to` function anySwapOutUnderlying( address token, address to, uint256 amount, uint256 toChainID ) external; }
/project_/contracts/utils/DAOContract.sol
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; import "../DAOStackInterfaces.sol"; import "../Interfaces.sol"; /** @title Simple contract that keeps DAO contracts registery */ contract DAOContract { Controller public dao; address public avatar; INameService public nameService; function _onlyAvatar() internal view { require( address(dao.avatar()) == msg.sender, "only avatar can call this method" ); } function setDAO(INameService _ns) internal { nameService = _ns; updateAvatar(); } function updateAvatar() public { dao = Controller(nameService.getAddress("CONTROLLER")); avatar = dao.avatar(); } function nativeToken() public view returns (IGoodDollar) { return IGoodDollar(nameService.getAddress("GOODDOLLAR")); } uint256[50] private gap; }
/project_/contracts/utils/DAOUpgradeableContract.sol
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "./DAOContract.sol"; /** @title Simple contract that adds upgradability to DAOContract */ contract DAOUpgradeableContract is Initializable, UUPSUpgradeable, DAOContract { function _authorizeUpgrade(address) internal virtual override { _onlyAvatar(); } }
/project_/contracts/utils/DataTypes.sol
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; library DataTypes { // refer to the whitepaper, section 1.1 basic concepts for a formal description of these properties. struct ReserveData { //stores the reserve configuration ReserveConfigurationMap configuration; //the liquidity index. Expressed in ray uint128 liquidityIndex; //variable borrow index. Expressed in ray uint128 variableBorrowIndex; //the current supply rate. Expressed in ray uint128 currentLiquidityRate; //the current variable borrow rate. Expressed in ray uint128 currentVariableBorrowRate; //the current stable borrow rate. Expressed in ray uint128 currentStableBorrowRate; uint40 lastUpdateTimestamp; //tokens addresses address aTokenAddress; address stableDebtTokenAddress; address variableDebtTokenAddress; //address of the interest rate strategy address interestRateStrategyAddress; //the id of the reserve. Represents the position in the list of the active reserves uint8 id; } struct ReserveConfigurationMap { //bit 0-15: LTV //bit 16-31: Liq. threshold //bit 32-47: Liq. bonus //bit 48-55: Decimals //bit 56: Reserve is active //bit 57: reserve is frozen //bit 58: borrowing is enabled //bit 59: stable rate borrowing enabled //bit 60-63: reserved //bit 64-79: reserve factor uint256 data; } enum InterestRateMode { NONE, STABLE, VARIABLE } }
Contract ABI
[{"type":"event","name":"AdminChanged","inputs":[{"type":"address","name":"previousAdmin","internalType":"address","indexed":false},{"type":"address","name":"newAdmin","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"BeaconUpgraded","inputs":[{"type":"address","name":"beacon","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Burned","inputs":[{"type":"address","name":"minter","internalType":"address","indexed":false},{"type":"address","name":"to","internalType":"address","indexed":false},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Initialized","inputs":[{"type":"uint8","name":"version","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"event","name":"Minted","inputs":[{"type":"address","name":"minter","internalType":"address","indexed":false},{"type":"address","name":"to","internalType":"address","indexed":false},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"MinterSet","inputs":[{"type":"address","name":"minter","internalType":"address","indexed":false},{"type":"uint256","name":"totalMintCapIn","internalType":"uint256","indexed":false},{"type":"uint256","name":"perTxCapIn","internalType":"uint256","indexed":false},{"type":"uint32","name":"bpsIn","internalType":"uint32","indexed":false},{"type":"uint256","name":"totalMintCapOut","internalType":"uint256","indexed":false},{"type":"uint256","name":"perTxCapOut","internalType":"uint256","indexed":false},{"type":"uint32","name":"bpsOut","internalType":"uint32","indexed":false},{"type":"bool","name":"rewardsRole","internalType":"bool","indexed":false},{"type":"bool","name":"isUpdate","internalType":"bool","indexed":false}],"anonymous":false},{"type":"event","name":"Paused","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":false}],"anonymous":false},{"type":"event","name":"RoleAdminChanged","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"previousAdminRole","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"newAdminRole","internalType":"bytes32","indexed":true}],"anonymous":false},{"type":"event","name":"RoleGranted","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RoleRevoked","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"SendOrMint","inputs":[{"type":"address","name":"rewarder","internalType":"address","indexed":false},{"type":"address","name":"to","internalType":"address","indexed":false},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false},{"type":"uint256","name":"sent","internalType":"uint256","indexed":false},{"type":"uint256","name":"minted","internalType":"uint256","indexed":false},{"type":"uint256","name":"outstandingMintDebt","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Unpaused","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":false}],"anonymous":false},{"type":"event","name":"UpdateFrequencySet","inputs":[{"type":"uint128","name":"newFrequency","internalType":"uint128","indexed":false}],"anonymous":false},{"type":"event","name":"Upgraded","inputs":[{"type":"address","name":"implementation","internalType":"address","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"BRIDGE_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"DEFAULT_ADMIN_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"GUARDIAN_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"MINTER_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"PAUSE_ALL_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"PAUSE_BURN_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"PAUSE_MINT_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"PAUSE_REWARDS_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"PAUSE_ROUTER_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"REWARDS_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"ROUTER_ROLE","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addMinter","inputs":[{"type":"address","name":"minter","internalType":"address"},{"type":"uint256","name":"globalLimitIn","internalType":"uint256"},{"type":"uint256","name":"perTxLimitIn","internalType":"uint256"},{"type":"uint32","name":"bpsPerDayIn","internalType":"uint32"},{"type":"uint256","name":"globalLimitOut","internalType":"uint256"},{"type":"uint256","name":"perTxLimitOut","internalType":"uint256"},{"type":"uint32","name":"bpsPerDayOut","internalType":"uint32"},{"type":"bool","name":"withRewardsRole","internalType":"bool"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"avatar","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"balance","internalType":"uint256"}],"name":"balanceOf","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"burn","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint128","name":"","internalType":"uint128"}],"name":"currentDay","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract Controller"}],"name":"dao","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint8","name":"","internalType":"uint8"}],"name":"decimals","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getRoleAdmin","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getRoleMember","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"uint256","name":"index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getRoleMemberCount","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"grantRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_admin","internalType":"address"},{"type":"address","name":"_nameService","internalType":"contract INameService"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"mint","inputs":[{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"maxOut","internalType":"uint256"},{"type":"uint256","name":"capOut","internalType":"uint256"},{"type":"uint256","name":"totalOut","internalType":"uint256"},{"type":"uint128","name":"dailyCapOut","internalType":"uint128"},{"type":"uint128","name":"burnedToday","internalType":"uint128"},{"type":"uint32","name":"bpsPerDayOut","internalType":"uint32"}],"name":"minterOutLimits","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"maxIn","internalType":"uint256"},{"type":"uint256","name":"capIn","internalType":"uint256"},{"type":"uint256","name":"totalIn","internalType":"uint256"},{"type":"uint128","name":"dailyCapIn","internalType":"uint128"},{"type":"uint128","name":"mintedToday","internalType":"uint128"},{"type":"uint128","name":"lastUpdate","internalType":"uint128"},{"type":"uint128","name":"totalRewards","internalType":"uint128"},{"type":"uint32","name":"bpsPerDayIn","internalType":"uint32"},{"type":"uint128","name":"lastDayReset","internalType":"uint128"}],"name":"minterSupply","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"name","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract INameService"}],"name":"nameService","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IGoodDollar"}],"name":"nativeToken","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"onTokenTransfer","inputs":[{"type":"address","name":"sender","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"bytes","name":"data","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"pause","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"paused","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"proxiableUUID","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"revokeRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"totalSent","internalType":"uint256"}],"name":"sendOrMint","inputs":[{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMinterCaps","inputs":[{"type":"address","name":"minter","internalType":"address"},{"type":"uint256","name":"globalLimitIn","internalType":"uint256"},{"type":"uint256","name":"perTxLimitIn","internalType":"uint256"},{"type":"uint32","name":"bpsPerDayIn","internalType":"uint32"},{"type":"uint256","name":"globalLimitOut","internalType":"uint256"},{"type":"uint256","name":"perTxLimitOut","internalType":"uint256"},{"type":"uint32","name":"bpsPerDayOut","internalType":"uint32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setUpdateFrequency","inputs":[{"type":"uint128","name":"inSeconds","internalType":"uint128"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"interfaceId","internalType":"bytes4"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"symbol","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"token","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalMintCap_unused","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint128","name":"","internalType":"uint128"}],"name":"totalMintDebt","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalMinted","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint128","name":"","internalType":"uint128"}],"name":"totalRewards","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unpause","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateAvatar","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint128","name":"","internalType":"uint128"}],"name":"updateFrequency","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"upgradeSuperGoodDollar","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"upgradeTo","inputs":[{"type":"address","name":"newImplementation","internalType":"address"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"upgradeToAndCall","inputs":[{"type":"address","name":"newImplementation","internalType":"address"},{"type":"bytes","name":"data","internalType":"bytes"}]}]
Contract Creation Code
0x60a06040523060805234801561001457600080fd5b506080516142f561004c600039600081816110c601528181611106015281816113c701528181611407015261147f01526142f56000f3fe60806040526004361061025a5760003560e01c806301ffc9a71461025f57806306fdde03146102945780630e15561a146102b657806317eebf21146102eb5780631b3c90a814610319578063248a9ca31461033057806324ea54f4146103505780632f2ff15d146103725780632f4dae9f1461039257806330d643b5146103b2578063313ce567146103e657806336568abe1461040d5780633659cfe61461042d5780633e6326fc1461044d57806340c10f191461047b5780634162169f1461049b578063485cc955146104bc5780634f1ef286146104dc5780634f31e2b5146104ef57806352d1902d1461051057806353e691a2146105255780635955b5921461053a5780635ad411611461055c5780635aef7de61461057c5780635c9302c91461059d578063673ea086146105be57806370a08231146105e65780638da5cb5b146106065780639010d07c1461061b57806391d148541461063b578063956092121461065b57806395d89b41146107335780639ac25d08146107485780639dc29fac1461075d5780639e9e46661461077d578063a19ff6801461079d578063a217fddf14610748578063a2309ff8146107bf578063a4c0ed36146107d6578063abccdb52146107f6578063b32ad1a614610816578063b5bfddea14610838578063ca15c8731461086c578063ca4fb87c1461088c578063d5391393146108ae578063d547741f146108d0578063d56b73a4146108f0578063e1758bd814610995578063e47cbcbe146109aa578063ed56531a146109c1578063f1755339146109e1578063fc0c546a14610a01578063fe2e98b914610a22575b600080fd5b34801561026b57600080fd5b5061027f61027a36600461390d565b610a44565b60405190151581526020015b60405180910390f35b3480156102a057600080fd5b506102a9610a6f565b60405161028b919061395b565b3480156102c257600080fd5b50610169546102de90600160801b90046001600160801b031681565b60405161028b919061398e565b3480156102f757600080fd5b5061030b6103063660046139b7565b610ae7565b60405190815260200161028b565b34801561032557600080fd5b5061032e610e03565b005b34801561033c57600080fd5b5061030b61034b3660046139e3565b610f2d565b34801561035c57600080fd5b5061030b6000805160206142a083398151915281565b34801561037e57600080fd5b5061032e61038d3660046139fc565b610f42565b34801561039e57600080fd5b5061032e6103ad3660046139e3565b610f63565b3480156103be57600080fd5b5061030b7f7a05a596cb0ce7fdea8a1e1ec73be300bdb35097c944ce1897202f7a13122eb281565b3480156103f257600080fd5b506103fb610fd3565b60405160ff909116815260200161028b565b34801561041957600080fd5b5061032e6104283660046139fc565b611042565b34801561043957600080fd5b5061032e610448366004613a2c565b6110bc565b34801561045957600080fd5b506101305461046e906001600160a01b031681565b60405161028b9190613a49565b34801561048757600080fd5b5061027f6104963660046139b7565b611184565b3480156104a757600080fd5b5061012e5461046e906001600160a01b031681565b3480156104c857600080fd5b5061032e6104d7366004613a5d565b6111f8565b61032e6104ea366004613b4e565b6113bd565b3480156104fb57600080fd5b50610169546102de906001600160801b031681565b34801561051c57600080fd5b5061030b611472565b34801561053157600080fd5b5061032e611520565b34801561054657600080fd5b5061030b60008051602061428083398151915281565b34801561056857600080fd5b5061032e610577366004613bc4565b6115e1565b34801561058857600080fd5b5061012f5461046e906001600160a01b031681565b3480156105a957600080fd5b50610168546102de906001600160801b031681565b3480156105ca57600080fd5b50610168546102de90600160801b90046001600160801b031681565b3480156105f257600080fd5b5061030b610601366004613a2c565b611671565b34801561061257600080fd5b5061046e6116e4565b34801561062757600080fd5b5061046e610636366004613c45565b6116ec565b34801561064757600080fd5b5061027f6106563660046139fc565b61170b565b34801561066757600080fd5b506106da610676366004613a2c565b610163602052600090815260409020805460018201546002830154600384015460048501546005909501549394929391926001600160801b0380831693600160801b93849004821693838316930482169163ffffffff821691600160201b90041689565b60408051998a5260208a0198909852968801959095526001600160801b0393841660608801529183166080870152821660a0860152811660c085015263ffffffff90911660e0840152166101008201526101200161028b565b34801561073f57600080fd5b506102a9611736565b34801561075457600080fd5b5061030b600081565b34801561076957600080fd5b5061027f6107783660046139b7565b611781565b34801561078957600080fd5b5061027f6107983660046139e3565b61183c565b3480156107a957600080fd5b5061030b60008051602061421983398151915281565b3480156107cb57600080fd5b5061030b6101655481565b3480156107e257600080fd5b5061027f6107f1366004613c67565b611851565b34801561080257600080fd5b5061032e610811366004613cbf565b6119e9565b34801561082257600080fd5b5061030b60008051602061415483398151915281565b34801561084457600080fd5b5061030b7f52ba824bfabc2bcfcdf7f0edbb486ebb05e1836c90e78047efeb949990f72e5f81565b34801561087857600080fd5b5061030b6108873660046139e3565b611a5e565b34801561089857600080fd5b5061030b6000805160206141f983398151915281565b3480156108ba57600080fd5b5061030b60008051602061426083398151915281565b3480156108dc57600080fd5b5061032e6108eb3660046139fc565b611a75565b3480156108fc57600080fd5b5061095661090b366004613a2c565b61016a60205260009081526040902080546001820154600283015460038401546004909401549293919290916001600160801b0380821692600160801b909204169063ffffffff1686565b604080519687526020870195909552938501929092526001600160801b03908116606085015216608083015263ffffffff1660a082015260c00161028b565b3480156109a157600080fd5b5061046e611a91565b3480156109b657600080fd5b5061030b6101645481565b3480156109cd57600080fd5b5061032e6109dc3660046139e3565b611b1a565b3480156109ed57600080fd5b5061032e6109fc366004613d2b565b611b7f565b348015610a0d57600080fd5b506101665461046e906001600160a01b031681565b348015610a2e57600080fd5b5061030b60008051602061417483398151915281565b60006001600160e01b03198216635a05180f60e01b1480610a695750610a6982611c32565b92915050565b61016654604080516306fdde0360e01b815290516060926001600160a01b0316916306fdde039160048083019260009291908290030181865afa158015610aba573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ae29190810190613d54565b905090565b60006000805160206141f9833981519152610b0181611c67565b600080516020614174833981519152610b198161183c565b158015610b2d5750610b2b600061183c565b155b610b525760405162461bcd60e51b8152600401610b4990613dc1565b60405180910390fd5b610b5b33611c71565b33600090815261016360205260408120600301546001600160801b031615610bbb573360009081526101636020526040902060030154610bad906001600160801b03600160801b820481169116613e08565b6001600160801b0316610bbd565b845b610166546040516370a0823160e01b8152919250600091610c3d916001600160a01b0316906370a0823190610bf6903090600401613a49565b602060405180830381865afa158015610c13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c379190613e28565b87611ee4565b90506000610c54610c4e8389613e41565b84611ee4565b9050610c608183613e54565b3360009081526101636020526040902060040180549197508791601090610c98908490600160801b90046001600160801b0316613e67565b92506101000a8154816001600160801b0302191690836001600160801b031602179055508561016960108282829054906101000a90046001600160801b0316610ce19190613e67565b92506101000a8154816001600160801b0302191690836001600160801b031602179055508061016960008282829054906101000a90046001600160801b0316610d2a9190613e67565b92506101000a8154816001600160801b0302191690836001600160801b031602179055506000811115610d6157610d618882611efa565b8115610d7f5761016654610d7f906001600160a01b031689846122e0565b80600003610d8f57610d8f612336565b61016954604080513381526001600160a01b038b1660208201528082018a905260608101859052608081018490526001600160801b0390921660a0830152517fdea51570922020f525c1f30d8c1c57bd3cffe5632d70d13aaf8f8451388dbd959181900360c00190a1505050505092915050565b6101305460405163bf40fac160e01b815260206004820152600a60248201526921a7a72a2927a62622a960b11b60448201526001600160a01b039091169063bf40fac190606401602060405180830381865afa158015610e67573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e8b9190613e87565b61012e80546001600160a01b0319166001600160a01b0392909216918217905560408051632d77bef360e11b81529051635aef7de6916004808201926020929091908290030181865afa158015610ee6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f0a9190613e87565b61012f80546001600160a01b0319166001600160a01b0392909216919091179055565b60009081526065602052604090206001015490565b610f4b82610f2d565b610f5481611c67565b610f5e8383612489565b505050565b604080518082019091526000805160206142a08339815191528152600060208201819052610f999082905b60200201513361170b565b80610faa5750610faa816001610f8e565b610fc65760405162461bcd60e51b8152600401610b4990613eba565b610fcf826124ab565b5050565b610166546040805163313ce56760e01b815290516000926001600160a01b03169163313ce5679160048083019260209291908290030181865afa15801561101e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ae29190613ee0565b6001600160a01b03811633146110b25760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610b49565b610fcf8282612557565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630036111045760405162461bcd60e51b8152600401610b4990613f03565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316611136612579565b6001600160a01b03161461115c5760405162461bcd60e51b8152600401610b4990613f3d565b61116581612595565b604080516000808252602082019092526111819183919061259d565b50565b600060008051602061426083398151915261119e81611c67565b6111a733611c71565b6111b18484611efa565b7f9d228d69b5fdb8d273a2336f8fb8612d039631024ea9bf09c424a9503aa078f03385856040516111e493929190613f77565b60405180910390a1600191505b5092915050565b600054610100900460ff16158080156112185750600054600160ff909116105b80611239575061122730612708565b158015611239575060005460ff166001145b61129c5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610b49565b6000805460ff1916600117905580156112bf576000805461ff0019166101001790555b6112c7612717565b6112d082612784565b6001600160a01b03831661131b5760405162461bcd60e51b81526020600482015260126024820152717a65726f2061646d696e206164647265737360701b6044820152606401610b49565b611323611a91565b61016680546001600160a01b0319166001600160a01b0392831617905561016880546001600160801b03166176a760881b17905561012f5461136891600091166127a8565b6113736000846127a8565b8015610f5e576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630036114055760405162461bcd60e51b8152600401610b4990613f03565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316611437612579565b6001600160a01b03161461145d5760405162461bcd60e51b8152600401610b4990613f3d565b61146682612595565b610fcf8282600161259d565b6000306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461150d5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c6044820152771b1959081d1a1c9bdd59da0819195b1959d85d1958d85b1b60421b6064820152608401610b49565b506000805160206141b483398151915290565b600061152b81611c67565b61012f54730f5db7a64a6a64052693676ca898ec7f7a94ff4e9061155a906000906001600160a01b0316612557565b61156381612784565b61156b611a91565b61016680546001600160a01b0319166001600160a01b0392831617905561012f5461159991600091166127a8565b61016880546001600160801b03166107e960871b179055610fcf73f27ee99622c3c9b264583dacb2cce056e194494f60008080806af8277896582678ac0000006113886127b2565b60006115ec81611c67565b81156116275761160a6000805160206141f98339815191528a610f42565b6116226000805160206142608339815191528a611a75565b611657565b61163f6000805160206142608339815191528a610f42565b6116576000805160206141f98339815191528a611a75565b611666898989898989896127b2565b505050505050505050565b610166546040516370a0823160e01b81526000916001600160a01b0316906370a08231906116a3908590600401613a49565b602060405180830381865afa1580156116c0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a699190613e28565b6000610ae281805b60008281526097602052604081206117049083612a54565b9392505050565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b61016654604080516395d89b4160e01b815290516060926001600160a01b0316916395d89b419160048083019260009291908290030181865afa158015610aba573d6000803e3d6000fd5b600060008051602061426083398151915261179b81611c67565b6000805160206142808339815191526117b38161183c565b1580156117c757506117c5600061183c565b155b6117e35760405162461bcd60e51b8152600401610b4990613dc1565b6117ec33611c71565b6117f68585612a60565b7f6ab368f832c266c8eb942b84fbcaa20aedc24a699d2a05fae2568028733b1d0933868660405161182993929190613f77565b60405180910390a1506001949350505050565b600090815260c9602052604090205460ff1690565b610166546000906001600160a01b0316331461186c57600080fd5b600080838060200190518101906118839190613f9b565b91509150806000036118c65760405162461bcd60e51b815260206004820152600c60248201526b1e995c9bc818da185a5b925960a21b6044820152606401610b49565b6001600160a01b0382166118da57856118dc565b815b6101305460405163bf40fac160e01b815260206004820152601160248201527026aaa62a24a1a420a4a72fa927aaaa22a960791b60448201529193506001600160a01b03169063bf40fac190606401602060405180830381865afa158015611948573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061196c9190613e87565b60405163241dc2df60e01b81523060048201526001600160a01b0384811660248301526044820188905260648201849052919091169063241dc2df90608401600060405180830381600087803b1580156119c557600080fd5b505af11580156119d9573d6000803e3d6000fd5b5060019998505050505050505050565b604080518082019091526000805160206142a08339815191528152600060208201819052611a18908290610f8e565b80611a295750611a29816001610f8e565b611a455760405162461bcd60e51b8152600401610b4990613eba565b611a54888888888888886127b2565b5050505050505050565b6000818152609760205260408120610a6990612d93565b611a7e82610f2d565b611a8781611c67565b610f5e8383612557565b6101305460405163bf40fac160e01b815260206004820152600a60248201526923a7a7a22227a62620a960b11b60448201526000916001600160a01b03169063bf40fac190606401602060405180830381865afa158015611af6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ae29190613e87565b604080518082019091526000805160206142a08339815191528152600060208201819052611b49908290610f8e565b80611b5a5750611b5a816001610f8e565b611b765760405162461bcd60e51b8152600401610b4990613eba565b610fcf82612d9d565b604080518082019091526000805160206142a08339815191528152600060208201819052611bae908290610f8e565b80611bbf5750611bbf816001610f8e565b611bdb5760405162461bcd60e51b8152600401610b4990613eba565b61016880546001600160801b03808516600160801b0291161790556040517f5497ec04d2873f2e2d376db2bb24e7e57851278c75fc1fcc9aab4db5fb70d22390611c2690849061398e565b60405180910390a15050565b60006001600160e01b03198216637965db0b60e01b1480610a6957506301ffc9a760e01b6001600160e01b0319831614610a69565b6111818133612e22565b6001600160a01b03811660009081526101636020526040812060040154611ca1906001600160801b031642613e41565b9050600061016660009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611cf9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d1d9190613e28565b61016854909150600160801b90046001600160801b03168210611e33576001600160a01b0383166000908152610163602052604090206005015461271090611d6b9063ffffffff1683613fc9565b611d759190613ffe565b6001600160a01b03841660009081526101636020908152604080832060030180546001600160801b0319166001600160801b03959095169490941790935561016a9052206004015461271090611dd19063ffffffff1683613fc9565b611ddb9190613ffe565b6001600160a01b038416600090815261016a6020908152604080832060030180546001600160801b03199081166001600160801b03968716179091556101639092529091206004018054909116429092169190911790555b611e3b612e7b565b6001600160a01b03831660009081526101636020526040902060050154610168546001600160801b03908116600160201b9092041614610f5e5750506001600160a01b0316600090815261016360208181526040808420600380820180546001600160801b0390811690915561016a855292909520909401805482169055610168549290915260059092018054600160201b600160a01b03191691909216600160201b02179055565b6000818310611ef35781611704565b5090919050565b600080516020614154833981519152611f128161183c565b158015611f265750611f24600061183c565b155b611f425760405162461bcd60e51b8152600401610b4990613dc1565b306001600160a01b03841603611f895760405162461bcd60e51b815260206004820152600c60248201526b36b4b73a103a379039b2b63360a11b6044820152606401610b49565b33600090815261016360205260409020541580611fb6575033600090815261016360205260409020548211155b611ff85760405162461bcd60e51b81526020600482015260136024820152721b5a5b9d195c881b585e08195e18d959591959606a1b6044820152606401610b49565b33600090815261016360205260409020600301546001600160801b0316158061206b5750336000908152610163602052604090206003015461204b908390600160801b90046001600160801b0316613e54565b33600090815261016360205260409020600301546001600160801b031610155b6120b35760405162461bcd60e51b81526020600482015260196024820152781b5a5b9d195c8819185a5b1e4818d85c08195e18d959591959603a1b6044820152606401610b49565b3360009081526101636020526040902060030180548391906010906120e9908490600160801b90046001600160801b0316613e67565b92506101000a8154816001600160801b0302191690836001600160801b03160217905550816101636000336001600160a01b03166001600160a01b0316815260200190815260200160002060020160008282546121469190613e54565b909155505033600090815261016360205260409020600101541580612184575033600090815261016360205260409020600181015460029091015411155b6121a05760405162461bcd60e51b8152600401610b4990614012565b8161016560008282546121b39190613e54565b909155505033600090815261016a602052604090206002015482116122005733600090815261016a6020526040812060020180548492906121f5908490613e41565b909155506122159050565b33600090815261016a60205260408120600201555b61012e5461012f54604051633203f21960e11b8152600481018590526001600160a01b03868116602483015291821660448201526000929190911690636407e432906064016020604051808303816000875af1158015612279573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061229d919061403f565b9050806122da5760405162461bcd60e51b815260206004820152600b60248201526a1b5a5b9d0819985a5b195960aa1b6044820152606401610b49565b50505050565b610f5e8363a9059cbb60e01b84846040516024016122ff92919061405c565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612eab565b61016954610166546040516370a0823160e01b81526000926123c4926001600160801b03909116916001600160a01b03909116906370a082319061237e903090600401613a49565b602060405180830381865afa15801561239b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123bf9190613e28565b611ee4565b905080156111815761016980548291906000906123eb9084906001600160801b0316613e08565b92506101000a8154816001600160801b0302191690836001600160801b031602179055508061016560008282546124229190613e41565b909155505061016654604051630852cd8d60e31b8152600481018390526001600160a01b03909116906342966c6890602401600060405180830381600087803b15801561246e57600080fd5b505af1158015612482573d6000803e3d6000fd5b5050505050565b6124938282612f7d565b6000828152609760205260409020610f5e9082613003565b806124b58161183c565b806124c557506124c5600061183c565b61250f5760405162461bcd60e51b815260206004820152601b60248201527a14185d5cd8589b1950dbdb9d1c9bdb0e881b9bdd081c185d5cd959602a1b6044820152606401610b49565b600082815260c9602052604090819020805460ff19169055517fd05bfc2250abb0f8fd265a54c53a24359c5484af63cad2e4ce87c78ab751395a90611c269084815260200190565b6125618282613018565b6000828152609760205260409020610f5e908261307f565b6000805160206141b4833981519152546001600160a01b031690565b611181613094565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156125d057610f5e83613158565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801561262a575060408051601f3d908101601f1916820190925261262791810190613e28565b60015b61268d5760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608401610b49565b6000805160206141b483398151915281146126fc5760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401610b49565b50610f5e8383836131f2565b6001600160a01b03163b151590565b600054610100900460ff166127825760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610b49565b565b61013080546001600160a01b0319166001600160a01b038316179055611181610e03565b610fcf8282612489565b6001600160a01b03871660009081526101636020908152604080832061016a90925282206004820154919290916001600160801b03161515906128036000805160206141f98339815191528c61170b565b600185018b905589855560058501805463ffffffff191663ffffffff8b16908117909155600480870180546001600160801b031916426001600160801b031617905561016654604080516318160ddd60e01b81529051949550612710946001600160a01b03909216926318160ddd9282820192602092908290030181865afa158015612893573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128b79190613e28565b6128c19190613fc9565b6128cb9190614075565b8460030160006101000a8154816001600160801b0302191690836001600160801b031602179055506127108563ffffffff1661016660009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612951573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129759190613e28565b61297f9190613fc9565b6129899190614075565b6003840180546001600160801b0319166001600160801b03929092169190911790556001830187905585835560048301805463ffffffff191663ffffffff878116918217909255604080516001600160a01b038f168152602081018e90529081018c9052918a1660608301526080820189905260a0820188905260c082015281151560e08201528215156101008201527f58c3ceb7d4f068706ddc92911fae8701fac2c91c60bcc1b56ec7a6f56001aa5e906101200160405180910390a15050505050505050505050565b60006117048383613217565b600080516020614219833981519152612a788161183c565b158015612a8c5750612a8a600061183c565b155b612aa85760405162461bcd60e51b8152600401610b4990613dc1565b33600090815261016a60205260409020541580612ad5575033600090815261016a60205260409020548211155b612b1c5760405162461bcd60e51b81526020600482015260186024820152771b5a5b9d195c88189d5c9b881b585e08195e18d95959195960421b6044820152606401610b49565b33600090815261016a60205260409020600301546001600160801b03161580612b8f575033600090815261016a6020526040902060030154612b6f908390600160801b90046001600160801b0316613e54565b33600090815261016a60205260409020600301546001600160801b031610155b612bdb5760405162461bcd60e51b815260206004820152601e60248201527f6d696e746572206275726e206461696c792063617020657863656564656400006044820152606401610b49565b33600090815261016a602052604090206003018054839190601090612c11908490600160801b90046001600160801b0316613e67565b92506101000a8154816001600160801b0302191690836001600160801b031602179055508161016a6000336001600160a01b03166001600160a01b031681526020019081526020016000206002016000828254612c6e9190613e54565b909155505033600090815261016a60205260409020600101541580612cac575033600090815261016a60205260409020600181015460029091015411155b612cc85760405162461bcd60e51b8152600401610b4990614012565b816101655410612cf057816101656000828254612ce59190613e41565b90915550612cf79050565b6000610165555b33600090815261016360205260409020600201548211612d3f57336000908152610163602052604081206002018054849290612d34908490613e41565b90915550612d549050565b33600090815261016360205260408120600201555b306001600160a01b03841603612d7b5761016654610f5e906001600160a01b031683613241565b61016654610f5e906001600160a01b0316848461328e565b6000610a69825490565b80612da78161183c565b158015612dbb5750612db9600061183c565b155b612dd75760405162461bcd60e51b8152600401610b4990613dc1565b600082815260c9602052604090819020805460ff19166001179055517f0cb09dc71d57eeec2046f6854976717e4874a3cf2d6ddeddde337e5b6de6ba3190611c269084815260200190565b612e2c828261170b565b610fcf57612e39816132aa565b612e448360206132bc565b604051602001612e5592919061409b565b60408051601f198184030181529082905262461bcd60e51b8252610b499160040161395b565b612e886201518042613ffe565b61016880546001600160801b0319166001600160801b0392909216919091179055565b6000612f00826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166134579092919063ffffffff16565b805190915015610f5e5780806020019051810190612f1e919061403f565b610f5e5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610b49565b612f87828261170b565b610fcf5760008281526065602090815260408083206001600160a01b03851684529091529020805460ff19166001179055612fbf3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000611704836001600160a01b03841661346e565b613022828261170b565b15610fcf5760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000611704836001600160a01b0384166134bd565b61012e5460408051632d77bef360e11b8152905133926001600160a01b031691635aef7de69160048083019260209291908290030181865afa1580156130de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131029190613e87565b6001600160a01b0316146127825760405162461bcd60e51b815260206004820181905260248201527f6f6e6c79206176617461722063616e2063616c6c2074686973206d6574686f646044820152606401610b49565b61316181612708565b6131c35760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610b49565b6000805160206141b483398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6131fb836135b0565b6000825111806132085750805b15610f5e576122da83836135f0565b600082600001828154811061322e5761322e613ea4565b9060005260206000200154905092915050565b610fcf826342966c688360405160240161325d91815260200190565b6040516020818303038152906040529060e01b6020820180516001600160e01b0383818316178352505050506136e2565b610f5e836379cc6790848460405160240161325d92919061405c565b6060610a696001600160a01b03831660145b606060006132cb836002613fc9565b6132d6906002613e54565b6001600160401b038111156132ed576132ed613a8b565b6040519080825280601f01601f191660200182016040528015613317576020820181803683370190505b509050600360fc1b8160008151811061333257613332613ea4565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061336157613361613ea4565b60200101906001600160f81b031916908160001a9053506000613385846002613fc9565b613390906001613e54565b90505b6001811115613408576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106133c4576133c4613ea4565b1a60f81b8282815181106133da576133da613ea4565b60200101906001600160f81b031916908160001a90535060049490941c936134018161410a565b9050613393565b5083156117045760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610b49565b6060613466848460008561377c565b949350505050565b60008181526001830160205260408120546134b557508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610a69565b506000610a69565b600081815260018301602052604081205480156135a65760006134e1600183613e41565b85549091506000906134f590600190613e41565b905081811461355a57600086600001828154811061351557613515613ea4565b906000526020600020015490508087600001848154811061353857613538613ea4565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061356b5761356b614121565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610a69565b6000915050610a69565b6135b981613158565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606135fb83612708565b6136565760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610b49565b600080846001600160a01b0316846040516136719190614137565b600060405180830381855af49150503d80600081146136ac576040519150601f19603f3d011682016040523d82523d6000602084013e6136b1565b606091505b50915091506136d9828260405180606001604052806027815260200161423960279139613857565b95945050505050565b6000613712826040518060600160405280602581526020016141d4602591396001600160a01b0386169190613457565b805190915015610f5e5780806020019051810190613730919061403f565b610f5e5760405162461bcd60e51b815260206004820152601f60248201527f546f6b656e4f7065726174696f6e3a20646964206e6f742073756363656564006044820152606401610b49565b6060824710156137dd5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610b49565b600080866001600160a01b031685876040516137f99190614137565b60006040518083038185875af1925050503d8060008114613836576040519150601f19603f3d011682016040523d82523d6000602084013e61383b565b606091505b509150915061384c87838387613870565b979650505050505050565b60608315613866575081611704565b61170483836138e3565b606083156138dd5782516000036138d65761388a85612708565b6138d65760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610b49565b5081613466565b61346683835b8151156138f35781518083602001fd5b8060405162461bcd60e51b8152600401610b49919061395b565b60006020828403121561391f57600080fd5b81356001600160e01b03198116811461170457600080fd5b60005b8381101561395257818101518382015260200161393a565b50506000910152565b602081526000825180602084015261397a816040850160208701613937565b601f01601f19169190910160400192915050565b6001600160801b0391909116815260200190565b6001600160a01b038116811461118157600080fd5b600080604083850312156139ca57600080fd5b82356139d5816139a2565b946020939093013593505050565b6000602082840312156139f557600080fd5b5035919050565b60008060408385031215613a0f57600080fd5b823591506020830135613a21816139a2565b809150509250929050565b600060208284031215613a3e57600080fd5b8135611704816139a2565b6001600160a01b0391909116815260200190565b60008060408385031215613a7057600080fd5b8235613a7b816139a2565b91506020830135613a21816139a2565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715613ac957613ac9613a8b565b604052919050565b60006001600160401b03821115613aea57613aea613a8b565b50601f01601f191660200190565b600082601f830112613b0957600080fd5b8135613b1c613b1782613ad1565b613aa1565b818152846020838601011115613b3157600080fd5b816020850160208301376000918101602001919091529392505050565b60008060408385031215613b6157600080fd5b8235613b6c816139a2565b915060208301356001600160401b03811115613b8757600080fd5b613b9385828601613af8565b9150509250929050565b803563ffffffff81168114613bb157600080fd5b919050565b801515811461118157600080fd5b600080600080600080600080610100898b031215613be157600080fd5b8835613bec816139a2565b97506020890135965060408901359550613c0860608a01613b9d565b94506080890135935060a08901359250613c2460c08a01613b9d565b915060e0890135613c3481613bb6565b809150509295985092959890939650565b60008060408385031215613c5857600080fd5b50508035926020909101359150565b600080600060608486031215613c7c57600080fd5b8335613c87816139a2565b92506020840135915060408401356001600160401b03811115613ca957600080fd5b613cb586828701613af8565b9150509250925092565b600080600080600080600060e0888a031215613cda57600080fd5b8735613ce5816139a2565b96506020880135955060408801359450613d0160608901613b9d565b93506080880135925060a08801359150613d1d60c08901613b9d565b905092959891949750929550565b600060208284031215613d3d57600080fd5b81356001600160801b038116811461170457600080fd5b600060208284031215613d6657600080fd5b81516001600160401b03811115613d7c57600080fd5b8201601f81018413613d8d57600080fd5b8051613d9b613b1782613ad1565b818152856020838501011115613db057600080fd5b6136d9826020830160208601613937565b60208082526017908201527614185d5cd8589b1950dbdb9d1c9bdb0e881c185d5cd959604a1b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6001600160801b038281168282160390808211156111f1576111f1613df2565b600060208284031215613e3a57600080fd5b5051919050565b81810381811115610a6957610a69613df2565b80820180821115610a6957610a69613df2565b6001600160801b038181168382160190808211156111f1576111f1613df2565b600060208284031215613e9957600080fd5b8151611704816139a2565b634e487b7160e01b600052603260045260246000fd5b6020808252600c908201526b726f6c65206d697373696e6760a01b604082015260600190565b600060208284031215613ef257600080fd5b815160ff8116811461170457600080fd5b6020808252602c9082015260008051602061419483398151915260408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c9082015260008051602061419483398151915260408201526b6163746976652070726f787960a01b606082015260800190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b60008060408385031215613fae57600080fd5b8251613fb9816139a2565b6020939093015192949293505050565b6000816000190483118215151615613fe357613fe3613df2565b500290565b634e487b7160e01b600052601260045260246000fd5b60008261400d5761400d613fe8565b500490565b6020808252601390820152721b5a5b9d195c8818d85c08195e18d959591959606a1b604082015260600190565b60006020828403121561405157600080fd5b815161170481613bb6565b6001600160a01b03929092168252602082015260400190565b60006001600160801b038381168061408f5761408f613fe8565b92169190910492915050565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b8152600083516140cd816017850160208801613937565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516140fe816028840160208801613937565b01602801949350505050565b60008161411957614119613df2565b506000190190565b634e487b7160e01b600052603160045260246000fd5b60008251614149818460208701613937565b919091019291505056feb2a18ae5d0b623b41098012c516d0bf4bef38c068c9e397da870c290888b19999604fa49b1cb3aa782c099225b9c340b6afeb802be5d4b3314ba27a14502cdfa46756e6374696f6e206d7573742062652063616c6c6564207468726f75676820360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546f6b656e4f7065726174696f6e3a206c6f772d6c6576656c2063616c6c206661696c65645407862f04286ebe607684514c14b7fffc750b6bf52ba44ea49569174845a5bd62d52416825983abd68b16e092b60c2eac31fd673bcce92494e063af530d9c30416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c65649f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6b601d6a8ea5419a4251765936e52b2763485fede82d3c5dfd765cd67d30f4f2255435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a5041a264697066735822122080fba124231a2b3040b17593b1b6f31533318c5ba4b4a2a90070bb60a841b13b64736f6c63430008100033
Deployed ByteCode
0x60806040526004361061025a5760003560e01c806301ffc9a71461025f57806306fdde03146102945780630e15561a146102b657806317eebf21146102eb5780631b3c90a814610319578063248a9ca31461033057806324ea54f4146103505780632f2ff15d146103725780632f4dae9f1461039257806330d643b5146103b2578063313ce567146103e657806336568abe1461040d5780633659cfe61461042d5780633e6326fc1461044d57806340c10f191461047b5780634162169f1461049b578063485cc955146104bc5780634f1ef286146104dc5780634f31e2b5146104ef57806352d1902d1461051057806353e691a2146105255780635955b5921461053a5780635ad411611461055c5780635aef7de61461057c5780635c9302c91461059d578063673ea086146105be57806370a08231146105e65780638da5cb5b146106065780639010d07c1461061b57806391d148541461063b578063956092121461065b57806395d89b41146107335780639ac25d08146107485780639dc29fac1461075d5780639e9e46661461077d578063a19ff6801461079d578063a217fddf14610748578063a2309ff8146107bf578063a4c0ed36146107d6578063abccdb52146107f6578063b32ad1a614610816578063b5bfddea14610838578063ca15c8731461086c578063ca4fb87c1461088c578063d5391393146108ae578063d547741f146108d0578063d56b73a4146108f0578063e1758bd814610995578063e47cbcbe146109aa578063ed56531a146109c1578063f1755339146109e1578063fc0c546a14610a01578063fe2e98b914610a22575b600080fd5b34801561026b57600080fd5b5061027f61027a36600461390d565b610a44565b60405190151581526020015b60405180910390f35b3480156102a057600080fd5b506102a9610a6f565b60405161028b919061395b565b3480156102c257600080fd5b50610169546102de90600160801b90046001600160801b031681565b60405161028b919061398e565b3480156102f757600080fd5b5061030b6103063660046139b7565b610ae7565b60405190815260200161028b565b34801561032557600080fd5b5061032e610e03565b005b34801561033c57600080fd5b5061030b61034b3660046139e3565b610f2d565b34801561035c57600080fd5b5061030b6000805160206142a083398151915281565b34801561037e57600080fd5b5061032e61038d3660046139fc565b610f42565b34801561039e57600080fd5b5061032e6103ad3660046139e3565b610f63565b3480156103be57600080fd5b5061030b7f7a05a596cb0ce7fdea8a1e1ec73be300bdb35097c944ce1897202f7a13122eb281565b3480156103f257600080fd5b506103fb610fd3565b60405160ff909116815260200161028b565b34801561041957600080fd5b5061032e6104283660046139fc565b611042565b34801561043957600080fd5b5061032e610448366004613a2c565b6110bc565b34801561045957600080fd5b506101305461046e906001600160a01b031681565b60405161028b9190613a49565b34801561048757600080fd5b5061027f6104963660046139b7565b611184565b3480156104a757600080fd5b5061012e5461046e906001600160a01b031681565b3480156104c857600080fd5b5061032e6104d7366004613a5d565b6111f8565b61032e6104ea366004613b4e565b6113bd565b3480156104fb57600080fd5b50610169546102de906001600160801b031681565b34801561051c57600080fd5b5061030b611472565b34801561053157600080fd5b5061032e611520565b34801561054657600080fd5b5061030b60008051602061428083398151915281565b34801561056857600080fd5b5061032e610577366004613bc4565b6115e1565b34801561058857600080fd5b5061012f5461046e906001600160a01b031681565b3480156105a957600080fd5b50610168546102de906001600160801b031681565b3480156105ca57600080fd5b50610168546102de90600160801b90046001600160801b031681565b3480156105f257600080fd5b5061030b610601366004613a2c565b611671565b34801561061257600080fd5b5061046e6116e4565b34801561062757600080fd5b5061046e610636366004613c45565b6116ec565b34801561064757600080fd5b5061027f6106563660046139fc565b61170b565b34801561066757600080fd5b506106da610676366004613a2c565b610163602052600090815260409020805460018201546002830154600384015460048501546005909501549394929391926001600160801b0380831693600160801b93849004821693838316930482169163ffffffff821691600160201b90041689565b60408051998a5260208a0198909852968801959095526001600160801b0393841660608801529183166080870152821660a0860152811660c085015263ffffffff90911660e0840152166101008201526101200161028b565b34801561073f57600080fd5b506102a9611736565b34801561075457600080fd5b5061030b600081565b34801561076957600080fd5b5061027f6107783660046139b7565b611781565b34801561078957600080fd5b5061027f6107983660046139e3565b61183c565b3480156107a957600080fd5b5061030b60008051602061421983398151915281565b3480156107cb57600080fd5b5061030b6101655481565b3480156107e257600080fd5b5061027f6107f1366004613c67565b611851565b34801561080257600080fd5b5061032e610811366004613cbf565b6119e9565b34801561082257600080fd5b5061030b60008051602061415483398151915281565b34801561084457600080fd5b5061030b7f52ba824bfabc2bcfcdf7f0edbb486ebb05e1836c90e78047efeb949990f72e5f81565b34801561087857600080fd5b5061030b6108873660046139e3565b611a5e565b34801561089857600080fd5b5061030b6000805160206141f983398151915281565b3480156108ba57600080fd5b5061030b60008051602061426083398151915281565b3480156108dc57600080fd5b5061032e6108eb3660046139fc565b611a75565b3480156108fc57600080fd5b5061095661090b366004613a2c565b61016a60205260009081526040902080546001820154600283015460038401546004909401549293919290916001600160801b0380821692600160801b909204169063ffffffff1686565b604080519687526020870195909552938501929092526001600160801b03908116606085015216608083015263ffffffff1660a082015260c00161028b565b3480156109a157600080fd5b5061046e611a91565b3480156109b657600080fd5b5061030b6101645481565b3480156109cd57600080fd5b5061032e6109dc3660046139e3565b611b1a565b3480156109ed57600080fd5b5061032e6109fc366004613d2b565b611b7f565b348015610a0d57600080fd5b506101665461046e906001600160a01b031681565b348015610a2e57600080fd5b5061030b60008051602061417483398151915281565b60006001600160e01b03198216635a05180f60e01b1480610a695750610a6982611c32565b92915050565b61016654604080516306fdde0360e01b815290516060926001600160a01b0316916306fdde039160048083019260009291908290030181865afa158015610aba573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ae29190810190613d54565b905090565b60006000805160206141f9833981519152610b0181611c67565b600080516020614174833981519152610b198161183c565b158015610b2d5750610b2b600061183c565b155b610b525760405162461bcd60e51b8152600401610b4990613dc1565b60405180910390fd5b610b5b33611c71565b33600090815261016360205260408120600301546001600160801b031615610bbb573360009081526101636020526040902060030154610bad906001600160801b03600160801b820481169116613e08565b6001600160801b0316610bbd565b845b610166546040516370a0823160e01b8152919250600091610c3d916001600160a01b0316906370a0823190610bf6903090600401613a49565b602060405180830381865afa158015610c13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c379190613e28565b87611ee4565b90506000610c54610c4e8389613e41565b84611ee4565b9050610c608183613e54565b3360009081526101636020526040902060040180549197508791601090610c98908490600160801b90046001600160801b0316613e67565b92506101000a8154816001600160801b0302191690836001600160801b031602179055508561016960108282829054906101000a90046001600160801b0316610ce19190613e67565b92506101000a8154816001600160801b0302191690836001600160801b031602179055508061016960008282829054906101000a90046001600160801b0316610d2a9190613e67565b92506101000a8154816001600160801b0302191690836001600160801b031602179055506000811115610d6157610d618882611efa565b8115610d7f5761016654610d7f906001600160a01b031689846122e0565b80600003610d8f57610d8f612336565b61016954604080513381526001600160a01b038b1660208201528082018a905260608101859052608081018490526001600160801b0390921660a0830152517fdea51570922020f525c1f30d8c1c57bd3cffe5632d70d13aaf8f8451388dbd959181900360c00190a1505050505092915050565b6101305460405163bf40fac160e01b815260206004820152600a60248201526921a7a72a2927a62622a960b11b60448201526001600160a01b039091169063bf40fac190606401602060405180830381865afa158015610e67573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e8b9190613e87565b61012e80546001600160a01b0319166001600160a01b0392909216918217905560408051632d77bef360e11b81529051635aef7de6916004808201926020929091908290030181865afa158015610ee6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f0a9190613e87565b61012f80546001600160a01b0319166001600160a01b0392909216919091179055565b60009081526065602052604090206001015490565b610f4b82610f2d565b610f5481611c67565b610f5e8383612489565b505050565b604080518082019091526000805160206142a08339815191528152600060208201819052610f999082905b60200201513361170b565b80610faa5750610faa816001610f8e565b610fc65760405162461bcd60e51b8152600401610b4990613eba565b610fcf826124ab565b5050565b610166546040805163313ce56760e01b815290516000926001600160a01b03169163313ce5679160048083019260209291908290030181865afa15801561101e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ae29190613ee0565b6001600160a01b03811633146110b25760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610b49565b610fcf8282612557565b6001600160a01b037f000000000000000000000000098148534ac15a44cff52387ba81ed929589ecaf1630036111045760405162461bcd60e51b8152600401610b4990613f03565b7f000000000000000000000000098148534ac15a44cff52387ba81ed929589ecaf6001600160a01b0316611136612579565b6001600160a01b03161461115c5760405162461bcd60e51b8152600401610b4990613f3d565b61116581612595565b604080516000808252602082019092526111819183919061259d565b50565b600060008051602061426083398151915261119e81611c67565b6111a733611c71565b6111b18484611efa565b7f9d228d69b5fdb8d273a2336f8fb8612d039631024ea9bf09c424a9503aa078f03385856040516111e493929190613f77565b60405180910390a1600191505b5092915050565b600054610100900460ff16158080156112185750600054600160ff909116105b80611239575061122730612708565b158015611239575060005460ff166001145b61129c5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610b49565b6000805460ff1916600117905580156112bf576000805461ff0019166101001790555b6112c7612717565b6112d082612784565b6001600160a01b03831661131b5760405162461bcd60e51b81526020600482015260126024820152717a65726f2061646d696e206164647265737360701b6044820152606401610b49565b611323611a91565b61016680546001600160a01b0319166001600160a01b0392831617905561016880546001600160801b03166176a760881b17905561012f5461136891600091166127a8565b6113736000846127a8565b8015610f5e576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050565b6001600160a01b037f000000000000000000000000098148534ac15a44cff52387ba81ed929589ecaf1630036114055760405162461bcd60e51b8152600401610b4990613f03565b7f000000000000000000000000098148534ac15a44cff52387ba81ed929589ecaf6001600160a01b0316611437612579565b6001600160a01b03161461145d5760405162461bcd60e51b8152600401610b4990613f3d565b61146682612595565b610fcf8282600161259d565b6000306001600160a01b037f000000000000000000000000098148534ac15a44cff52387ba81ed929589ecaf161461150d5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c6044820152771b1959081d1a1c9bdd59da0819195b1959d85d1958d85b1b60421b6064820152608401610b49565b506000805160206141b483398151915290565b600061152b81611c67565b61012f54730f5db7a64a6a64052693676ca898ec7f7a94ff4e9061155a906000906001600160a01b0316612557565b61156381612784565b61156b611a91565b61016680546001600160a01b0319166001600160a01b0392831617905561012f5461159991600091166127a8565b61016880546001600160801b03166107e960871b179055610fcf73f27ee99622c3c9b264583dacb2cce056e194494f60008080806af8277896582678ac0000006113886127b2565b60006115ec81611c67565b81156116275761160a6000805160206141f98339815191528a610f42565b6116226000805160206142608339815191528a611a75565b611657565b61163f6000805160206142608339815191528a610f42565b6116576000805160206141f98339815191528a611a75565b611666898989898989896127b2565b505050505050505050565b610166546040516370a0823160e01b81526000916001600160a01b0316906370a08231906116a3908590600401613a49565b602060405180830381865afa1580156116c0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a699190613e28565b6000610ae281805b60008281526097602052604081206117049083612a54565b9392505050565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b61016654604080516395d89b4160e01b815290516060926001600160a01b0316916395d89b419160048083019260009291908290030181865afa158015610aba573d6000803e3d6000fd5b600060008051602061426083398151915261179b81611c67565b6000805160206142808339815191526117b38161183c565b1580156117c757506117c5600061183c565b155b6117e35760405162461bcd60e51b8152600401610b4990613dc1565b6117ec33611c71565b6117f68585612a60565b7f6ab368f832c266c8eb942b84fbcaa20aedc24a699d2a05fae2568028733b1d0933868660405161182993929190613f77565b60405180910390a1506001949350505050565b600090815260c9602052604090205460ff1690565b610166546000906001600160a01b0316331461186c57600080fd5b600080838060200190518101906118839190613f9b565b91509150806000036118c65760405162461bcd60e51b815260206004820152600c60248201526b1e995c9bc818da185a5b925960a21b6044820152606401610b49565b6001600160a01b0382166118da57856118dc565b815b6101305460405163bf40fac160e01b815260206004820152601160248201527026aaa62a24a1a420a4a72fa927aaaa22a960791b60448201529193506001600160a01b03169063bf40fac190606401602060405180830381865afa158015611948573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061196c9190613e87565b60405163241dc2df60e01b81523060048201526001600160a01b0384811660248301526044820188905260648201849052919091169063241dc2df90608401600060405180830381600087803b1580156119c557600080fd5b505af11580156119d9573d6000803e3d6000fd5b5060019998505050505050505050565b604080518082019091526000805160206142a08339815191528152600060208201819052611a18908290610f8e565b80611a295750611a29816001610f8e565b611a455760405162461bcd60e51b8152600401610b4990613eba565b611a54888888888888886127b2565b5050505050505050565b6000818152609760205260408120610a6990612d93565b611a7e82610f2d565b611a8781611c67565b610f5e8383612557565b6101305460405163bf40fac160e01b815260206004820152600a60248201526923a7a7a22227a62620a960b11b60448201526000916001600160a01b03169063bf40fac190606401602060405180830381865afa158015611af6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ae29190613e87565b604080518082019091526000805160206142a08339815191528152600060208201819052611b49908290610f8e565b80611b5a5750611b5a816001610f8e565b611b765760405162461bcd60e51b8152600401610b4990613eba565b610fcf82612d9d565b604080518082019091526000805160206142a08339815191528152600060208201819052611bae908290610f8e565b80611bbf5750611bbf816001610f8e565b611bdb5760405162461bcd60e51b8152600401610b4990613eba565b61016880546001600160801b03808516600160801b0291161790556040517f5497ec04d2873f2e2d376db2bb24e7e57851278c75fc1fcc9aab4db5fb70d22390611c2690849061398e565b60405180910390a15050565b60006001600160e01b03198216637965db0b60e01b1480610a6957506301ffc9a760e01b6001600160e01b0319831614610a69565b6111818133612e22565b6001600160a01b03811660009081526101636020526040812060040154611ca1906001600160801b031642613e41565b9050600061016660009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611cf9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d1d9190613e28565b61016854909150600160801b90046001600160801b03168210611e33576001600160a01b0383166000908152610163602052604090206005015461271090611d6b9063ffffffff1683613fc9565b611d759190613ffe565b6001600160a01b03841660009081526101636020908152604080832060030180546001600160801b0319166001600160801b03959095169490941790935561016a9052206004015461271090611dd19063ffffffff1683613fc9565b611ddb9190613ffe565b6001600160a01b038416600090815261016a6020908152604080832060030180546001600160801b03199081166001600160801b03968716179091556101639092529091206004018054909116429092169190911790555b611e3b612e7b565b6001600160a01b03831660009081526101636020526040902060050154610168546001600160801b03908116600160201b9092041614610f5e5750506001600160a01b0316600090815261016360208181526040808420600380820180546001600160801b0390811690915561016a855292909520909401805482169055610168549290915260059092018054600160201b600160a01b03191691909216600160201b02179055565b6000818310611ef35781611704565b5090919050565b600080516020614154833981519152611f128161183c565b158015611f265750611f24600061183c565b155b611f425760405162461bcd60e51b8152600401610b4990613dc1565b306001600160a01b03841603611f895760405162461bcd60e51b815260206004820152600c60248201526b36b4b73a103a379039b2b63360a11b6044820152606401610b49565b33600090815261016360205260409020541580611fb6575033600090815261016360205260409020548211155b611ff85760405162461bcd60e51b81526020600482015260136024820152721b5a5b9d195c881b585e08195e18d959591959606a1b6044820152606401610b49565b33600090815261016360205260409020600301546001600160801b0316158061206b5750336000908152610163602052604090206003015461204b908390600160801b90046001600160801b0316613e54565b33600090815261016360205260409020600301546001600160801b031610155b6120b35760405162461bcd60e51b81526020600482015260196024820152781b5a5b9d195c8819185a5b1e4818d85c08195e18d959591959603a1b6044820152606401610b49565b3360009081526101636020526040902060030180548391906010906120e9908490600160801b90046001600160801b0316613e67565b92506101000a8154816001600160801b0302191690836001600160801b03160217905550816101636000336001600160a01b03166001600160a01b0316815260200190815260200160002060020160008282546121469190613e54565b909155505033600090815261016360205260409020600101541580612184575033600090815261016360205260409020600181015460029091015411155b6121a05760405162461bcd60e51b8152600401610b4990614012565b8161016560008282546121b39190613e54565b909155505033600090815261016a602052604090206002015482116122005733600090815261016a6020526040812060020180548492906121f5908490613e41565b909155506122159050565b33600090815261016a60205260408120600201555b61012e5461012f54604051633203f21960e11b8152600481018590526001600160a01b03868116602483015291821660448201526000929190911690636407e432906064016020604051808303816000875af1158015612279573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061229d919061403f565b9050806122da5760405162461bcd60e51b815260206004820152600b60248201526a1b5a5b9d0819985a5b195960aa1b6044820152606401610b49565b50505050565b610f5e8363a9059cbb60e01b84846040516024016122ff92919061405c565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612eab565b61016954610166546040516370a0823160e01b81526000926123c4926001600160801b03909116916001600160a01b03909116906370a082319061237e903090600401613a49565b602060405180830381865afa15801561239b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123bf9190613e28565b611ee4565b905080156111815761016980548291906000906123eb9084906001600160801b0316613e08565b92506101000a8154816001600160801b0302191690836001600160801b031602179055508061016560008282546124229190613e41565b909155505061016654604051630852cd8d60e31b8152600481018390526001600160a01b03909116906342966c6890602401600060405180830381600087803b15801561246e57600080fd5b505af1158015612482573d6000803e3d6000fd5b5050505050565b6124938282612f7d565b6000828152609760205260409020610f5e9082613003565b806124b58161183c565b806124c557506124c5600061183c565b61250f5760405162461bcd60e51b815260206004820152601b60248201527a14185d5cd8589b1950dbdb9d1c9bdb0e881b9bdd081c185d5cd959602a1b6044820152606401610b49565b600082815260c9602052604090819020805460ff19169055517fd05bfc2250abb0f8fd265a54c53a24359c5484af63cad2e4ce87c78ab751395a90611c269084815260200190565b6125618282613018565b6000828152609760205260409020610f5e908261307f565b6000805160206141b4833981519152546001600160a01b031690565b611181613094565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156125d057610f5e83613158565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801561262a575060408051601f3d908101601f1916820190925261262791810190613e28565b60015b61268d5760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608401610b49565b6000805160206141b483398151915281146126fc5760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401610b49565b50610f5e8383836131f2565b6001600160a01b03163b151590565b600054610100900460ff166127825760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610b49565b565b61013080546001600160a01b0319166001600160a01b038316179055611181610e03565b610fcf8282612489565b6001600160a01b03871660009081526101636020908152604080832061016a90925282206004820154919290916001600160801b03161515906128036000805160206141f98339815191528c61170b565b600185018b905589855560058501805463ffffffff191663ffffffff8b16908117909155600480870180546001600160801b031916426001600160801b031617905561016654604080516318160ddd60e01b81529051949550612710946001600160a01b03909216926318160ddd9282820192602092908290030181865afa158015612893573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128b79190613e28565b6128c19190613fc9565b6128cb9190614075565b8460030160006101000a8154816001600160801b0302191690836001600160801b031602179055506127108563ffffffff1661016660009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612951573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129759190613e28565b61297f9190613fc9565b6129899190614075565b6003840180546001600160801b0319166001600160801b03929092169190911790556001830187905585835560048301805463ffffffff191663ffffffff878116918217909255604080516001600160a01b038f168152602081018e90529081018c9052918a1660608301526080820189905260a0820188905260c082015281151560e08201528215156101008201527f58c3ceb7d4f068706ddc92911fae8701fac2c91c60bcc1b56ec7a6f56001aa5e906101200160405180910390a15050505050505050505050565b60006117048383613217565b600080516020614219833981519152612a788161183c565b158015612a8c5750612a8a600061183c565b155b612aa85760405162461bcd60e51b8152600401610b4990613dc1565b33600090815261016a60205260409020541580612ad5575033600090815261016a60205260409020548211155b612b1c5760405162461bcd60e51b81526020600482015260186024820152771b5a5b9d195c88189d5c9b881b585e08195e18d95959195960421b6044820152606401610b49565b33600090815261016a60205260409020600301546001600160801b03161580612b8f575033600090815261016a6020526040902060030154612b6f908390600160801b90046001600160801b0316613e54565b33600090815261016a60205260409020600301546001600160801b031610155b612bdb5760405162461bcd60e51b815260206004820152601e60248201527f6d696e746572206275726e206461696c792063617020657863656564656400006044820152606401610b49565b33600090815261016a602052604090206003018054839190601090612c11908490600160801b90046001600160801b0316613e67565b92506101000a8154816001600160801b0302191690836001600160801b031602179055508161016a6000336001600160a01b03166001600160a01b031681526020019081526020016000206002016000828254612c6e9190613e54565b909155505033600090815261016a60205260409020600101541580612cac575033600090815261016a60205260409020600181015460029091015411155b612cc85760405162461bcd60e51b8152600401610b4990614012565b816101655410612cf057816101656000828254612ce59190613e41565b90915550612cf79050565b6000610165555b33600090815261016360205260409020600201548211612d3f57336000908152610163602052604081206002018054849290612d34908490613e41565b90915550612d549050565b33600090815261016360205260408120600201555b306001600160a01b03841603612d7b5761016654610f5e906001600160a01b031683613241565b61016654610f5e906001600160a01b0316848461328e565b6000610a69825490565b80612da78161183c565b158015612dbb5750612db9600061183c565b155b612dd75760405162461bcd60e51b8152600401610b4990613dc1565b600082815260c9602052604090819020805460ff19166001179055517f0cb09dc71d57eeec2046f6854976717e4874a3cf2d6ddeddde337e5b6de6ba3190611c269084815260200190565b612e2c828261170b565b610fcf57612e39816132aa565b612e448360206132bc565b604051602001612e5592919061409b565b60408051601f198184030181529082905262461bcd60e51b8252610b499160040161395b565b612e886201518042613ffe565b61016880546001600160801b0319166001600160801b0392909216919091179055565b6000612f00826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166134579092919063ffffffff16565b805190915015610f5e5780806020019051810190612f1e919061403f565b610f5e5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610b49565b612f87828261170b565b610fcf5760008281526065602090815260408083206001600160a01b03851684529091529020805460ff19166001179055612fbf3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000611704836001600160a01b03841661346e565b613022828261170b565b15610fcf5760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000611704836001600160a01b0384166134bd565b61012e5460408051632d77bef360e11b8152905133926001600160a01b031691635aef7de69160048083019260209291908290030181865afa1580156130de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131029190613e87565b6001600160a01b0316146127825760405162461bcd60e51b815260206004820181905260248201527f6f6e6c79206176617461722063616e2063616c6c2074686973206d6574686f646044820152606401610b49565b61316181612708565b6131c35760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610b49565b6000805160206141b483398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6131fb836135b0565b6000825111806132085750805b15610f5e576122da83836135f0565b600082600001828154811061322e5761322e613ea4565b9060005260206000200154905092915050565b610fcf826342966c688360405160240161325d91815260200190565b6040516020818303038152906040529060e01b6020820180516001600160e01b0383818316178352505050506136e2565b610f5e836379cc6790848460405160240161325d92919061405c565b6060610a696001600160a01b03831660145b606060006132cb836002613fc9565b6132d6906002613e54565b6001600160401b038111156132ed576132ed613a8b565b6040519080825280601f01601f191660200182016040528015613317576020820181803683370190505b509050600360fc1b8160008151811061333257613332613ea4565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061336157613361613ea4565b60200101906001600160f81b031916908160001a9053506000613385846002613fc9565b613390906001613e54565b90505b6001811115613408576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106133c4576133c4613ea4565b1a60f81b8282815181106133da576133da613ea4565b60200101906001600160f81b031916908160001a90535060049490941c936134018161410a565b9050613393565b5083156117045760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610b49565b6060613466848460008561377c565b949350505050565b60008181526001830160205260408120546134b557508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610a69565b506000610a69565b600081815260018301602052604081205480156135a65760006134e1600183613e41565b85549091506000906134f590600190613e41565b905081811461355a57600086600001828154811061351557613515613ea4565b906000526020600020015490508087600001848154811061353857613538613ea4565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061356b5761356b614121565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610a69565b6000915050610a69565b6135b981613158565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606135fb83612708565b6136565760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610b49565b600080846001600160a01b0316846040516136719190614137565b600060405180830381855af49150503d80600081146136ac576040519150601f19603f3d011682016040523d82523d6000602084013e6136b1565b606091505b50915091506136d9828260405180606001604052806027815260200161423960279139613857565b95945050505050565b6000613712826040518060600160405280602581526020016141d4602591396001600160a01b0386169190613457565b805190915015610f5e5780806020019051810190613730919061403f565b610f5e5760405162461bcd60e51b815260206004820152601f60248201527f546f6b656e4f7065726174696f6e3a20646964206e6f742073756363656564006044820152606401610b49565b6060824710156137dd5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610b49565b600080866001600160a01b031685876040516137f99190614137565b60006040518083038185875af1925050503d8060008114613836576040519150601f19603f3d011682016040523d82523d6000602084013e61383b565b606091505b509150915061384c87838387613870565b979650505050505050565b60608315613866575081611704565b61170483836138e3565b606083156138dd5782516000036138d65761388a85612708565b6138d65760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610b49565b5081613466565b61346683835b8151156138f35781518083602001fd5b8060405162461bcd60e51b8152600401610b49919061395b565b60006020828403121561391f57600080fd5b81356001600160e01b03198116811461170457600080fd5b60005b8381101561395257818101518382015260200161393a565b50506000910152565b602081526000825180602084015261397a816040850160208701613937565b601f01601f19169190910160400192915050565b6001600160801b0391909116815260200190565b6001600160a01b038116811461118157600080fd5b600080604083850312156139ca57600080fd5b82356139d5816139a2565b946020939093013593505050565b6000602082840312156139f557600080fd5b5035919050565b60008060408385031215613a0f57600080fd5b823591506020830135613a21816139a2565b809150509250929050565b600060208284031215613a3e57600080fd5b8135611704816139a2565b6001600160a01b0391909116815260200190565b60008060408385031215613a7057600080fd5b8235613a7b816139a2565b91506020830135613a21816139a2565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715613ac957613ac9613a8b565b604052919050565b60006001600160401b03821115613aea57613aea613a8b565b50601f01601f191660200190565b600082601f830112613b0957600080fd5b8135613b1c613b1782613ad1565b613aa1565b818152846020838601011115613b3157600080fd5b816020850160208301376000918101602001919091529392505050565b60008060408385031215613b6157600080fd5b8235613b6c816139a2565b915060208301356001600160401b03811115613b8757600080fd5b613b9385828601613af8565b9150509250929050565b803563ffffffff81168114613bb157600080fd5b919050565b801515811461118157600080fd5b600080600080600080600080610100898b031215613be157600080fd5b8835613bec816139a2565b97506020890135965060408901359550613c0860608a01613b9d565b94506080890135935060a08901359250613c2460c08a01613b9d565b915060e0890135613c3481613bb6565b809150509295985092959890939650565b60008060408385031215613c5857600080fd5b50508035926020909101359150565b600080600060608486031215613c7c57600080fd5b8335613c87816139a2565b92506020840135915060408401356001600160401b03811115613ca957600080fd5b613cb586828701613af8565b9150509250925092565b600080600080600080600060e0888a031215613cda57600080fd5b8735613ce5816139a2565b96506020880135955060408801359450613d0160608901613b9d565b93506080880135925060a08801359150613d1d60c08901613b9d565b905092959891949750929550565b600060208284031215613d3d57600080fd5b81356001600160801b038116811461170457600080fd5b600060208284031215613d6657600080fd5b81516001600160401b03811115613d7c57600080fd5b8201601f81018413613d8d57600080fd5b8051613d9b613b1782613ad1565b818152856020838501011115613db057600080fd5b6136d9826020830160208601613937565b60208082526017908201527614185d5cd8589b1950dbdb9d1c9bdb0e881c185d5cd959604a1b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6001600160801b038281168282160390808211156111f1576111f1613df2565b600060208284031215613e3a57600080fd5b5051919050565b81810381811115610a6957610a69613df2565b80820180821115610a6957610a69613df2565b6001600160801b038181168382160190808211156111f1576111f1613df2565b600060208284031215613e9957600080fd5b8151611704816139a2565b634e487b7160e01b600052603260045260246000fd5b6020808252600c908201526b726f6c65206d697373696e6760a01b604082015260600190565b600060208284031215613ef257600080fd5b815160ff8116811461170457600080fd5b6020808252602c9082015260008051602061419483398151915260408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c9082015260008051602061419483398151915260408201526b6163746976652070726f787960a01b606082015260800190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b60008060408385031215613fae57600080fd5b8251613fb9816139a2565b6020939093015192949293505050565b6000816000190483118215151615613fe357613fe3613df2565b500290565b634e487b7160e01b600052601260045260246000fd5b60008261400d5761400d613fe8565b500490565b6020808252601390820152721b5a5b9d195c8818d85c08195e18d959591959606a1b604082015260600190565b60006020828403121561405157600080fd5b815161170481613bb6565b6001600160a01b03929092168252602082015260400190565b60006001600160801b038381168061408f5761408f613fe8565b92169190910492915050565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b8152600083516140cd816017850160208801613937565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516140fe816028840160208801613937565b01602801949350505050565b60008161411957614119613df2565b506000190190565b634e487b7160e01b600052603160045260246000fd5b60008251614149818460208701613937565b919091019291505056feb2a18ae5d0b623b41098012c516d0bf4bef38c068c9e397da870c290888b19999604fa49b1cb3aa782c099225b9c340b6afeb802be5d4b3314ba27a14502cdfa46756e6374696f6e206d7573742062652063616c6c6564207468726f75676820360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546f6b656e4f7065726174696f6e3a206c6f772d6c6576656c2063616c6c206661696c65645407862f04286ebe607684514c14b7fffc750b6bf52ba44ea49569174845a5bd62d52416825983abd68b16e092b60c2eac31fd673bcce92494e063af530d9c30416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c65649f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6b601d6a8ea5419a4251765936e52b2763485fede82d3c5dfd765cd67d30f4f2255435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a5041a264697066735822122080fba124231a2b3040b17593b1b6f31533318c5ba4b4a2a90070bb60a841b13b64736f6c63430008100033