More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 1,004 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Create Token | 21827309 | 22 hrs ago | IN | 0.002 ETH | 0.01148606 | ||||
Burn | 21806178 | 3 days ago | IN | 0 ETH | 0.0018609 | ||||
Update Bond Crea... | 21806091 | 3 days ago | IN | 0 ETH | 0.00002706 | ||||
Update Bond Crea... | 21806083 | 3 days ago | IN | 0 ETH | 0.0000269 | ||||
Update Bond Crea... | 21805294 | 4 days ago | IN | 0 ETH | 0.00002637 | ||||
Update Bond Crea... | 21805286 | 4 days ago | IN | 0 ETH | 0.00002423 | ||||
Update Bond Crea... | 21805009 | 4 days ago | IN | 0 ETH | 0.0000377 | ||||
Create Token | 21804910 | 4 days ago | IN | 0.002 ETH | 0.00049444 | ||||
Update Bond Crea... | 21799592 | 4 days ago | IN | 0 ETH | 0.00002662 | ||||
Create Multi Tok... | 21791125 | 5 days ago | IN | 0.002 ETH | 0.00038972 | ||||
Create Multi Tok... | 21791103 | 6 days ago | IN | 0.002 ETH | 0.00005573 | ||||
Create Multi Tok... | 21791097 | 6 days ago | IN | 0.002 ETH | 0.00038926 | ||||
Create Multi Tok... | 21791043 | 6 days ago | IN | 0.002 ETH | 0.00041506 | ||||
Create Token | 21791009 | 6 days ago | IN | 0.002 ETH | 0.00033793 | ||||
Burn | 21783348 | 7 days ago | IN | 0 ETH | 0.00017945 | ||||
Mint | 21778263 | 7 days ago | IN | 0 ETH | 0.00047419 | ||||
Burn | 21776984 | 7 days ago | IN | 0 ETH | 0.00070627 | ||||
Mint | 21774123 | 8 days ago | IN | 0 ETH | 0.00107426 | ||||
Mint | 21771579 | 8 days ago | IN | 0 ETH | 0.000502 | ||||
Mint | 21752894 | 11 days ago | IN | 0 ETH | 0.00143422 | ||||
Burn | 21744796 | 12 days ago | IN | 0 ETH | 0.00150277 | ||||
Mint | 21737805 | 13 days ago | IN | 0 ETH | 0.00219677 | ||||
Mint | 21733468 | 14 days ago | IN | 0 ETH | 0.00112291 | ||||
Burn | 21728726 | 14 days ago | IN | 0 ETH | 0.00104373 | ||||
Create Token | 21726894 | 14 days ago | IN | 0.002 ETH | 0.00096802 |
Latest 25 internal transactions (View All)
Advanced mode:
Parent Transaction Hash | Block |
From
|
To
|
|||
---|---|---|---|---|---|---|
21827309 | 22 hrs ago | 0.002 ETH | ||||
21827309 | 22 hrs ago | Contract Creation | 0 ETH | |||
21804910 | 4 days ago | 0.002 ETH | ||||
21804910 | 4 days ago | Contract Creation | 0 ETH | |||
21791125 | 5 days ago | 0.002 ETH | ||||
21791125 | 5 days ago | Contract Creation | 0 ETH | |||
21791097 | 6 days ago | 0.002 ETH | ||||
21791097 | 6 days ago | Contract Creation | 0 ETH | |||
21791043 | 6 days ago | 0.002 ETH | ||||
21791043 | 6 days ago | Contract Creation | 0 ETH | |||
21791009 | 6 days ago | 0.002 ETH | ||||
21791009 | 6 days ago | Contract Creation | 0 ETH | |||
21726894 | 14 days ago | 0.002 ETH | ||||
21726894 | 14 days ago | Contract Creation | 0 ETH | |||
21640593 | 27 days ago | 0.002 ETH | ||||
21640593 | 27 days ago | Contract Creation | 0 ETH | |||
21640495 | 27 days ago | 0.002 ETH | ||||
21640495 | 27 days ago | Contract Creation | 0 ETH | |||
21640352 | 27 days ago | 0.002 ETH | ||||
21640352 | 27 days ago | Contract Creation | 0 ETH | |||
21554343 | 39 days ago | 0.002 ETH | ||||
21554343 | 39 days ago | Contract Creation | 0 ETH | |||
21541267 | 40 days ago | 0.002 ETH | ||||
21541267 | 40 days ago | Contract Creation | 0 ETH | |||
21540733 | 40 days ago | 0.002 ETH |
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Source Code Verified (Exact Match)
Contract Name:
MCV2_Bond
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 50000 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BSD-3-Clause pragma solidity =0.8.20; import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {MCV2_Royalty} from "./MCV2_Royalty.sol"; import {MCV2_Token} from "./MCV2_Token.sol"; import {MCV2_MultiToken} from "./MCV2_MultiToken.sol"; import {MCV2_ICommonToken} from "./interfaces/MCV2_ICommonToken.sol"; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol"; /** * @title MintClub Bond V2 * @dev Providing liquidity for MintClubV2 tokens with a bonding curve. */ contract MCV2_Bond is MCV2_Royalty { using SafeERC20 for IERC20; using SafeCast for uint256; // Error messages error MCV2_Bond__InvalidConstructorParams(string reason); error MCV2_Bond__InvalidTokenCreationParams(string reason); error MCV2_Bond__InvalidReserveToken(string reason); error MCV2_Bond__InvalidStepParams(string reason); error MCV2_Bond__TokenSymbolAlreadyExists(); error MCV2_Bond__TokenNotFound(); error MCV2_Bond__ExceedMaxSupply(); error MCV2_Bond__SlippageLimitExceeded(); error MCV2_Bond__InvalidTokenAmount(); error MCV2_Bond__ExceedTotalSupply(); error MCV2_Bond__InvalidCurrentSupply(); error MCV2_Bond__PermissionDenied(); error MCV2_Bond__InvalidCreatorAddress(); error MCV2_BOND__InvalidPaginationParameters(); error MCV2_Bond__InvalidReceiver(); error MCV2_Bond__InvalidCreationFee(); error MCV2_Bond__CreationFeeTransactionFailed(); uint256 private constant MIN_UINT8_LENGTH = 31; // uint8 = 32 bits uint256 private constant MIN_STRING_LENGTH = 95; // empty string = 64 bits, 1 character = 96 bits uint256 private immutable MAX_STEPS; /** * @dev ERC20 Token implementation contract * We use "EIP-1167: Minimal Proxy Contract" in order to save gas cost for each token deployment * REF: https://github.com/optionality/clone-factory */ address private immutable TOKEN_IMPLEMENTATION; address private immutable MULTI_TOKEN_IMPLEMENTATION; struct Bond { address creator; uint16 mintRoyalty; // immutable uint16 burnRoyalty; // immutable uint40 createdAt; // immutable address reserveToken; // immutable uint256 reserveBalance; BondStep[] steps; // immutable } // Use uint128 to save storage cost & prevent integer overflow when calculating range * price struct BondStep { uint128 rangeTo; uint128 price; // multiplied by 10**18 for decimals } mapping (address => Bond) public tokenBond; address[] public tokens; // Array of all created tokens event TokenCreated(address indexed token, string name, string symbol, address indexed reserveToken); event MultiTokenCreated(address indexed token, string name, string symbol, string uri, address indexed reserveToken); event Mint(address indexed token, address indexed user, address receiver, uint256 amountMinted, address indexed reserveToken, uint256 reserveAmount); event Burn(address indexed token, address indexed user, address receiver, uint256 amountBurned, address indexed reserveToken, uint256 refundAmount); event BondCreatorUpdated(address indexed token, address indexed creator); // MARK: - Constructor /** * @dev Initializes the MCV2_Bond contract. * @param tokenImplementation The address of the token implementation contract. * @param multiTokenImplementation The address of the multi-token implementation contract. * @param protocolBeneficiary_ The address of the protocol beneficiary. * @param maxSteps The maximum number of steps allowed in a bond. */ constructor( address tokenImplementation, address multiTokenImplementation, address protocolBeneficiary_, uint256 creationFee_, uint256 maxSteps ) MCV2_Royalty(protocolBeneficiary_, creationFee_, msg.sender) { if (tokenImplementation == address(0)) revert MCV2_Bond__InvalidConstructorParams('tokenImplementation'); if (multiTokenImplementation == address(0)) revert MCV2_Bond__InvalidConstructorParams('multiTokenImplementation'); if (protocolBeneficiary_ == address(0)) revert MCV2_Bond__InvalidConstructorParams('protocolBeneficiary'); if (maxSteps == 0) revert MCV2_Bond__InvalidConstructorParams('maxSteps'); TOKEN_IMPLEMENTATION = tokenImplementation; MULTI_TOKEN_IMPLEMENTATION = multiTokenImplementation; MAX_STEPS = maxSteps; } modifier _checkBondExists(address token) { if(tokenBond[token].reserveToken == address(0)) revert MCV2_Bond__TokenNotFound(); _; } // MARK: - Factory // Use structs to avoid stack too deep error struct TokenParams { string name; string symbol; } struct MultiTokenParams { string name; string symbol; string uri; } struct BondParams { uint16 mintRoyalty; uint16 burnRoyalty; address reserveToken; uint128 maxSupply; uint128[] stepRanges; uint128[] stepPrices; } /** * @dev Validates the token creation parameters. * @param tp The token parameters. */ function _validateTokenParams(TokenParams calldata tp) pure private { if (bytes(tp.name).length == 0) revert MCV2_Bond__InvalidTokenCreationParams('name'); if (bytes(tp.symbol).length == 0) revert MCV2_Bond__InvalidTokenCreationParams('symbol'); } /** * @dev Validates the multi-token creation parameters. * @param tp The multi-token parameters. */ function _validateMultiTokenParams(MultiTokenParams calldata tp) pure private { if (bytes(tp.name).length == 0) revert MCV2_Bond__InvalidTokenCreationParams('name'); if (bytes(tp.symbol).length == 0) revert MCV2_Bond__InvalidTokenCreationParams('symbol'); if (bytes(tp.uri).length == 0) revert MCV2_Bond__InvalidTokenCreationParams('uri'); } /** * @dev Checks if the contract has the method with the minimum length of the return data. * @param implementation The address of the contract implementation. * @param method The name of the method to check. * @param minLength The minimum length of the return data. * @return A boolean indicating whether the method exists. */ function _checkMethodExists(address implementation, string memory method, uint256 minLength) private view returns (bool) { (bool success, bytes memory data) = implementation.staticcall(abi.encodeWithSignature(method)); return success && data.length > minLength; } /** * @dev Validates the bond parameters. * @param bp The bond parameters. */ function _validateBondParams(BondParams calldata bp) view private { if (bp.mintRoyalty > maxRoyaltyRange) revert MCV2_Bond__InvalidTokenCreationParams('mintRoyalty'); if (bp.burnRoyalty > maxRoyaltyRange) revert MCV2_Bond__InvalidTokenCreationParams('burnRoyalty'); // Check if the reserveToken is compatible with IERC20Metadata address r = bp.reserveToken; if (r == address(0)) revert MCV2_Bond__InvalidTokenCreationParams('reserveToken'); if(!_checkMethodExists(r, "decimals()", MIN_UINT8_LENGTH)) revert MCV2_Bond__InvalidReserveToken('decimals'); if(!_checkMethodExists(r, "name()", MIN_STRING_LENGTH)) revert MCV2_Bond__InvalidReserveToken('name'); if(!_checkMethodExists(r, "symbol()", MIN_STRING_LENGTH)) revert MCV2_Bond__InvalidReserveToken('symbol'); if (bp.maxSupply == 0) revert MCV2_Bond__InvalidTokenCreationParams('maxSupply'); if (bp.stepRanges.length == 0 || bp.stepRanges.length > MAX_STEPS) revert MCV2_Bond__InvalidStepParams('INVALID_STEP_LENGTH'); if (bp.stepRanges.length != bp.stepPrices.length) revert MCV2_Bond__InvalidStepParams('STEP_LENGTH_DO_NOT_MATCH'); // Last value or the rangeTo must be the same as the maxSupply if (bp.stepRanges[bp.stepRanges.length - 1] != bp.maxSupply) revert MCV2_Bond__InvalidStepParams('MAX_SUPPLY_MISMATCH'); } /** * @dev Sets the bond parameters for a token. * @param token The address of the token. * @param bp The bond parameters. */ function _setBond(address token, BondParams calldata bp) private { // Set token bond data Bond storage bond = tokenBond[token]; bond.creator = _msgSender(); bond.mintRoyalty = bp.mintRoyalty; bond.burnRoyalty = bp.burnRoyalty; bond.createdAt = uint40(block.timestamp); bond.reserveToken = bp.reserveToken; uint256 multiFactor = 10**IERC20Metadata(token).decimals(); for (uint256 i = 0; i < bp.stepRanges.length; ++i) { uint256 stepRange = bp.stepRanges[i]; uint256 stepPrice = bp.stepPrices[i]; if (stepRange == 0) { revert MCV2_Bond__InvalidStepParams('STEP_CANNOT_BE_ZERO'); } else if (stepPrice > 0 && stepRange * stepPrice < multiFactor) { // To minimize rounding errors, the product of the range and price must be at least multiFactor (1e18 for ERC20, 1 for ERC1155). revert MCV2_Bond__InvalidStepParams('STEP_RANG_OR_PRICE_TOO_SMALL'); } // Ranges and prices must be strictly increasing if (i > 0) { if (stepRange <= bp.stepRanges[i - 1]) revert MCV2_Bond__InvalidStepParams('DECREASING_RANGE'); if (stepPrice <= bp.stepPrices[i - 1]) revert MCV2_Bond__InvalidStepParams('DECREASING_PRICE'); } bond.steps.push(BondStep({ rangeTo: uint128(stepRange), price: uint128(stepPrice) })); } } /** * @dev Clones the implementation contract with a unique symbol. * @param implementation The address of the implementation contract. * @param symbol The symbol of the token. * @return The address of the cloned token contract. */ function _clone(address implementation, string calldata symbol) private returns (address) { // Uniqueness of symbols on this network is guaranteed by the deterministic contract address bytes32 salt = keccak256(abi.encodePacked(address(this), symbol)); // NOTE: This check might not be necessary as the clone would fail with an 'ERC1167: create2 failed' // error anyway, and the collision is nearly impossible (one in 2^160). // However, we retain this check to provide a clearer error message, albeit at the expense of an additional gas cost. address predicted = Clones.predictDeterministicAddress(implementation, salt); if (exists(predicted)) revert MCV2_Bond__TokenSymbolAlreadyExists(); return Clones.cloneDeterministic(implementation, salt); } /** * @dev Creates a new token with the given parameters. * @param tp The token parameters. * @param bp The bond parameters. * @return The address of the newly created token. */ function createToken(TokenParams calldata tp, BondParams calldata bp) external payable returns (address) { if (msg.value != creationFee) revert MCV2_Bond__InvalidCreationFee(); _validateTokenParams(tp); _validateBondParams(bp); address token = _clone(TOKEN_IMPLEMENTATION, tp.symbol); MCV2_Token newToken = MCV2_Token(token); newToken.init(tp.name, tp.symbol); tokens.push(token); _setBond(token, bp); emit TokenCreated(token, tp.name, tp.symbol, bp.reserveToken); // Send free tokens to the creator if a free minting range exists if (bp.stepPrices[0] == 0) { newToken.mintByBond(_msgSender(), bp.stepRanges[0]); } // Collect creation fee if exists if (creationFee > 0) { (bool success, ) = payable(protocolBeneficiary).call{value: creationFee}(""); if (!success) revert MCV2_Bond__CreationFeeTransactionFailed(); } return token; } /** * @dev Creates a new multi-token with the given parameters. * @param tp The multi-token parameters. * @param bp The bond parameters. * @return The address of the newly created multi-token. */ function createMultiToken(MultiTokenParams calldata tp, BondParams calldata bp) external payable returns (address) { if (msg.value != creationFee) revert MCV2_Bond__InvalidCreationFee(); _validateMultiTokenParams(tp); _validateBondParams(bp); address token = _clone(MULTI_TOKEN_IMPLEMENTATION, tp.symbol); MCV2_MultiToken newToken = MCV2_MultiToken(token); newToken.init(tp.name, tp.symbol, tp.uri); tokens.push(token); _setBond(token, bp); emit MultiTokenCreated(token, tp.name, tp.symbol, tp.uri, bp.reserveToken); // Send free tokens to the creator if a free minting range exists if (bp.stepPrices[0] == 0) { newToken.mintByBond(_msgSender(), bp.stepRanges[0]); } // Collect creation fee if exists if (creationFee > 0) { (bool success, ) = payable(protocolBeneficiary).call{value: creationFee}(""); if (!success) revert MCV2_Bond__CreationFeeTransactionFailed(); } return token; } // MARK: - Creator only functions /** * @dev Updates the bond creator address for a token. * @param token The address of the token. * @param creator The new creator address. */ function updateBondCreator(address token, address creator) external { Bond storage bond = tokenBond[token]; if (bond.creator != _msgSender()) revert MCV2_Bond__PermissionDenied(); // This will also check the existence of the bond // null address is not allowed, use dEaD address instead if (creator == address(0)) revert MCV2_Bond__InvalidCreatorAddress(); bond.creator = creator; emit BondCreatorUpdated(token, creator); } // MARK: - Mint /** * @dev Retrieves the current step for a given token and current supply. * @param token The address of the token. * @param currentSupply The current supply of the token. * @return The index of the current step. */ function getCurrentStep(address token, uint256 currentSupply) internal view returns (uint256) { Bond storage bond = tokenBond[token]; for(uint256 i = 0; i < bond.steps.length; ++i) { if (currentSupply <= bond.steps[i].rangeTo) { return i; } } revert MCV2_Bond__InvalidCurrentSupply(); // can never happen } /** * @dev Retrieves the reserve amount and royalty for a given token and the number of tokens to mint. * @param token The address of the token. * @param tokensToMint The number of tokens to mint. * @return reserveAmount The reserve amount required to mint the specified number of tokens. * @return royalty The royalty amount to be added to the reserve amount. */ function getReserveForToken(address token, uint256 tokensToMint) public view _checkBondExists(token) returns (uint256 reserveAmount, uint256 royalty) { if (tokensToMint == 0) revert MCV2_Bond__InvalidTokenAmount(); Bond memory bond = tokenBond[token]; // Create an array and variable to mention that this can be modified. BondStep[] memory steps = bond.steps; MCV2_ICommonToken t = MCV2_ICommonToken(token); uint256 currentSupply = t.totalSupply(); uint256 newSupply = currentSupply + tokensToMint; if (newSupply > maxSupply(token)) revert MCV2_Bond__ExceedMaxSupply(); uint256 multiFactor = 10**t.decimals(); // 1 or 18 uint256 tokensLeft = tokensToMint; uint256 reserveToBond = 0; uint256 supplyLeft; for (uint256 i = getCurrentStep(token, currentSupply); i < steps.length; ++i) { BondStep memory step = steps[i]; supplyLeft = step.rangeTo - currentSupply; if (supplyLeft < tokensLeft) { if(supplyLeft == 0) continue; // ensure reserve is calculated with ceiling reserveToBond += Math.ceilDiv(supplyLeft * step.price, multiFactor); currentSupply += supplyLeft; tokensLeft -= supplyLeft; } else { // ensure reserve is calculated with ceiling reserveToBond += Math.ceilDiv(tokensLeft * step.price, multiFactor); tokensLeft = 0; break; } } // tokensLeft > 0 -> can never happen // reserveToBond == 0 -> can happen if a user tries to mint within the free minting range, which is prohibited by design. if (reserveToBond == 0 || tokensLeft > 0) revert MCV2_Bond__InvalidTokenAmount(); royalty = _getRoyalty(reserveToBond, bond.mintRoyalty); reserveAmount = reserveToBond + royalty; } /** * @dev Mint new tokens by depositing reserve tokens. * @param token The address of the token to mint. * @param tokensToMint The amount of tokens to mint. * @param maxReserveAmount The maximum reserve amount allowed for the minting operation. * @param receiver The address to receive the minted tokens. */ function mint(address token, uint256 tokensToMint, uint256 maxReserveAmount, address receiver) external returns (uint256) { if (receiver == address(0)) revert MCV2_Bond__InvalidReceiver(); (uint256 reserveAmount, uint256 royalty) = getReserveForToken(token, tokensToMint); if (reserveAmount > maxReserveAmount) revert MCV2_Bond__SlippageLimitExceeded(); Bond storage bond = tokenBond[token]; address user = _msgSender(); IERC20 reserveToken = IERC20(bond.reserveToken); // Update reserve & fee balances bond.reserveBalance += reserveAmount - royalty; _addRoyalty(bond.creator, bond.reserveToken, royalty); // Mint reward tokens to the receiver MCV2_ICommonToken(token).mintByBond(receiver, tokensToMint); // Transfer reserve tokens from the user reserveToken.safeTransferFrom(user, address(this), reserveAmount); emit Mint(token, user, receiver, tokensToMint, bond.reserveToken, reserveAmount); return reserveAmount; } // MARK: - Burn /** * @dev Calculates the refund amount and royalty for a given amount of tokens to burn. * @param token The address of the token. * @param tokensToBurn The amount of tokens to burn. * @return refundAmount The amount to be refunded. * @return royalty The royalty amount. */ function getRefundForTokens(address token, uint256 tokensToBurn) public view _checkBondExists(token) returns (uint256 refundAmount, uint256 royalty) { if (tokensToBurn == 0) revert MCV2_Bond__InvalidTokenAmount(); Bond memory bond = tokenBond[token]; // Store bond.steps in memory to minimize sloads BondStep[] memory steps = bond.steps; MCV2_ICommonToken t = MCV2_ICommonToken(token); uint256 currentSupply = t.totalSupply(); if (tokensToBurn > currentSupply) revert MCV2_Bond__ExceedTotalSupply(); uint256 multiFactor = 10**t.decimals(); uint256 reserveFromBond; uint256 tokensLeft = tokensToBurn; uint256 i = getCurrentStep(token, currentSupply); while (tokensLeft > 0) { uint256 supplyLeft = i == 0 ? currentSupply : currentSupply - steps[i - 1].rangeTo; uint256 tokensToProcess = tokensLeft < supplyLeft ? tokensLeft : supplyLeft; reserveFromBond += ((tokensToProcess * steps[i].price) / multiFactor); tokensLeft -= tokensToProcess; currentSupply -= tokensToProcess; if (i > 0) --i; } // tokensLeft > 0 -> can never happen // reserveToBond == 0 -> can happen if a user tries to burn within the free minting range, which is prohibited by design. if (tokensLeft > 0) revert MCV2_Bond__InvalidTokenAmount(); royalty = _getRoyalty(reserveFromBond, bond.burnRoyalty); refundAmount = reserveFromBond - royalty; } /** * @dev Burns a specified amount of tokens and refunds the user with reserve tokens. * @param token The address of the token to burn. * @param tokensToBurn The amount of tokens to burn. * @param minRefund The minimum refund amount required. * @param receiver The address to receive the refund. */ function burn(address token, uint256 tokensToBurn, uint256 minRefund, address receiver) external returns (uint256) { if (receiver == address(0)) revert MCV2_Bond__InvalidReceiver(); (uint256 refundAmount, uint256 royalty) = getRefundForTokens(token, tokensToBurn); if (refundAmount < minRefund) revert MCV2_Bond__SlippageLimitExceeded(); Bond storage bond = tokenBond[token]; address user = _msgSender(); // Burn tokens from the user MCV2_ICommonToken(token).burnByBond(user, tokensToBurn); // Update reserve & fee balances bond.reserveBalance -= (refundAmount + royalty); _addRoyalty(bond.creator, bond.reserveToken, royalty); // Transfer reserve tokens to the receiver IERC20 reserveToken = IERC20(bond.reserveToken); reserveToken.safeTransfer(receiver, refundAmount); emit Burn(token, user, receiver, tokensToBurn, bond.reserveToken, refundAmount); return refundAmount; } // MARK: - Utility functions /** * @dev Returns the number of tokens in the bond. * @return The number of tokens in the bond. */ function tokenCount() external view returns (uint256) { return tokens.length; } /** * @dev Checks if a token exists in the bond. * @param token The address of the token to check. * @return True if the token exists in the bond, false otherwise. */ function exists(address token) public view returns (bool) { return tokenBond[token].reserveToken != address(0); } /** * @dev Returns the steps of a token in the bond. * @param token The address of the token. * @return The steps of the token in the bond. */ function getSteps(address token) external view returns (BondStep[] memory) { return tokenBond[token].steps; } /** * @dev Returns the price for the next mint of a token * @param token The address of the token. * @return The price at the next step of the bonding curve */ function priceForNextMint(address token) public view returns (uint128) { uint256 currentSupply = MCV2_ICommonToken(token).totalSupply(); if (currentSupply < maxSupply(token)) { ++currentSupply; // Ensure currentSupply is in the next range } uint256 i = getCurrentStep(token, currentSupply); return tokenBond[token].steps[i].price; } /** * @dev Returns the maximum supply of a token in the bond. * @param token The address of the token. * @return The maximum supply of the token in the bond. */ function maxSupply(address token) public view returns (uint128) { return tokenBond[token].steps[tokenBond[token].steps.length - 1].rangeTo; } struct BondInfo { address creator; address token; uint8 decimals; string symbol; string name; uint40 createdAt; uint128 currentSupply; uint128 maxSupply; uint128 priceForNextMint; address reserveToken; uint8 reserveDecimals; string reserveSymbol; string reserveName; uint256 reserveBalance; } function _getBondInfo(address token) private view returns(BondInfo memory info) { MCV2_ICommonToken t = MCV2_ICommonToken(token); Bond memory bond = tokenBond[token]; IERC20Metadata r = IERC20Metadata(bond.reserveToken); info = BondInfo({ creator: bond.creator, token: token, decimals: t.decimals(), symbol: t.symbol(), name: t.name(), createdAt: bond.createdAt, currentSupply: t.totalSupply().toUint128(), maxSupply: maxSupply(token), priceForNextMint: priceForNextMint(token), reserveToken: bond.reserveToken, reserveDecimals: r.decimals(), reserveSymbol: r.symbol(), reserveName: r.name(), reserveBalance: bond.reserveBalance }); } /** * @dev Get all tokens and their bond parameters in the range where start <= id < stop. * @param start The starting index of the range. * @param stop The ending index of the range. * @return info An array of BondInfo structs containing the bond parameters for each token in the range. */ function getList(uint256 start, uint256 stop) external view returns(BondInfo[] memory info) { if (start >= stop || stop - start > 1000) revert MCV2_BOND__InvalidPaginationParameters(); unchecked { uint256 tokensLength = tokens.length; if (stop > tokensLength) { stop = tokensLength; } uint256 arrayLength = stop - start; info = new BondInfo[](arrayLength); uint256 j; for (uint256 i = start; i < stop; ++i) { info[j++] = _getBondInfo(tokens[i]); } } } struct BondDetail { uint16 mintRoyalty; uint16 burnRoyalty; BondInfo info; BondStep[] steps; } /** * @dev Retrieves the details of a bond token. * @param token The address of the bond token. * @return detail The BondDetail struct containing the royalty, bond info, and steps of the bond token. */ function getDetail(address token) external view returns(BondDetail memory detail) { Bond memory bond = tokenBond[token]; detail = BondDetail({ mintRoyalty: bond.mintRoyalty, burnRoyalty: bond.burnRoyalty, info: _getBondInfo(token), steps: bond.steps }); } /** * @dev Get tokens filtered by reserve token in the range where start <= id < stop * @param reserveToken The address of the reserve token * @param start The starting index of the range * @param stop The ending index of the range * @return addresses An array of addresses representing the filtered tokens */ function getTokensByReserveToken(address reserveToken, uint256 start, uint256 stop) external view returns (address[] memory addresses) { if (start >= stop || stop - start > 10000) revert MCV2_BOND__InvalidPaginationParameters(); unchecked { uint256 tokensLength = tokens.length; if (stop > tokensLength) { stop = tokensLength; } uint256 count; for (uint256 i = start; i < stop; ++i) { if (tokenBond[tokens[i]].reserveToken == reserveToken) ++count; } addresses = new address[](count); uint256 j = 0; for (uint256 i = start; i < stop; ++i) { if (tokenBond[tokens[i]].reserveToken == reserveToken){ addresses[j++] = tokens[i]; if (j == count) break; } } } } /** * @dev Get tokens filtered by creator address in the range where start <= id < stop * @param creator The address of the token creator * @param start The starting index of the range * @param stop The ending index of the range (exclusive) * @return addresses An array of token addresses filtered by creator address */ function getTokensByCreator(address creator, uint256 start, uint256 stop) external view returns (address[] memory addresses) { if (start >= stop || stop - start > 10000) revert MCV2_BOND__InvalidPaginationParameters(); unchecked { uint256 tokensLength = tokens.length; if (stop > tokensLength) { stop = tokensLength; } uint256 count; for (uint256 i = start; i < stop; ++i) { if (tokenBond[tokens[i]].creator == creator) ++count; } addresses = new address[](count); uint256 j = 0; for (uint256 i = start; i < stop; ++i) { if (tokenBond[tokens[i]].creator == creator) { addresses[j++] = tokens[i]; if (j == count) break; } } } } function version() external pure returns (string memory) { return "0.1.120"; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {Context} from "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is set to the address provided by the deployer. This can * later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; /** * @dev The caller account is not authorized to perform an operation. */ error OwnableUnauthorizedAccount(address account); /** * @dev The owner is not a valid owner account. (eg. `address(0)`) */ error OwnableInvalidOwner(address owner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the address provided by the deployer as the initial owner. */ constructor(address initialOwner) { if (initialOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(initialOwner); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { if (owner() != _msgSender()) { revert OwnableUnauthorizedAccount(_msgSender()); } } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { if (newOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol) pragma solidity ^0.8.20; /** * @dev Standard ERC20 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens. */ interface IERC20Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC20InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC20InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers. * @param spender Address that may be allowed to operate on tokens without being their owner. * @param allowance Amount of tokens a `spender` is allowed to operate with. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC20InvalidApprover(address approver); /** * @dev Indicates a failure with the `spender` to be approved. Used in approvals. * @param spender Address that may be allowed to operate on tokens without being their owner. */ error ERC20InvalidSpender(address spender); } /** * @dev Standard ERC721 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens. */ interface IERC721Errors { /** * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20. * Used in balance queries. * @param owner Address of the current owner of a token. */ error ERC721InvalidOwner(address owner); /** * @dev Indicates a `tokenId` whose `owner` is the zero address. * @param tokenId Identifier number of a token. */ error ERC721NonexistentToken(uint256 tokenId); /** * @dev Indicates an error related to the ownership over a particular token. Used in transfers. * @param sender Address whose tokens are being transferred. * @param tokenId Identifier number of a token. * @param owner Address of the current owner of a token. */ error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC721InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC721InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param tokenId Identifier number of a token. */ error ERC721InsufficientApproval(address operator, uint256 tokenId); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC721InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC721InvalidOperator(address operator); } /** * @dev Standard ERC1155 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens. */ interface IERC1155Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. * @param tokenId Identifier number of a token. */ error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC1155InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC1155InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param owner Address of the current owner of a token. */ error ERC1155MissingApprovalForAll(address operator, address owner); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC1155InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC1155InvalidOperator(address operator); /** * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation. * Used in batch transfers. * @param idsLength Length of the array of token identifiers * @param valuesLength Length of the array of token amounts */ error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/Clones.sol) pragma solidity ^0.8.20; /** * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for * deploying minimal proxy contracts, also known as "clones". * * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies * > a minimal bytecode implementation that delegates all calls to a known, fixed address. * * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2` * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the * deterministic method. */ library Clones { /** * @dev A clone instance deployment failed. */ error ERC1167FailedCreateClone(); /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`. * * This function uses the create opcode, which should never revert. */ function clone(address implementation) internal returns (address instance) { /// @solidity memory-safe-assembly assembly { // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes // of the `implementation` address with the bytecode before the address. mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000)) // Packs the remaining 17 bytes of `implementation` with the bytecode after the address. mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3)) instance := create(0, 0x09, 0x37) } if (instance == address(0)) { revert ERC1167FailedCreateClone(); } } /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`. * * This function uses the create2 opcode and a `salt` to deterministically deploy * the clone. Using the same `implementation` and `salt` multiple time will revert, since * the clones cannot be deployed twice at the same address. */ function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) { /// @solidity memory-safe-assembly assembly { // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes // of the `implementation` address with the bytecode before the address. mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000)) // Packs the remaining 17 bytes of `implementation` with the bytecode after the address. mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3)) instance := create2(0, 0x09, 0x37, salt) } if (instance == address(0)) { revert ERC1167FailedCreateClone(); } } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress( address implementation, bytes32 salt, address deployer ) internal pure returns (address predicted) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(add(ptr, 0x38), deployer) mstore(add(ptr, 0x24), 0x5af43d82803e903d91602b57fd5bf3ff) mstore(add(ptr, 0x14), implementation) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73) mstore(add(ptr, 0x58), salt) mstore(add(ptr, 0x78), keccak256(add(ptr, 0x0c), 0x37)) predicted := keccak256(add(ptr, 0x43), 0x55) } } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress( address implementation, bytes32 salt ) internal view returns (address predicted) { return predictDeterministicAddress(implementation, salt, address(this)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/extensions/IERC1155MetadataURI.sol) pragma solidity ^0.8.20; import {IERC1155} from "../IERC1155.sol"; /** * @dev Interface of the optional ERC1155MetadataExtension interface, as defined * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. */ interface IERC1155MetadataURI is IERC1155 { /** * @dev Returns the URI for token type `id`. * * If the `\{id\}` substring is present in the URI, it must be replaced by * clients with the actual token type ID. */ function uri(uint256 id) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (token/ERC1155/IERC1155.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. */ interface IERC1155 is IERC165 { /** * @dev Emitted when `value` amount of tokens of type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the value of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch( address[] calldata accounts, uint256[] calldata ids ) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`. * * WARNING: This function can potentially allow a reentrancy attack when transferring tokens * to an untrusted contract, when invoking {onERC1155Received} on the receiver. * Ensure to follow the checks-effects-interactions pattern and consider employing * reentrancy guards when interacting with untrusted contracts. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `value` amount. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * WARNING: This function can potentially allow a reentrancy attack when transferring tokens * to an untrusted contract, when invoking {onERC1155BatchReceived} on the receiver. * Ensure to follow the checks-effects-interactions pattern and consider employing * reentrancy guards when interacting with untrusted contracts. * * Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments. * * Requirements: * * - `ids` and `values` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/IERC1155Receiver.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Interface that must be implemented by smart contracts in order to receive * ERC-1155 token transfers. */ interface IERC1155Receiver is IERC165 { /** * @dev Handles the receipt of a single ERC1155 token type. This function is * called at the end of a `safeTransferFrom` after the balance has been updated. * * NOTE: To accept the transfer, this must return * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` * (i.e. 0xf23a6e61, or its own function selector). * * @param operator The address which initiated the transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param id The ID of the token being transferred * @param value The amount of tokens being transferred * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4); /** * @dev Handles the receipt of a multiple ERC1155 token types. This function * is called at the end of a `safeBatchTransferFrom` after the balances have * been updated. * * NOTE: To accept the transfer(s), this must return * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` * (i.e. 0xbc197c81, or its own function selector). * * @param operator The address which initiated the batch transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param ids An array containing ids of each token being transferred (order and length must match values array) * @param values An array containing amounts of each token being transferred (order and length must match ids array) * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.20; /** * @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. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20Permit { /** * @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]. * * CAUTION: See Security Considerations above. */ 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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 value) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; import {IERC20Permit} from "../extensions/IERC20Permit.sol"; import {Address} from "../../../utils/Address.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 SafeERC20 { using Address for address; /** * @dev An operation with an ERC20 token failed. */ error SafeERC20FailedOperation(address token); /** * @dev Indicates a failed `decreaseAllowance` request. */ error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease); /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value))); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value))); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); forceApprove(token, spender, oldAllowance + value); } /** * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no * value, non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal { unchecked { uint256 currentAllowance = token.allowance(address(this), spender); if (currentAllowance < requestedDecrease) { revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease); } forceApprove(token, spender, currentAllowance - requestedDecrease); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value)); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0))); _callOptionalReturn(token, approvalCall); } } /** * @dev 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(IERC20 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); if (returndata.length != 0 && !abi.decode(returndata, (bool))) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // 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 cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol) pragma solidity ^0.8.20; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error AddressInsufficientBalance(address account); /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedInnerCall(); /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert AddressInsufficientBalance(address(this)); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert FailedInnerCall(); } } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {FailedInnerCall} error. * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert AddressInsufficientBalance(address(this)); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an * unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {FailedInnerCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}. */ function _revert(bytes memory returndata) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert FailedInnerCall(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Arrays.sol) pragma solidity ^0.8.20; import {StorageSlot} from "./StorageSlot.sol"; import {Math} from "./math/Math.sol"; /** * @dev Collection of functions related to array types. */ library Arrays { using StorageSlot for bytes32; /** * @dev Searches a sorted `array` and returns the first index that contains * a value greater or equal to `element`. If no such index exists (i.e. all * values in the array are strictly less than `element`), the array length is * returned. Time complexity O(log n). * * `array` is expected to be sorted in ascending order, and to contain no * repeated elements. */ function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) { uint256 low = 0; uint256 high = array.length; if (high == 0) { return 0; } while (low < high) { uint256 mid = Math.average(low, high); // Note that mid will always be strictly less than high (i.e. it will be a valid array index) // because Math.average rounds towards zero (it does integer division with truncation). if (unsafeAccess(array, mid).value > element) { high = mid; } else { low = mid + 1; } } // At this point `low` is the exclusive upper bound. We will return the inclusive upper bound. if (low > 0 && unsafeAccess(array, low - 1).value == element) { return low - 1; } else { return low; } } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeAccess(address[] storage arr, uint256 pos) internal pure returns (StorageSlot.AddressSlot storage) { bytes32 slot; // We use assembly to calculate the storage slot of the element at index `pos` of the dynamic array `arr` // following https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays. /// @solidity memory-safe-assembly assembly { mstore(0, arr.slot) slot := add(keccak256(0, 0x20), pos) } return slot.getAddressSlot(); } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeAccess(bytes32[] storage arr, uint256 pos) internal pure returns (StorageSlot.Bytes32Slot storage) { bytes32 slot; // We use assembly to calculate the storage slot of the element at index `pos` of the dynamic array `arr` // following https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays. /// @solidity memory-safe-assembly assembly { mstore(0, arr.slot) slot := add(keccak256(0, 0x20), pos) } return slot.getBytes32Slot(); } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeAccess(uint256[] storage arr, uint256 pos) internal pure returns (StorageSlot.Uint256Slot storage) { bytes32 slot; // We use assembly to calculate the storage slot of the element at index `pos` of the dynamic array `arr` // following https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays. /// @solidity memory-safe-assembly assembly { mstore(0, arr.slot) slot := add(keccak256(0, 0x20), pos) } return slot.getUint256Slot(); } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeMemoryAccess(uint256[] memory arr, uint256 pos) internal pure returns (uint256 res) { assembly { res := mload(add(add(arr, 0x20), mul(pos, 0x20))) } } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeMemoryAccess(address[] memory arr, uint256 pos) internal pure returns (address res) { assembly { res := mload(add(add(arr, 0x20), mul(pos, 0x20))) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement 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); * } * ``` */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @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 IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol) pragma solidity ^0.8.20; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Muldiv operation overflow. */ error MathOverflowedMulDiv(); enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an overflow flag. */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @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 towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. return a / b; } // (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 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. if (denominator <= prod1) { revert MathOverflowedMulDiv(); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. // Always >= 1. See https://cs.stackexchange.com/q/138556/92363. uint256 twos = denominator & (0 - denominator); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^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 (unsignedRoundsUp(rounding) && 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 * towards zero. * * 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 + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; 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 + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; 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 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.20; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeCast { /** * @dev Value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value); /** * @dev An int value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedIntToUint(int256 value); /** * @dev Value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedIntDowncast(uint8 bits, int256 value); /** * @dev An uint value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedUintToInt(uint256 value); /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits */ function toUint248(uint256 value) internal pure returns (uint248) { if (value > type(uint248).max) { revert SafeCastOverflowedUintDowncast(248, value); } return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits */ function toUint240(uint256 value) internal pure returns (uint240) { if (value > type(uint240).max) { revert SafeCastOverflowedUintDowncast(240, value); } return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits */ function toUint232(uint256 value) internal pure returns (uint232) { if (value > type(uint232).max) { revert SafeCastOverflowedUintDowncast(232, value); } return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits */ function toUint224(uint256 value) internal pure returns (uint224) { if (value > type(uint224).max) { revert SafeCastOverflowedUintDowncast(224, value); } return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits */ function toUint216(uint256 value) internal pure returns (uint216) { if (value > type(uint216).max) { revert SafeCastOverflowedUintDowncast(216, value); } return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits */ function toUint208(uint256 value) internal pure returns (uint208) { if (value > type(uint208).max) { revert SafeCastOverflowedUintDowncast(208, value); } return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits */ function toUint200(uint256 value) internal pure returns (uint200) { if (value > type(uint200).max) { revert SafeCastOverflowedUintDowncast(200, value); } return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits */ function toUint192(uint256 value) internal pure returns (uint192) { if (value > type(uint192).max) { revert SafeCastOverflowedUintDowncast(192, value); } return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits */ function toUint184(uint256 value) internal pure returns (uint184) { if (value > type(uint184).max) { revert SafeCastOverflowedUintDowncast(184, value); } return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits */ function toUint176(uint256 value) internal pure returns (uint176) { if (value > type(uint176).max) { revert SafeCastOverflowedUintDowncast(176, value); } return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits */ function toUint168(uint256 value) internal pure returns (uint168) { if (value > type(uint168).max) { revert SafeCastOverflowedUintDowncast(168, value); } return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits */ function toUint160(uint256 value) internal pure returns (uint160) { if (value > type(uint160).max) { revert SafeCastOverflowedUintDowncast(160, value); } return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits */ function toUint152(uint256 value) internal pure returns (uint152) { if (value > type(uint152).max) { revert SafeCastOverflowedUintDowncast(152, value); } return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits */ function toUint144(uint256 value) internal pure returns (uint144) { if (value > type(uint144).max) { revert SafeCastOverflowedUintDowncast(144, value); } return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits */ function toUint136(uint256 value) internal pure returns (uint136) { if (value > type(uint136).max) { revert SafeCastOverflowedUintDowncast(136, value); } return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { if (value > type(uint128).max) { revert SafeCastOverflowedUintDowncast(128, value); } return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits */ function toUint120(uint256 value) internal pure returns (uint120) { if (value > type(uint120).max) { revert SafeCastOverflowedUintDowncast(120, value); } return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits */ function toUint112(uint256 value) internal pure returns (uint112) { if (value > type(uint112).max) { revert SafeCastOverflowedUintDowncast(112, value); } return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits */ function toUint104(uint256 value) internal pure returns (uint104) { if (value > type(uint104).max) { revert SafeCastOverflowedUintDowncast(104, value); } return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits */ function toUint96(uint256 value) internal pure returns (uint96) { if (value > type(uint96).max) { revert SafeCastOverflowedUintDowncast(96, value); } return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits */ function toUint88(uint256 value) internal pure returns (uint88) { if (value > type(uint88).max) { revert SafeCastOverflowedUintDowncast(88, value); } return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits */ function toUint80(uint256 value) internal pure returns (uint80) { if (value > type(uint80).max) { revert SafeCastOverflowedUintDowncast(80, value); } return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits */ function toUint72(uint256 value) internal pure returns (uint72) { if (value > type(uint72).max) { revert SafeCastOverflowedUintDowncast(72, value); } return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { if (value > type(uint64).max) { revert SafeCastOverflowedUintDowncast(64, value); } return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits */ function toUint56(uint256 value) internal pure returns (uint56) { if (value > type(uint56).max) { revert SafeCastOverflowedUintDowncast(56, value); } return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits */ function toUint48(uint256 value) internal pure returns (uint48) { if (value > type(uint48).max) { revert SafeCastOverflowedUintDowncast(48, value); } return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits */ function toUint40(uint256 value) internal pure returns (uint40) { if (value > type(uint40).max) { revert SafeCastOverflowedUintDowncast(40, value); } return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { if (value > type(uint32).max) { revert SafeCastOverflowedUintDowncast(32, value); } return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits */ function toUint24(uint256 value) internal pure returns (uint24) { if (value > type(uint24).max) { revert SafeCastOverflowedUintDowncast(24, value); } return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { if (value > type(uint16).max) { revert SafeCastOverflowedUintDowncast(16, value); } return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits */ function toUint8(uint256 value) internal pure returns (uint8) { if (value > type(uint8).max) { revert SafeCastOverflowedUintDowncast(8, value); } return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { if (value < 0) { revert SafeCastOverflowedIntToUint(value); } return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(248, value); } } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(240, value); } } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(232, value); } } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(224, value); } } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(216, value); } } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(208, value); } } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(200, value); } } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(192, value); } } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(184, value); } } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(176, value); } } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(168, value); } } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(160, value); } } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(152, value); } } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(144, value); } } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(136, value); } } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(128, value); } } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(120, value); } } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(112, value); } } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(104, value); } } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(96, value); } } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(88, value); } } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(80, value); } } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(72, value); } } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(64, value); } } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(56, value); } } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(48, value); } } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(40, value); } } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(32, value); } } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(24, value); } } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(16, value); } } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(8, value); } } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive if (value > uint256(type(int256).max)) { revert SafeCastOverflowedUintToInt(value); } return int256(value); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.20; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol) // This file was procedurally generated from scripts/generate/templates/StorageSlot.js. pragma solidity ^0.8.20; /** * @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: * ```solidity * 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(newImplementation.code.length > 0); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } struct StringSlot { string value; } struct BytesSlot { bytes 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 } } /** * @dev Returns an `StringSlot` with member `value` located at `slot`. */ function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` representation of the string storage pointer `store`. */ function getStringSlot(string storage store) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } /** * @dev Returns an `BytesSlot` with member `value` located at `slot`. */ function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`. */ function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol) pragma solidity ^0.8.20; import {Math} from "./math/Math.sol"; import {SignedMath} from "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant HEX_DIGITS = "0123456789abcdef"; uint8 private constant ADDRESS_LENGTH = 20; /** * @dev The `value` string doesn't fit in the specified `length`. */ error StringsInsufficientHexLength(uint256 value, uint256 length); /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.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), HEX_DIGITS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toStringSigned(int256 value) internal pure returns (string memory) { return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.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) { uint256 localValue = value; 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] = HEX_DIGITS[localValue & 0xf]; localValue >>= 4; } if (localValue != 0) { revert StringsInsufficientHexLength(value, length); } 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); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: BSD-3-Clause pragma solidity =0.8.20; interface MCV2_ICommonToken { function totalSupply() external view returns (uint256); function mintByBond(address to, uint256 amount) external; function burnByBond(address account, uint256 amount) external; function decimals() external pure returns (uint8); function name() external view returns (string memory); function symbol() external view returns (string memory); }
// SPDX-License-Identifier: MIT pragma solidity =0.8.20; import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; import {IERC1155Receiver} from "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol"; import {IERC1155MetadataURI} from "@openzeppelin/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol"; import {Context} from "@openzeppelin/contracts/utils/Context.sol"; import {IERC165, ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; import {Arrays} from "@openzeppelin/contracts/utils/Arrays.sol"; import {IERC1155Errors} from "@openzeppelin/contracts/interfaces/draft-IERC6093.sol"; /** * @notice A slightly modified version of ERC1155 (from OpenZeppelin 5.0.0) for initialization pattern. * Modifications are marekd with the MODIFIED tag. */ abstract contract ERC1155Initializable is Context, ERC165, IERC1155, IERC1155MetadataURI, IERC1155Errors { using Arrays for uint256[]; using Arrays for address[]; mapping(uint256 id => mapping(address account => uint256)) private _balances; mapping(address account => mapping(address operator => bool)) private _operatorApprovals; // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json string internal _uri; // MODIFIED // MODIFIED: Removed for initialization pattern // constructor(string memory uri_) { // _setURI(uri_); // } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC1155).interfaceId || interfaceId == type(IERC1155MetadataURI).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC1155MetadataURI-uri}. * * This implementation returns the same URI for *all* token types. It relies * on the token type ID substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * Clients calling this function must replace the `\{id\}` substring with the * actual token type ID. */ function uri(uint256 /* id */) public view virtual returns (string memory) { return _uri; } /** * @dev See {IERC1155-balanceOf}. */ function balanceOf(address account, uint256 id) public view virtual returns (uint256) { return _balances[id][account]; } /** * @dev See {IERC1155-balanceOfBatch}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch( address[] memory accounts, uint256[] memory ids ) public view virtual returns (uint256[] memory) { if (accounts.length != ids.length) { revert ERC1155InvalidArrayLength(ids.length, accounts.length); } uint256[] memory batchBalances = new uint256[](accounts.length); for (uint256 i = 0; i < accounts.length; ++i) { batchBalances[i] = balanceOf(accounts.unsafeMemoryAccess(i), ids.unsafeMemoryAccess(i)); } return batchBalances; } /** * @dev See {IERC1155-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC1155-isApprovedForAll}. */ function isApprovedForAll(address account, address operator) public view virtual returns (bool) { return _operatorApprovals[account][operator]; } /** * @dev See {IERC1155-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) public virtual { address sender = _msgSender(); if (from != sender && !isApprovedForAll(from, sender)) { revert ERC1155MissingApprovalForAll(sender, from); } _safeTransferFrom(from, to, id, value, data); } /** * @dev See {IERC1155-safeBatchTransferFrom}. */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory values, bytes memory data ) public virtual { address sender = _msgSender(); if (from != sender && !isApprovedForAll(from, sender)) { revert ERC1155MissingApprovalForAll(sender, from); } _safeBatchTransferFrom(from, to, ids, values, data); } /** * @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`. Will mint (or burn) if `from` * (or `to`) is the zero address. * * Emits a {TransferSingle} event if the arrays contain one element, and {TransferBatch} otherwise. * * Requirements: * * - If `to` refers to a smart contract, it must implement either {IERC1155Receiver-onERC1155Received} * or {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value. * - `ids` and `values` must have the same length. * * NOTE: The ERC-1155 acceptance check is not performed in this function. See {_updateWithAcceptanceCheck} instead. */ function _update(address from, address to, uint256[] memory ids, uint256[] memory values) internal virtual { if (ids.length != values.length) { revert ERC1155InvalidArrayLength(ids.length, values.length); } address operator = _msgSender(); for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids.unsafeMemoryAccess(i); uint256 value = values.unsafeMemoryAccess(i); if (from != address(0)) { uint256 fromBalance = _balances[id][from]; if (fromBalance < value) { revert ERC1155InsufficientBalance(from, fromBalance, value, id); } unchecked { // Overflow not possible: value <= fromBalance _balances[id][from] = fromBalance - value; } } if (to != address(0)) { _balances[id][to] += value; } } if (ids.length == 1) { uint256 id = ids.unsafeMemoryAccess(0); uint256 value = values.unsafeMemoryAccess(0); emit TransferSingle(operator, from, to, id, value); } else { emit TransferBatch(operator, from, to, ids, values); } } /** * @dev Version of {_update} that performs the token acceptance check by calling * {IERC1155Receiver-onERC1155Received} or {IERC1155Receiver-onERC1155BatchReceived} on the receiver address if it * contains code (eg. is a smart contract at the moment of execution). * * IMPORTANT: Overriding this function is discouraged because it poses a reentrancy risk from the receiver. So any * update to the contract state after this function would break the check-effect-interaction pattern. Consider * overriding {_update} instead. */ function _updateWithAcceptanceCheck( address from, address to, uint256[] memory ids, uint256[] memory values, bytes memory data ) internal virtual { _update(from, to, ids, values); if (to != address(0)) { address operator = _msgSender(); if (ids.length == 1) { uint256 id = ids.unsafeMemoryAccess(0); uint256 value = values.unsafeMemoryAccess(0); _doSafeTransferAcceptanceCheck(operator, from, to, id, value, data); } else { _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, values, data); } } } /** * @dev Transfers a `value` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - `from` must have a balance of tokens of type `id` of at least `value` amount. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) internal { if (to == address(0)) { revert ERC1155InvalidReceiver(address(0)); } if (from == address(0)) { revert ERC1155InvalidSender(address(0)); } (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value); _updateWithAcceptanceCheck(from, to, ids, values, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. * - `ids` and `values` must have the same length. */ function _safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory values, bytes memory data ) internal { if (to == address(0)) { revert ERC1155InvalidReceiver(address(0)); } if (from == address(0)) { revert ERC1155InvalidSender(address(0)); } _updateWithAcceptanceCheck(from, to, ids, values, data); } /** * @dev Sets a new URI for all token types, by relying on the token type ID * substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * By this mechanism, any occurrence of the `\{id\}` substring in either the * URI or any of the values in the JSON file at said URI will be replaced by * clients with the token type ID. * * For example, the `https://token-cdn-domain/\{id\}.json` URI would be * interpreted by clients as * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json` * for token type ID 0x4cce0. * * See {uri}. * * Because these URIs cannot be meaningfully represented by the {URI} event, * this function emits no events. */ function _setURI(string memory newuri) internal virtual { _uri = newuri; } /** * @dev Creates a `value` amount of tokens of type `id`, and assigns them to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint(address to, uint256 id, uint256 value, bytes memory data) internal { if (to == address(0)) { revert ERC1155InvalidReceiver(address(0)); } (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value); _updateWithAcceptanceCheck(address(0), to, ids, values, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `values` must have the same length. * - `to` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _mintBatch(address to, uint256[] memory ids, uint256[] memory values, bytes memory data) internal { if (to == address(0)) { revert ERC1155InvalidReceiver(address(0)); } _updateWithAcceptanceCheck(address(0), to, ids, values, data); } /** * @dev Destroys a `value` amount of tokens of type `id` from `from` * * Emits a {TransferSingle} event. * * Requirements: * * - `from` cannot be the zero address. * - `from` must have at least `value` amount of tokens of type `id`. */ function _burn(address from, uint256 id, uint256 value) internal { if (from == address(0)) { revert ERC1155InvalidSender(address(0)); } (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value); _updateWithAcceptanceCheck(from, address(0), ids, values, ""); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}. * * Emits a {TransferBatch} event. * * Requirements: * * - `from` cannot be the zero address. * - `from` must have at least `value` amount of tokens of type `id`. * - `ids` and `values` must have the same length. */ function _burnBatch(address from, uint256[] memory ids, uint256[] memory values) internal { if (from == address(0)) { revert ERC1155InvalidSender(address(0)); } _updateWithAcceptanceCheck(from, address(0), ids, values, ""); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the zero address. */ function _setApprovalForAll(address owner, address operator, bool approved) internal virtual { if (operator == address(0)) { revert ERC1155InvalidOperator(address(0)); } _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Performs an acceptance check by calling {IERC1155-onERC1155Received} on the `to` address * if it contains code at the moment of execution. */ function _doSafeTransferAcceptanceCheck( address operator, address from, address to, uint256 id, uint256 value, bytes memory data ) private { if (to.code.length > 0) { try IERC1155Receiver(to).onERC1155Received(operator, from, id, value, data) returns (bytes4 response) { if (response != IERC1155Receiver.onERC1155Received.selector) { // Tokens rejected revert ERC1155InvalidReceiver(to); } } catch (bytes memory reason) { if (reason.length == 0) { // non-ERC1155Receiver implementer revert ERC1155InvalidReceiver(to); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } } /** * @dev Performs a batch acceptance check by calling {IERC1155-onERC1155BatchReceived} on the `to` address * if it contains code at the moment of execution. */ function _doSafeBatchTransferAcceptanceCheck( address operator, address from, address to, uint256[] memory ids, uint256[] memory values, bytes memory data ) private { if (to.code.length > 0) { try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, values, data) returns ( bytes4 response ) { if (response != IERC1155Receiver.onERC1155BatchReceived.selector) { // Tokens rejected revert ERC1155InvalidReceiver(to); } } catch (bytes memory reason) { if (reason.length == 0) { // non-ERC1155Receiver implementer revert ERC1155InvalidReceiver(to); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } } /** * @dev Creates an array in memory with only one value for each of the elements provided. */ function _asSingletonArrays( uint256 element1, uint256 element2 ) private pure returns (uint256[] memory array1, uint256[] memory array2) { /// @solidity memory-safe-assembly assembly { // Load the free memory pointer array1 := mload(0x40) // Set array length to 1 mstore(array1, 1) // Store the single element at the next word after the length (where content starts) mstore(add(array1, 0x20), element1) // Repeat for next array locating it right after the first array array2 := add(array1, 0x40) mstore(array2, 1) mstore(add(array2, 0x20), element2) // Update the free memory pointer by pointing after the second array mstore(0x40, add(array2, 0x40)) } } }
// SPDX-License-Identifier: MIT pragma solidity =0.8.20; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import {Context} from "@openzeppelin/contracts/utils/Context.sol"; import {IERC20Errors} from "@openzeppelin/contracts/interfaces/draft-IERC6093.sol"; /** * @notice A slightly modified version of ERC20 (from OpenZeppelin 5.0.0) for initialization pattern. * Modifications are marekd with the MODIFIED tag. */ abstract contract ERC20Initializable is Context, IERC20, IERC20Metadata, IERC20Errors { mapping(address account => uint256) private _balances; mapping(address account => mapping(address spender => uint256)) private _allowances; uint256 private _totalSupply; string internal _name; // MODIFIED string internal _symbol; // MODIFIED // MODIFIED: Removed for initialization pattern // constructor(string memory name_, string memory symbol_) { // _name = name_; // _symbol = symbol_; // } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the default value returned by this function, unless * it's overridden. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `value`. */ function transfer(address to, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _transfer(owner, to, value); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, value); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `value`. * - the caller must have allowance for ``from``'s tokens of at least * `value`. */ function transferFrom(address from, address to, uint256 value) public virtual returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, value); _transfer(from, to, value); return true; } /** * @dev Moves a `value` amount of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _transfer(address from, address to, uint256 value) internal { if (from == address(0)) { revert ERC20InvalidSender(address(0)); } if (to == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(from, to, value); } /** * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from` * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding * this function. * * Emits a {Transfer} event. */ function _update(address from, address to, uint256 value) internal virtual { if (from == address(0)) { // Overflow check required: The rest of the code assumes that totalSupply never overflows _totalSupply += value; } else { uint256 fromBalance = _balances[from]; if (fromBalance < value) { revert ERC20InsufficientBalance(from, fromBalance, value); } unchecked { // Overflow not possible: value <= fromBalance <= totalSupply. _balances[from] = fromBalance - value; } } if (to == address(0)) { unchecked { // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply. _totalSupply -= value; } } else { unchecked { // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256. _balances[to] += value; } } emit Transfer(from, to, value); } /** * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0). * Relies on the `_update` mechanism * * Emits a {Transfer} event with `from` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _mint(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(address(0), account, value); } /** * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply. * Relies on the `_update` mechanism. * * Emits a {Transfer} event with `to` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead */ function _burn(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidSender(address(0)); } _update(account, address(0), value); } /** * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. * * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument. */ function _approve(address owner, address spender, uint256 value) internal { _approve(owner, spender, value, true); } /** * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event. * * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any * `Approval` event during `transferFrom` operations. * * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to * true using the following override: * ``` * function _approve(address owner, address spender, uint256 value, bool) internal virtual override { * super._approve(owner, spender, value, true); * } * ``` * * Requirements are the same as {_approve}. */ function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual { if (owner == address(0)) { revert ERC20InvalidApprover(address(0)); } if (spender == address(0)) { revert ERC20InvalidSpender(address(0)); } _allowances[owner][spender] = value; if (emitEvent) { emit Approval(owner, spender, value); } } /** * @dev Updates `owner` s allowance for `spender` based on spent `value`. * * Does not update the allowance value in case of infinite allowance. * Revert if not enough allowance is available. * * Does not emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 value) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { if (currentAllowance < value) { revert ERC20InsufficientAllowance(spender, currentAllowance, value); } unchecked { _approve(owner, spender, currentAllowance - value, false); } } } }
// SPDX-License-Identifier: BSD-3-Clause pragma solidity =0.8.20; import {ERC1155Initializable} from "./lib/ERC1155Initializable.sol"; import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; /** * @title MCV2_MultiToken * @dev A multi-token contract that implements the ERC1155 standard. */ contract MCV2_MultiToken is ERC1155Initializable { error MCV2_MultiToken__AlreadyInitialized(); error MCV2_MultiToken__PermissionDenied(); error MCV2_MultiToken__BurnAmountExceedsTotalSupply(); error MCV2_MultiToken__NotApproved(); // ERC1155 spec does not include a name and symbol by default, but we have added them here for consistency. string public name; string public symbol; // Implement custom totalSupply tracking, since we only need to track the supply for tokenId = 0 uint256 public totalSupply; bool private _initialized; // false by default address public bond; // Bonding curve contract should have its minting permission /** * @dev Initializes the contract with the provided name, symbol, and URI. * @param name_ The name of the multi-token contract. * @param symbol_ The symbol of the multi-token contract. * @param uri_ The base URI for token metadata. */ function init(string calldata name_, string calldata symbol_, string calldata uri_) external { if(_initialized) revert MCV2_MultiToken__AlreadyInitialized(); _initialized = true; name = name_; symbol = symbol_; _setURI(uri_); bond = _msgSender(); } modifier onlyBond() { if (bond != _msgSender()) revert MCV2_MultiToken__PermissionDenied(); _; } /** * @dev Mints tokens by the bonding curve contract. * Minting should also provide liquidity to the bonding curve contract. * @param to The address to which the tokens will be minted. * @param amount The amount of tokens to mint. */ function mintByBond(address to, uint256 amount) external onlyBond { totalSupply += amount; _mint(to, 0, amount, ""); } /** * @dev Burns tokens by the bonding curve contract. * Users can simply send tokens to the token contract address for the same burning effect without changing the totalSupply. * @param account The address from which the tokens will be burned. * @param amount The amount of tokens to burn. */ function burnByBond(address account, uint256 amount) external onlyBond { if (amount > totalSupply) revert MCV2_MultiToken__BurnAmountExceedsTotalSupply(); if(!isApprovedForAll(account, bond)) revert MCV2_MultiToken__NotApproved(); // `msg.sender` is always be `_bond` unchecked { totalSupply -= amount; } _burn(account, 0, amount); } /** * @dev Added to support a common interface with ERC20 */ function decimals() public pure returns (uint8) { return 0; } /** * @dev Returns the contract URI for OpenSea compatibility. * @return The contract URI. */ function contractURI() external view returns (string memory) { return string(abi.encodePacked("https://mint.club/metadata/", Strings.toString(block.chainid), "/", symbol, ".json")); } }
// SPDX-License-Identifier: BSD-3-Clause pragma solidity =0.8.20; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; // include Context /** * @title MCV2_Royalty * @dev This contract implements royalty functionality for the Mint Club V2 protocol. */ abstract contract MCV2_Royalty is Ownable { using SafeERC20 for IERC20; error MCV2_Royalty__NothingToClaim(); error MCV2_Royalty__InvalidParams(); uint256 private constant RATIO_BASE = 10000; // 100.00% uint256 private constant PROTOCOL_CUT = 2000; address public constant BURN_ADDRESS = address(0x000000000000000000000000000000000000dEaD); address public protocolBeneficiary; uint256 public creationFee; uint256 public maxRoyaltyRange = 5000; // User => ReserveToken => Royalty Balance mapping(address => mapping(address => uint256)) public userTokenRoyaltyBalance; mapping(address => mapping(address => uint256)) public userTokenRoyaltyClaimed; // INFO event ProtocolBeneficiaryUpdated(address protocolBeneficiary); event CreationFeeUpdated(uint256 amount); event RoyaltyRangeUpdated(uint256 ratio); event RoyaltyClaimed(address indexed user, address reserveToken, uint256 amount); /** * @dev Initializes the MCV2_Royalty contract. * @param protocolBeneficiary_ The address of the protocol beneficiary. * @param msgSender The address of the contract deployer. */ constructor(address protocolBeneficiary_, uint256 creationFee_, address msgSender) Ownable(msgSender) { protocolBeneficiary = protocolBeneficiary_; creationFee = creationFee_; } // MARK: - Admin functions /** * @dev Updates the protocol beneficiary address. * @param protocolBeneficiary_ The new address of the protocol beneficiary. */ function updateProtocolBeneficiary(address protocolBeneficiary_) public onlyOwner { if (protocolBeneficiary == address(0)) revert MCV2_Royalty__InvalidParams(); protocolBeneficiary = protocolBeneficiary_; emit ProtocolBeneficiaryUpdated(protocolBeneficiary_); } function updateCreationFee(uint256 amount) external onlyOwner { creationFee = amount; emit CreationFeeUpdated(amount); } function updateMaxRoyaltyRange(uint256 ratio) external onlyOwner { if (ratio > RATIO_BASE) revert MCV2_Royalty__InvalidParams(); maxRoyaltyRange = ratio; emit RoyaltyRangeUpdated(ratio); } // MARK: - Internal utility functions /** * @dev Calculates the royalty amount based on the reserve amount and royalty ratio. * @param reserveAmount The amount of the reserve token. * @param royaltyRatio The royalty ratio. * @return The calculated royalty amount. */ function _getRoyalty(uint256 reserveAmount, uint16 royaltyRatio) internal pure returns (uint256) { return reserveAmount * royaltyRatio / RATIO_BASE; } /** * @dev Adds royalty to the beneficiary and the protocol. * @param beneficiary The address of the royalty beneficiary. * @param reserveToken The address of the reserve token. * @param royaltyAmount The royalty amount to be added. */ function _addRoyalty(address beneficiary, address reserveToken, uint256 royaltyAmount) internal { uint256 protocolCut = royaltyAmount * PROTOCOL_CUT / RATIO_BASE; userTokenRoyaltyBalance[beneficiary][reserveToken] += royaltyAmount - protocolCut; userTokenRoyaltyBalance[protocolBeneficiary][reserveToken] += protocolCut; } // MARK: - External functions /** * @dev Claims the accumulated royalties for a specific reserve token. * @param reserveToken The address of the reserve token. */ function claimRoyalties(address reserveToken) external { address msgSender = _msgSender(); uint256 amount = userTokenRoyaltyBalance[msgSender][reserveToken]; if (amount == 0) revert MCV2_Royalty__NothingToClaim(); userTokenRoyaltyBalance[msgSender][reserveToken] = 0; userTokenRoyaltyClaimed[msgSender][reserveToken] += amount; // INFO IERC20(reserveToken).safeTransfer(msgSender, amount); emit RoyaltyClaimed(msgSender, reserveToken, amount); } /** * @dev Burns the accumulated royalties for a specific reserve token and sends them to the BURN_ADDRESS. * @dev Anyone can call this function to burn the accumulated royalties for a specific reserve token. * @dev This function serves to clear the burned reserve balance from the bond contract. * @param reserveToken The address of the reserve token. */ function burnRoyalties(address reserveToken) external { uint256 amount = userTokenRoyaltyBalance[BURN_ADDRESS][reserveToken]; if (amount == 0) revert MCV2_Royalty__NothingToClaim(); userTokenRoyaltyBalance[BURN_ADDRESS][reserveToken] = 0; userTokenRoyaltyClaimed[BURN_ADDRESS][reserveToken] += amount; // INFO IERC20(reserveToken).safeTransfer(BURN_ADDRESS, amount); emit RoyaltyClaimed(BURN_ADDRESS, reserveToken, amount); } // MARK: - Utility view functions /** * @dev Retrieves the royalty information for a specific wallet and reserve token. * @param wallet The address of the wallet. * @param reserveToken The address of the reserve token. * @return The royalty balance and claimed amount for the wallet and reserve token. */ function getRoyaltyInfo(address wallet, address reserveToken) external view returns (uint256, uint256) { return (userTokenRoyaltyBalance[wallet][reserveToken], userTokenRoyaltyClaimed[wallet][reserveToken]); } }
// SPDX-License-Identifier: BSD-3-Clause pragma solidity =0.8.20; import {ERC20Initializable} from "./lib/ERC20Initializable.sol"; /** * @title MCV2_Token * @dev A token contract that implements a bonding curve and allows minting and burning of tokens. */ contract MCV2_Token is ERC20Initializable { error MCV2_Token__AlreadyInitialized(); error MCV2_Token__PermissionDenied(); bool private _initialized; // false by default address public bond; // Bonding curve contract should have its minting permission /** * @dev Initializes the token contract with the provided name and symbol. * @param name_ The name of the token. * @param symbol_ The symbol of the token. */ function init(string calldata name_, string calldata symbol_) external { if(_initialized) revert MCV2_Token__AlreadyInitialized(); _initialized = true; _name = name_; _symbol = symbol_; bond = _msgSender(); } modifier onlyBond() { if (bond != _msgSender()) revert MCV2_Token__PermissionDenied(); _; } /** * @dev Mint tokens by the bonding curve contract. * Minting should also provide liquidity to the bonding curve contract. * @param to The address to which the minted tokens will be transferred. * @param amount The amount of tokens to mint. */ function mintByBond(address to, uint256 amount) external onlyBond { _mint(to, amount); } /** * @dev Burns tokens by the bonding curve contract. * Burning tokens affects the bonding curve. * Users can simply send tokens to the token contract address for the same burning effect without changing the totalSupply. * @param account The address from which the tokens will be burned. * @param amount The amount of tokens to burn. */ function burnByBond(address account, uint256 amount) external onlyBond { _spendAllowance(account, bond, amount); // `msg.sender` is always `bond` _burn(account, amount); } }
{ "evmVersion": "paris", "optimizer": { "enabled": true, "runs": 50000 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"tokenImplementation","type":"address"},{"internalType":"address","name":"multiTokenImplementation","type":"address"},{"internalType":"address","name":"protocolBeneficiary_","type":"address"},{"internalType":"uint256","name":"creationFee_","type":"uint256"},{"internalType":"uint256","name":"maxSteps","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"ERC1167FailedCreateClone","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"MCV2_BOND__InvalidPaginationParameters","type":"error"},{"inputs":[],"name":"MCV2_Bond__CreationFeeTransactionFailed","type":"error"},{"inputs":[],"name":"MCV2_Bond__ExceedMaxSupply","type":"error"},{"inputs":[],"name":"MCV2_Bond__ExceedTotalSupply","type":"error"},{"inputs":[{"internalType":"string","name":"reason","type":"string"}],"name":"MCV2_Bond__InvalidConstructorParams","type":"error"},{"inputs":[],"name":"MCV2_Bond__InvalidCreationFee","type":"error"},{"inputs":[],"name":"MCV2_Bond__InvalidCreatorAddress","type":"error"},{"inputs":[],"name":"MCV2_Bond__InvalidCurrentSupply","type":"error"},{"inputs":[],"name":"MCV2_Bond__InvalidReceiver","type":"error"},{"inputs":[{"internalType":"string","name":"reason","type":"string"}],"name":"MCV2_Bond__InvalidReserveToken","type":"error"},{"inputs":[{"internalType":"string","name":"reason","type":"string"}],"name":"MCV2_Bond__InvalidStepParams","type":"error"},{"inputs":[],"name":"MCV2_Bond__InvalidTokenAmount","type":"error"},{"inputs":[{"internalType":"string","name":"reason","type":"string"}],"name":"MCV2_Bond__InvalidTokenCreationParams","type":"error"},{"inputs":[],"name":"MCV2_Bond__PermissionDenied","type":"error"},{"inputs":[],"name":"MCV2_Bond__SlippageLimitExceeded","type":"error"},{"inputs":[],"name":"MCV2_Bond__TokenNotFound","type":"error"},{"inputs":[],"name":"MCV2_Bond__TokenSymbolAlreadyExists","type":"error"},{"inputs":[],"name":"MCV2_Royalty__InvalidParams","type":"error"},{"inputs":[],"name":"MCV2_Royalty__NothingToClaim","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"uint8","name":"bits","type":"uint8"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"SafeCastOverflowedUintDowncast","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"creator","type":"address"}],"name":"BondCreatorUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountBurned","type":"uint256"},{"indexed":true,"internalType":"address","name":"reserveToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"refundAmount","type":"uint256"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"CreationFeeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountMinted","type":"uint256"},{"indexed":true,"internalType":"address","name":"reserveToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"reserveAmount","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"string","name":"uri","type":"string"},{"indexed":true,"internalType":"address","name":"reserveToken","type":"address"}],"name":"MultiTokenCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"protocolBeneficiary","type":"address"}],"name":"ProtocolBeneficiaryUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"reserveToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RoyaltyClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"ratio","type":"uint256"}],"name":"RoyaltyRangeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":true,"internalType":"address","name":"reserveToken","type":"address"}],"name":"TokenCreated","type":"event"},{"inputs":[],"name":"BURN_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"tokensToBurn","type":"uint256"},{"internalType":"uint256","name":"minRefund","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"burn","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"reserveToken","type":"address"}],"name":"burnRoyalties","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"reserveToken","type":"address"}],"name":"claimRoyalties","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"string","name":"uri","type":"string"}],"internalType":"struct MCV2_Bond.MultiTokenParams","name":"tp","type":"tuple"},{"components":[{"internalType":"uint16","name":"mintRoyalty","type":"uint16"},{"internalType":"uint16","name":"burnRoyalty","type":"uint16"},{"internalType":"address","name":"reserveToken","type":"address"},{"internalType":"uint128","name":"maxSupply","type":"uint128"},{"internalType":"uint128[]","name":"stepRanges","type":"uint128[]"},{"internalType":"uint128[]","name":"stepPrices","type":"uint128[]"}],"internalType":"struct MCV2_Bond.BondParams","name":"bp","type":"tuple"}],"name":"createMultiToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"}],"internalType":"struct MCV2_Bond.TokenParams","name":"tp","type":"tuple"},{"components":[{"internalType":"uint16","name":"mintRoyalty","type":"uint16"},{"internalType":"uint16","name":"burnRoyalty","type":"uint16"},{"internalType":"address","name":"reserveToken","type":"address"},{"internalType":"uint128","name":"maxSupply","type":"uint128"},{"internalType":"uint128[]","name":"stepRanges","type":"uint128[]"},{"internalType":"uint128[]","name":"stepPrices","type":"uint128[]"}],"internalType":"struct MCV2_Bond.BondParams","name":"bp","type":"tuple"}],"name":"createToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"creationFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"exists","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getDetail","outputs":[{"components":[{"internalType":"uint16","name":"mintRoyalty","type":"uint16"},{"internalType":"uint16","name":"burnRoyalty","type":"uint16"},{"components":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint8","name":"decimals","type":"uint8"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"string","name":"name","type":"string"},{"internalType":"uint40","name":"createdAt","type":"uint40"},{"internalType":"uint128","name":"currentSupply","type":"uint128"},{"internalType":"uint128","name":"maxSupply","type":"uint128"},{"internalType":"uint128","name":"priceForNextMint","type":"uint128"},{"internalType":"address","name":"reserveToken","type":"address"},{"internalType":"uint8","name":"reserveDecimals","type":"uint8"},{"internalType":"string","name":"reserveSymbol","type":"string"},{"internalType":"string","name":"reserveName","type":"string"},{"internalType":"uint256","name":"reserveBalance","type":"uint256"}],"internalType":"struct MCV2_Bond.BondInfo","name":"info","type":"tuple"},{"components":[{"internalType":"uint128","name":"rangeTo","type":"uint128"},{"internalType":"uint128","name":"price","type":"uint128"}],"internalType":"struct MCV2_Bond.BondStep[]","name":"steps","type":"tuple[]"}],"internalType":"struct MCV2_Bond.BondDetail","name":"detail","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"stop","type":"uint256"}],"name":"getList","outputs":[{"components":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint8","name":"decimals","type":"uint8"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"string","name":"name","type":"string"},{"internalType":"uint40","name":"createdAt","type":"uint40"},{"internalType":"uint128","name":"currentSupply","type":"uint128"},{"internalType":"uint128","name":"maxSupply","type":"uint128"},{"internalType":"uint128","name":"priceForNextMint","type":"uint128"},{"internalType":"address","name":"reserveToken","type":"address"},{"internalType":"uint8","name":"reserveDecimals","type":"uint8"},{"internalType":"string","name":"reserveSymbol","type":"string"},{"internalType":"string","name":"reserveName","type":"string"},{"internalType":"uint256","name":"reserveBalance","type":"uint256"}],"internalType":"struct MCV2_Bond.BondInfo[]","name":"info","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"tokensToBurn","type":"uint256"}],"name":"getRefundForTokens","outputs":[{"internalType":"uint256","name":"refundAmount","type":"uint256"},{"internalType":"uint256","name":"royalty","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"tokensToMint","type":"uint256"}],"name":"getReserveForToken","outputs":[{"internalType":"uint256","name":"reserveAmount","type":"uint256"},{"internalType":"uint256","name":"royalty","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"wallet","type":"address"},{"internalType":"address","name":"reserveToken","type":"address"}],"name":"getRoyaltyInfo","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getSteps","outputs":[{"components":[{"internalType":"uint128","name":"rangeTo","type":"uint128"},{"internalType":"uint128","name":"price","type":"uint128"}],"internalType":"struct MCV2_Bond.BondStep[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"stop","type":"uint256"}],"name":"getTokensByCreator","outputs":[{"internalType":"address[]","name":"addresses","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"reserveToken","type":"address"},{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"stop","type":"uint256"}],"name":"getTokensByReserveToken","outputs":[{"internalType":"address[]","name":"addresses","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxRoyaltyRange","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"maxSupply","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"tokensToMint","type":"uint256"},{"internalType":"uint256","name":"maxReserveAmount","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"mint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"priceForNextMint","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"protocolBeneficiary","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokenBond","outputs":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"uint16","name":"mintRoyalty","type":"uint16"},{"internalType":"uint16","name":"burnRoyalty","type":"uint16"},{"internalType":"uint40","name":"createdAt","type":"uint40"},{"internalType":"address","name":"reserveToken","type":"address"},{"internalType":"uint256","name":"reserveBalance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokens","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"creator","type":"address"}],"name":"updateBondCreator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"updateCreationFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"ratio","type":"uint256"}],"name":"updateMaxRoyaltyRange","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"protocolBeneficiary_","type":"address"}],"name":"updateProtocolBeneficiary","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"userTokenRoyaltyBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"userTokenRoyaltyClaimed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"}]
Contract Creation Code
60e06040526113886003553480156200001757600080fd5b50604051620058c0380380620058c08339810160408190526200003a916200025f565b82823380806200006557604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b6200007081620001f2565b5050600180546001600160a01b0319166001600160a01b039384161790556002558516620000e25760405163643b81d760e01b815260206004820152601360248201527f746f6b656e496d706c656d656e746174696f6e0000000000000000000000000060448201526064016200005c565b6001600160a01b0384166200013b5760405163643b81d760e01b815260206004820152601860248201527f6d756c7469546f6b656e496d706c656d656e746174696f6e000000000000000060448201526064016200005c565b6001600160a01b038316620001945760405163643b81d760e01b815260206004820152601360248201527f70726f746f636f6c42656e65666963696172790000000000000000000000000060448201526064016200005c565b80600003620001d25760405163643b81d760e01b81526020600482015260086024820152676d6178537465707360c01b60448201526064016200005c565b6001600160a01b0394851660a0529290931660c0525060805250620002bc565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b03811681146200025a57600080fd5b919050565b600080600080600060a086880312156200027857600080fd5b620002838662000242565b9450620002936020870162000242565b9350620002a36040870162000242565b6060870151608090970151959894975095949392505050565b60805160a05160c0516155d4620002ec60003960006119d501526000610bb70152600061324b01526155d46000f3fe6080604052600436106102195760003560e01c8063995e5f921161011d578063c9cb204b116100b0578063f2fde38b1161007f578063f74bfe8e11610064578063f74bfe8e14610801578063fb8c13c814610821578063fccc28131461084157600080fd5b8063f2fde38b14610786578063f6a3d24e146107a657600080fd5b8063c9cb204b14610620578063cfc5562214610640578063d9fe0eae14610660578063dce0b4e41461077057600080fd5b8063a746ee2e116100ec578063a746ee2e14610586578063a9816b08146105b3578063ac4e9675146105e0578063c162c9161461060057600080fd5b8063995e5f92146104ec5780639c65003d146105195780639cc7becf146105515780639f181b5e1461057157600080fd5b8063715018a6116101b057806377e456cb1161017f57806385396d2b1161016457806385396d2b146104815780638da5cb5b14610494578063990e6005146104bf57600080fd5b806377e456cb1461042a578063840d885d1461044057600080fd5b8063715018a6146103a05780637348ed2f146103b5578063763e7da6146103d557806376a9864b146103f557600080fd5b806350801fb1116101ec57806350801fb1146102ce57806354fd4d50146103145780635a4d5311146103605780636fa237951461038057600080fd5b806307e329461461021e57806327e381a91461025457806330be6955146102765780634f64b2be146102ae575b600080fd5b34801561022a57600080fd5b5061023e6102393660046149df565b610857565b60405161024b9190614a12565b60405180910390f35b34801561026057600080fd5b5061027461026f366004614a6c565b610a90565b005b610289610284366004614a9f565b610b61565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161024b565b3480156102ba57600080fd5b506102896102c9366004614b0b565b610f47565b3480156102da57600080fd5b506103066102e9366004614b24565b600560209081526000928352604080842090915290825290205481565b60405190815260200161024b565b34801561032057600080fd5b50604080518082018252600781527f302e312e313230000000000000000000000000000000000000000000000000006020820152905161024b9190614bc5565b34801561036c57600080fd5b5061030661037b366004614bd8565b610f7e565b34801561038c57600080fd5b5061027461039b366004614b0b565b61119d565b3480156103ac57600080fd5b506102746111da565b3480156103c157600080fd5b506102746103d0366004614b0b565b6111ee565b3480156103e157600080fd5b506102746103f0366004614b24565b611267565b34801561040157600080fd5b50610415610410366004614c1e565b61138a565b6040805192835260208301919091520161024b565b34801561043657600080fd5b5061030660035481565b34801561044c57600080fd5b5061046061045b366004614a6c565b611859565b6040516fffffffffffffffffffffffffffffffff909116815260200161024b565b61028961048f366004614c48565b61197f565b3480156104a057600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff16610289565b3480156104cb57600080fd5b506001546102899073ffffffffffffffffffffffffffffffffffffffff1681565b3480156104f857600080fd5b5061050c610507366004614a6c565b611b94565b60405161024b9190614ce3565b34801561052557600080fd5b50610306610534366004614b24565b600460209081526000928352604080842090915290825290205481565b34801561055d57600080fd5b5061046061056c366004614a6c565b611c46565b34801561057d57600080fd5b50600754610306565b34801561059257600080fd5b506105a66105a1366004614a6c565b611cb0565b60405161024b9190614e7f565b3480156105bf57600080fd5b506105d36105ce366004614efb565b611ed3565b60405161024b9190614f1d565b3480156105ec57600080fd5b506104156105fb366004614b24565b61208c565b34801561060c57600080fd5b5061027461061b366004614a6c565b6120df565b34801561062c57600080fd5b5061041561063b366004614c1e565b612224565b34801561064c57600080fd5b5061027461065b366004614a6c565b6126ac565b34801561066c57600080fd5b5061071861067b366004614a6c565b60066020526000908152604090208054600182015460029092015473ffffffffffffffffffffffffffffffffffffffff8083169374010000000000000000000000000000000000000000840461ffff90811694760100000000000000000000000000000000000000000000810490911693780100000000000000000000000000000000000000000000000090910464ffffffffff16929091169086565b6040805173ffffffffffffffffffffffffffffffffffffffff978816815261ffff9687166020820152949095169484019490945264ffffffffff919091166060830152909216608083015260a082015260c00161024b565b34801561077c57600080fd5b5061030660025481565b34801561079257600080fd5b506102746107a1366004614a6c565b61282b565b3480156107b257600080fd5b506107f16107c1366004614a6c565b73ffffffffffffffffffffffffffffffffffffffff90811660009081526006602052604090206001015416151590565b604051901515815260200161024b565b34801561080d57600080fd5b5061030661081c366004614bd8565b612894565b34801561082d57600080fd5b5061023e61083c3660046149df565b612abb565b34801561084d57600080fd5b5061028961dead81565b6060818310158061087257506127106108708484614fcc565b115b156108a9576040517f891724d600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600754808311156108b8578092505b6000845b84811015610941578673ffffffffffffffffffffffffffffffffffffffff1660066000600784815481106108f2576108f2614fdf565b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff90811684529083019390935260409091019020600101541603610939578160010191505b6001016108bc565b508067ffffffffffffffff81111561095b5761095b61500e565b604051908082528060200260200182016040528015610984578160200160208202803683370190505b5092506000855b85811015610a85578773ffffffffffffffffffffffffffffffffffffffff1660066000600784815481106109c1576109c1614fdf565b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff90811684529083019390935260409091019020600101541603610a7d5760078181548110610a1457610a14614fdf565b6000918252602090912001548551600184019373ffffffffffffffffffffffffffffffffffffffff9092169187918110610a5057610a50614fdf565b73ffffffffffffffffffffffffffffffffffffffff90921660209283029190910190910152818314610a85575b60010161098b565b505050509392505050565b610a98612ce3565b60015473ffffffffffffffffffffffffffffffffffffffff16610ae7576040517f5059b85f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527fcf7686c0c53a1ab216c4cd81c1bc037136c791a61f30af4a78827c3915766044906020015b60405180910390a150565b60006002543414610b9e576040517f3403ce3700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610ba783612d36565b610bb082612e25565b6000610be87f0000000000000000000000000000000000000000000000000000000000000000610be3602087018761503d565b613451565b90508073ffffffffffffffffffffffffffffffffffffffff8116637029144c610c11878061503d565b610c1e60208a018a61503d565b6040518563ffffffff1660e01b8152600401610c3d94939291906150eb565b600060405180830381600087803b158015610c5757600080fd5b505af1158015610c6b573d6000803e3d6000fd5b5050600780546001810182556000919091527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c6880180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff861617905550610cea90508285613508565b610cfa6060850160408601614a6c565b73ffffffffffffffffffffffffffffffffffffffff9081169083167f6596c1670eb3390048d23721809c3da5d3f531375ac0e2cab0f77a808ed64331610d40888061503d565b610d4d60208b018b61503d565b604051610d5d94939291906150eb565b60405180910390a3610d7260a085018561511d565b6000818110610d8357610d83614fdf565b9050602002016020810190610d989190615185565b6fffffffffffffffffffffffffffffffff16600003610e975773ffffffffffffffffffffffffffffffffffffffff8116631b5ad8b533610ddb608088018861511d565b6000818110610dec57610dec614fdf565b9050602002016020810190610e019190615185565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815273ffffffffffffffffffffffffffffffffffffffff90921660048301526fffffffffffffffffffffffffffffffff166024820152604401600060405180830381600087803b158015610e7e57600080fd5b505af1158015610e92573d6000803e3d6000fd5b505050505b60025415610f3d5760015460025460405160009273ffffffffffffffffffffffffffffffffffffffff1691908381818185875af1925050503d8060008114610efb576040519150601f19603f3d011682016040523d82523d6000602084013e610f00565b606091505b5050905080610f3b576040517f0d4d59b300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505b5090505b92915050565b60078181548110610f5757600080fd5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16905081565b600073ffffffffffffffffffffffffffffffffffffffff8216610fcd576040517fd9b08f7600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080610fda8787612224565b9150915084821015611018576040517f07728bb000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff871660008181526006602052604080822081517ff4efe8f20000000000000000000000000000000000000000000000000000000081523360048201819052602482018c905292519194929363f4efe8f29260448084019382900301818387803b15801561109957600080fd5b505af11580156110ad573d6000803e3d6000fd5b5050505082846110bd91906151b7565b8260020160008282546110d09190614fcc565b9091555050815460018301546111009173ffffffffffffffffffffffffffffffffffffffff908116911685613a97565b600182015473ffffffffffffffffffffffffffffffffffffffff16611126818887613b59565b60018301546040805173ffffffffffffffffffffffffffffffffffffffff8a81168252602082018d905291810188905291811691848216918d16907f80a56de61873550ae491e454783a8dfc9d08a6f8bdace0887eabd4315c4b9da8906060015b60405180910390a4509298975050505050505050565b6111a5612ce3565b60028190556040518181527f88a973fd5506071e0cf878b30898776c47d5250a7ee1e6ee0b36df3b03c7c16a90602001610b56565b6111e2612ce3565b6111ec6000613bdf565b565b6111f6612ce3565b612710811115611232576040517f5059b85f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60038190556040518181527f21085b3501e0e4fa8e0c825e7ed36b44420471b9f3c5aef447cebe50b2db133d90602001610b56565b73ffffffffffffffffffffffffffffffffffffffff8281166000908152600660205260409020805490911633146112ca576040517f36a0203800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8216611317576040517f67f61c8200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8381169182178355604051908516907f9dcef3aa57f22970dfc6ff519e5421e041cc4153300a7dabe19bffe85e25568890600090a3505050565b73ffffffffffffffffffffffffffffffffffffffff808316600090815260066020526040812060010154909182918591166113f1576040517f2d350e9f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8360000361142b576040517fc01ae10500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8086166000908152600660209081526040808320815160e0810183528154808716825261ffff7401000000000000000000000000000000000000000082048116838701527601000000000000000000000000000000000000000000008204168285015264ffffffffff780100000000000000000000000000000000000000000000000090910416606082015260018201549095166080860152600281015460a0860152600381018054835181860281018601909452808452949594919360c08601939290879084015b8282101561156857600084815260209081902060408051808201909152908401546fffffffffffffffffffffffffffffffff80821683527001000000000000000000000000000000009091041681830152825260019092019101611509565b5050505081525050905060008160c001519050600087905060008173ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115f191906151ca565b905060006115ff89836151b7565b905061160a8a611c46565b6fffffffffffffffffffffffffffffffff16811115611655576040517f6b5b0f7c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008373ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156116a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116c691906151e3565b6116d190600a615326565b905089600080806116e28f88613c54565b90505b88518110156117e757600089828151811061170257611702614fdf565b602002602001015190508781600001516fffffffffffffffffffffffffffffffff1661172e9190614fcc565b92508483101561179a578260000361174657506117d7565b61177181602001516fffffffffffffffffffffffffffffffff168461176b9190615335565b87613d0c565b61177b90856151b7565b935061178783896151b7565b97506117938386614fcc565b94506117d5565b6117bf81602001516fffffffffffffffffffffffffffffffff168661176b9190615335565b6117c990856151b7565b935060009450506117e7565b505b6117e08161534c565b90506116e5565b508115806117f55750600083115b1561182c576040517fc01ae10500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61183a828a60200151613d5c565b9a506118468b836151b7565b9b50505050505050505050509250929050565b6000808273ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156118a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118cb91906151ca565b90506118d683611c46565b6fffffffffffffffffffffffffffffffff168110156118fb576118f88161534c565b90505b60006119078483613c54565b73ffffffffffffffffffffffffffffffffffffffff851660009081526006602052604090206003018054919250908290811061194557611945614fdf565b60009182526020909120015470010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff16949350505050565b600060025434146119bc576040517f3403ce3700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6119c583613d79565b6119ce82612e25565b6000611a017f0000000000000000000000000000000000000000000000000000000000000000610be3602087018761503d565b90508073ffffffffffffffffffffffffffffffffffffffff81166341e461a0611a2a878061503d565b611a3760208a018a61503d565b611a4460408c018c61503d565b6040518763ffffffff1660e01b8152600401611a6596959493929190615384565b600060405180830381600087803b158015611a7f57600080fd5b505af1158015611a93573d6000803e3d6000fd5b5050600780546001810182556000919091527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c6880180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff861617905550611b1290508285613508565b611b226060850160408601614a6c565b73ffffffffffffffffffffffffffffffffffffffff9081169083167f42d30c09380d6b8dbb77d95cae534a5c8fbf778789d87f58030bd74280437071611b68888061503d565b611b7560208b018b61503d565b611b8260408d018d61503d565b604051610d5d96959493929190615384565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600660209081526040808320600301805482518185028101850190935280835260609492939192909184015b82821015611c3b57600084815260209081902060408051808201909152908401546fffffffffffffffffffffffffffffffff80821683527001000000000000000000000000000000009091041681830152825260019092019101611bdc565b505050509050919050565b73ffffffffffffffffffffffffffffffffffffffff811660009081526006602052604081206003018054611c7c90600190614fcc565b81548110611c8c57611c8c614fdf565b6000918252602090912001546fffffffffffffffffffffffffffffffff1692915050565b611d4760408051608080820183526000808352602080840182905284516101c081018652828152908101829052808501829052606080820181905292810183905260a0810182905260c0810182905260e0810182905261010081018290526101208101829052610140810182905261016081018390526101808101929092526101a082015290918201908152602001606081525090565b73ffffffffffffffffffffffffffffffffffffffff8083166000908152600660209081526040808320815160e0810183528154808716825261ffff7401000000000000000000000000000000000000000082048116838701527601000000000000000000000000000000000000000000008204168285015264ffffffffff780100000000000000000000000000000000000000000000000090910416606082015260018201549095166080860152600281015460a0860152600381018054835181860281018601909452808452949594919360c08601939290879084015b82821015611e8457600084815260209081902060408051808201909152908401546fffffffffffffffffffffffffffffffff80821683527001000000000000000000000000000000009091041681830152825260019092019101611e25565b505050508152505090506040518060800160405280826020015161ffff168152602001826040015161ffff168152602001611ebe85613ee0565b81526020018260c00151815250915050919050565b60608183101580611eee57506103e8611eec8484614fcc565b115b15611f25576040517f891724d600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60075480831115611f34578092505b8383038067ffffffffffffffff811115611f5057611f5061500e565b60405190808252806020026020018201604052801561200c57816020015b604080516101c0810182526000808252602080830182905292820181905260608083018190526080830181905260a0830182905260c0830182905260e0830182905261010083018290526101208301829052610140830182905261016083018190526101808301526101a082015282527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff909201910181611f6e5790505b5092506000855b85811015612082576120586007828154811061203157612031614fdf565b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16613ee0565b855160018401938791811061206f5761206f614fdf565b6020908102919091010152600101612013565b5050505092915050565b73ffffffffffffffffffffffffffffffffffffffff8083166000818152600460209081526040808320948616808452948252808320549383526005825280832094835293905291909120545b9250929050565b33600081815260046020908152604080832073ffffffffffffffffffffffffffffffffffffffff861684529091528120549081900361214a576040517fbfa4e44600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff80831660008181526004602090815260408083209488168084529482528083208390559282526005815282822093825292909252812080548392906121a59084906151b7565b909155506121cc905073ffffffffffffffffffffffffffffffffffffffff84168383613b59565b6040805173ffffffffffffffffffffffffffffffffffffffff8581168252602082018490528416917fd1b893da855ca6a7c9cfbaff142da78c734a39d4811ad711fe7acfd6e5e433a4910160405180910390a2505050565b73ffffffffffffffffffffffffffffffffffffffff8083166000908152600660205260408120600101549091829185911661228b576040517f2d350e9f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b836000036122c5576040517fc01ae10500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8086166000908152600660209081526040808320815160e0810183528154808716825261ffff7401000000000000000000000000000000000000000082048116838701527601000000000000000000000000000000000000000000008204168285015264ffffffffff780100000000000000000000000000000000000000000000000090910416606082015260018201549095166080860152600281015460a0860152600381018054835181860281018601909452808452949594919360c08601939290879084015b8282101561240257600084815260209081902060408051808201909152908401546fffffffffffffffffffffffffffffffff808216835270010000000000000000000000000000000090910416818301528252600190920191016123a3565b5050505081525050905060008160c001519050600087905060008173ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612467573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061248b91906151ca565b9050808811156124c7576040517f4fffb8fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008273ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612514573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061253891906151e3565b61254390600a615326565b9050600089816125538d86613c54565b90505b811561264857600081156125ae5787612570600184614fcc565b8151811061258057612580614fdf565b6020026020010151600001516fffffffffffffffffffffffffffffffff16866125a99190614fcc565b6125b0565b855b905060008184106125c157816125c3565b835b9050858984815181106125d8576125d8614fdf565b6020026020010151602001516fffffffffffffffffffffffffffffffff16826126019190615335565b61260b91906153cd565b61261590866151b7565b94506126218185614fcc565b935061262d8188614fcc565b965082156126415761263e83615408565b92505b5050612556565b8115612680576040517fc01ae10500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61268e838960400151613d5c565b995061269a8a84614fcc565b9a505050505050505050509250929050565b73ffffffffffffffffffffffffffffffffffffffff811660009081527f42c63635470f1fb1d6d4b6441c413cb435b1ebb6fedd1896dd5e25d1399147dd60205260408120549081900361272b576040517fbfa4e44600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff821660009081527f42c63635470f1fb1d6d4b6441c413cb435b1ebb6fedd1896dd5e25d1399147dd602090815260408083208390557f7d509c07f0d4edcc2dd1b53aae68677132eb562dcba78e36381b63ccaf66e6ba909152812080548392906127ab9084906151b7565b909155506127d4905073ffffffffffffffffffffffffffffffffffffffff831661dead83613b59565b6040805173ffffffffffffffffffffffffffffffffffffffff841681526020810183905261dead917fd1b893da855ca6a7c9cfbaff142da78c734a39d4811ad711fe7acfd6e5e433a4910160405180910390a25050565b612833612ce3565b73ffffffffffffffffffffffffffffffffffffffff8116612888576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024015b60405180910390fd5b61289181613bdf565b50565b600073ffffffffffffffffffffffffffffffffffffffff82166128e3576040517fd9b08f7600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000806128f0878761138a565b915091508482111561292e576040517f07728bb000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8781166000908152600660205260409020600181015490913391166129688486614fcc565b83600201600082825461297b91906151b7565b9091555050825460018401546129ab9173ffffffffffffffffffffffffffffffffffffffff908116911686613a97565b6040517f1b5ad8b500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8881166004830152602482018b90528b1690631b5ad8b590604401600060405180830381600087803b158015612a1b57600080fd5b505af1158015612a2f573d6000803e3d6000fd5b50612a569250505073ffffffffffffffffffffffffffffffffffffffff8216833088614541565b60018301546040805173ffffffffffffffffffffffffffffffffffffffff8a81168252602082018d905291810188905291811691848216918d16907f02ed9b10d8b33a6a9fda664247bfd8f6248f74cff85cc84e56b7530c2fce560a90606001611187565b60608183101580612ad65750612710612ad48484614fcc565b115b15612b0d576040517f891724d600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60075480831115612b1c578092505b6000845b84811015612ba2578673ffffffffffffffffffffffffffffffffffffffff166006600060078481548110612b5657612b56614fdf565b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff90811684529083019390935260409091019020541603612b9a578160010191505b600101612b20565b508067ffffffffffffffff811115612bbc57612bbc61500e565b604051908082528060200260200182016040528015612be5578160200160208202803683370190505b5092506000855b85811015610a85578773ffffffffffffffffffffffffffffffffffffffff166006600060078481548110612c2257612c22614fdf565b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff90811684529083019390935260409091019020541603612cdb5760078181548110612c7257612c72614fdf565b6000918252602090912001548551600184019373ffffffffffffffffffffffffffffffffffffffff9092169187918110612cae57612cae614fdf565b73ffffffffffffffffffffffffffffffffffffffff90921660209283029190910190910152818314610a85575b600101612bec565b60005473ffffffffffffffffffffffffffffffffffffffff1633146111ec576040517f118cdaa700000000000000000000000000000000000000000000000000000000815233600482015260240161287f565b612d40818061503d565b9050600003612dad576040517f49d3358800000000000000000000000000000000000000000000000000000000815260040161287f9060208082526004908201527f6e616d6500000000000000000000000000000000000000000000000000000000604082015260600190565b612dba602082018261503d565b9050600003612891576040517f49d3358800000000000000000000000000000000000000000000000000000000815260206004820152600660248201527f73796d626f6c0000000000000000000000000000000000000000000000000000604482015260640161287f565b600354612e35602083018361543d565b61ffff161115612ea1576040517f49d3358800000000000000000000000000000000000000000000000000000000815260206004820152600b60248201527f6d696e74526f79616c7479000000000000000000000000000000000000000000604482015260640161287f565b600354612eb4604083016020840161543d565b61ffff161115612f20576040517f49d3358800000000000000000000000000000000000000000000000000000000815260206004820152600b60248201527f6275726e526f79616c7479000000000000000000000000000000000000000000604482015260640161287f565b6000612f326060830160408401614a6c565b905073ffffffffffffffffffffffffffffffffffffffff8116612fb1576040517f49d3358800000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f72657365727665546f6b656e0000000000000000000000000000000000000000604482015260640161287f565b612ff2816040518060400160405280600a81526020017f646563696d616c73282900000000000000000000000000000000000000000000815250601f61458d565b613058576040517f59f5822400000000000000000000000000000000000000000000000000000000815260206004820152600860248201527f646563696d616c73000000000000000000000000000000000000000000000000604482015260640161287f565b613099816040518060400160405280600681526020017f6e616d6528290000000000000000000000000000000000000000000000000000815250605f61458d565b613101576040517f59f5822400000000000000000000000000000000000000000000000000000000815260040161287f9060208082526004908201527f6e616d6500000000000000000000000000000000000000000000000000000000604082015260600190565b613142816040518060400160405280600881526020017f73796d626f6c2829000000000000000000000000000000000000000000000000815250605f61458d565b6131a8576040517f59f5822400000000000000000000000000000000000000000000000000000000815260206004820152600660248201527f73796d626f6c0000000000000000000000000000000000000000000000000000604482015260640161287f565b6131b86080830160608401615185565b6fffffffffffffffffffffffffffffffff16600003613233576040517f49d3358800000000000000000000000000000000000000000000000000000000815260206004820152600960248201527f6d6178537570706c790000000000000000000000000000000000000000000000604482015260640161287f565b613240608083018361511d565b1590508061327b57507f0000000000000000000000000000000000000000000000000000000000000000613277608084018461511d565b9050115b156132e2576040517f1afd40d600000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f494e56414c49445f535445505f4c454e47544800000000000000000000000000604482015260640161287f565b6132ef60a083018361511d565b90506132fe608084018461511d565b905014613367576040517f1afd40d600000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f535445505f4c454e4754485f444f5f4e4f545f4d415443480000000000000000604482015260640161287f565b6133776080830160608401615185565b6fffffffffffffffffffffffffffffffff16613396608084018461511d565b60016133a5608087018761511d565b6133b0929150614fcc565b8181106133bf576133bf614fdf565b90506020020160208101906133d49190615185565b6fffffffffffffffffffffffffffffffff161461344d576040517f1afd40d600000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4d41585f535550504c595f4d49534d4154434800000000000000000000000000604482015260640161287f565b5050565b60008030848460405160200161346993929190615461565b604051602081830303815290604052805190602001209050600061348d8683614686565b73ffffffffffffffffffffffffffffffffffffffff80821660009081526006602052604090206001015491925016156134f2576040517f358b663800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6134fc86836146e6565b925050505b9392505050565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260066020908152604090912080547fffffffffffffffffffffffff00000000000000000000000000000000000000001633178155906135659083018361543d565b815461ffff9190911674010000000000000000000000000000000000000000027fffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffff9091161781556135bc604083016020840161543d565b81547fffffff00000000000000ffffffffffffffffffffffffffffffffffffffffffff1676010000000000000000000000000000000000000000000061ffff92909216919091027fffffff0000000000ffffffffffffffffffffffffffffffffffffffffffffffff161778010000000000000000000000000000000000000000000000004264ffffffffff160217815561365c6060830160408401614a6c565b8160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008373ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156136eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061370f91906151e3565b61371a90600a615326565b905060005b61372c608085018561511d565b9050811015613a90576000613744608086018661511d565b8381811061375457613754614fdf565b90506020020160208101906137699190615185565b6fffffffffffffffffffffffffffffffff169050600061378c60a087018761511d565b8481811061379c5761379c614fdf565b90506020020160208101906137b19190615185565b6fffffffffffffffffffffffffffffffff1690508160000361382f576040517f1afd40d600000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f535445505f43414e4e4f545f42455f5a45524f00000000000000000000000000604482015260640161287f565b6000811180156138475750836138458284615335565b105b156138ae576040517f1afd40d600000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f535445505f52414e475f4f525f50524943455f544f4f5f534d414c4c00000000604482015260640161287f565b8215613a20576138c1608087018761511d565b6138cc600186614fcc565b8181106138db576138db614fdf565b90506020020160208101906138f09190615185565b6fffffffffffffffffffffffffffffffff16821161396a576040517f1afd40d600000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f44454352454153494e475f52414e474500000000000000000000000000000000604482015260640161287f565b61397760a087018761511d565b613982600186614fcc565b81811061399157613991614fdf565b90506020020160208101906139a69190615185565b6fffffffffffffffffffffffffffffffff168111613a20576040517f1afd40d600000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f44454352454153494e475f505249434500000000000000000000000000000000604482015260640161287f565b604080518082019091526fffffffffffffffffffffffffffffffff928316815290821660208083019182526003870180546001810182556000918252919020925191518416700100000000000000000000000000000000029190931617910155613a898161534c565b905061371f565b5050505050565b6000612710613aa86107d084615335565b613ab291906153cd565b9050613abe8183614fcc565b73ffffffffffffffffffffffffffffffffffffffff808616600090815260046020908152604080832093881683529290529081208054909190613b029084906151b7565b909155505060015473ffffffffffffffffffffffffffffffffffffffff908116600090815260046020908152604080832093871683529290529081208054839290613b4e9084906151b7565b909155505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff838116602483015260448201839052613bda91859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505061477a565b505050565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600660205260408120815b6003820154811015613cd957816003018181548110613c9c57613c9c614fdf565b6000918252602090912001546fffffffffffffffffffffffffffffffff168411613cc9579150610f419050565b613cd28161534c565b9050613c7b565b506040517fd1ce01ea00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600081600003613d2757613d2082846153cd565b9050610f41565b8215613d535781613d39600185614fcc565b613d4391906153cd565b613d4e9060016151b7565b613501565b60009392505050565b6000612710613d6f61ffff841685615335565b61350191906153cd565b613d83818061503d565b9050600003613df0576040517f49d3358800000000000000000000000000000000000000000000000000000000815260040161287f9060208082526004908201527f6e616d6500000000000000000000000000000000000000000000000000000000604082015260600190565b613dfd602082018261503d565b9050600003613e68576040517f49d3358800000000000000000000000000000000000000000000000000000000815260206004820152600660248201527f73796d626f6c0000000000000000000000000000000000000000000000000000604482015260640161287f565b613e75604082018261503d565b9050600003612891576040517f49d3358800000000000000000000000000000000000000000000000000000000815260206004820152600360248201527f7572690000000000000000000000000000000000000000000000000000000000604482015260640161287f565b604080516101c08101825260008082526020820181905291810182905260608082018190526080820181905260a0820183905260c0820183905260e0820183905261010082018390526101208201839052610140820183905261016082018190526101808201526101a081019190915273ffffffffffffffffffffffffffffffffffffffff8083166000908152600660209081526040808320815160e0810183528154808716825261ffff7401000000000000000000000000000000000000000082048116838701527601000000000000000000000000000000000000000000008204168285015264ffffffffff780100000000000000000000000000000000000000000000000090910416606082015260018201549095166080860152600281015460a0860152600381018054835181860281018601909452808452889694929360c086019390929190879084015b8282101561408f57600084815260209081902060408051808201909152908401546fffffffffffffffffffffffffffffffff80821683527001000000000000000000000000000000009091041681830152825260019092019101614030565b50505050815250509050600081608001519050604051806101c00160405280836000015173ffffffffffffffffffffffffffffffffffffffff1681526020018673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015614135573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061415991906151e3565b60ff1681526020018473ffffffffffffffffffffffffffffffffffffffff166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa1580156141ac573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526141f291908101906154a0565b81526020018473ffffffffffffffffffffffffffffffffffffffff166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa158015614242573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405261428891908101906154a0565b8152602001836060015164ffffffffff1681526020016143158573ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156142ec573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061431091906151ca565b614810565b6fffffffffffffffffffffffffffffffff16815260200161433587611c46565b6fffffffffffffffffffffffffffffffff16815260200161435587611859565b6fffffffffffffffffffffffffffffffff168152602001836080015173ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156143d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143fb91906151e3565b60ff1681526020018273ffffffffffffffffffffffffffffffffffffffff166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa15801561444e573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405261449491908101906154a0565b81526020018273ffffffffffffffffffffffffffffffffffffffff166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa1580156144e4573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405261452a91908101906154a0565b81526020018360a001518152509350505050919050565b60405173ffffffffffffffffffffffffffffffffffffffff84811660248301528381166044830152606482018390526145879186918216906323b872dd90608401613b93565b50505050565b604080516004815260248101918290526000918291829173ffffffffffffffffffffffffffffffffffffffff881691906145c8908890615560565b60408051918290039091206020830180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009092169190911790525161462c9190615560565b600060405180830381855afa9150503d8060008114614667576040519150601f19603f3d011682016040523d82523d6000602084013e61466c565b606091505b50915091508180156134fc57505192909211949350505050565b6040513060388201526f5af43d82803e903d91602b57fd5bf3ff602482015260148101839052733d602d80600a3d3981f3363d3d373d3d3d363d738152605881018290526037600c82012060788201526055604390910120600090613501565b6000763d602d80600a3d3981f3363d3d373d3d3d363d730000008360601b60e81c176000526e5af43d82803e903d91602b57fd5bf38360781b1760205281603760096000f5905073ffffffffffffffffffffffffffffffffffffffff8116610f41576040517fc2f868f400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061479c73ffffffffffffffffffffffffffffffffffffffff84168361486a565b905080516000141580156147c15750808060200190518101906147bf919061557c565b155b15613bda576040517f5274afe700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416600482015260240161287f565b60006fffffffffffffffffffffffffffffffff821115614866576040517f6dfcc650000000000000000000000000000000000000000000000000000000008152608060048201526024810183905260440161287f565b5090565b606061350183836000846000808573ffffffffffffffffffffffffffffffffffffffff16848660405161489d9190615560565b60006040518083038185875af1925050503d80600081146148da576040519150601f19603f3d011682016040523d82523d6000602084013e6148df565b606091505b50915091506134fc8683836060826148fa57613d4e82614974565b815115801561491e575073ffffffffffffffffffffffffffffffffffffffff84163b155b1561496d576040517f9996b31500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8516600482015260240161287f565b5080613501565b8051156149845780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b803573ffffffffffffffffffffffffffffffffffffffff811681146149da57600080fd5b919050565b6000806000606084860312156149f457600080fd5b6149fd846149b6565b95602085013595506040909401359392505050565b6020808252825182820181905260009190848201906040850190845b81811015614a6057835173ffffffffffffffffffffffffffffffffffffffff1683529284019291840191600101614a2e565b50909695505050505050565b600060208284031215614a7e57600080fd5b613501826149b6565b600060c08284031215614a9957600080fd5b50919050565b60008060408385031215614ab257600080fd5b823567ffffffffffffffff80821115614aca57600080fd5b9084019060408287031215614ade57600080fd5b90925060208401359080821115614af457600080fd5b50614b0185828601614a87565b9150509250929050565b600060208284031215614b1d57600080fd5b5035919050565b60008060408385031215614b3757600080fd5b614b40836149b6565b9150614b4e602084016149b6565b90509250929050565b60005b83811015614b72578181015183820152602001614b5a565b50506000910152565b60008151808452614b93816020860160208601614b57565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006135016020830184614b7b565b60008060008060808587031215614bee57600080fd5b614bf7856149b6565b93506020850135925060408501359150614c13606086016149b6565b905092959194509250565b60008060408385031215614c3157600080fd5b614c3a836149b6565b946020939093013593505050565b60008060408385031215614c5b57600080fd5b823567ffffffffffffffff80821115614c7357600080fd5b9084019060608287031215614ade57600080fd5b600081518084526020808501945080840160005b83811015614cd857815180516fffffffffffffffffffffffffffffffff908116895290840151168388015260409096019590820190600101614c9b565b509495945050505050565b6020815260006135016020830184614c87565b805173ffffffffffffffffffffffffffffffffffffffff16825260006101c06020830151614d3c602086018273ffffffffffffffffffffffffffffffffffffffff169052565b506040830151614d51604086018260ff169052565b506060830151816060860152614d6982860182614b7b565b91505060808301518482036080860152614d838282614b7b565b91505060a0830151614d9e60a086018264ffffffffff169052565b5060c0830151614dc260c08601826fffffffffffffffffffffffffffffffff169052565b5060e0830151614de660e08601826fffffffffffffffffffffffffffffffff169052565b50610100838101516fffffffffffffffffffffffffffffffff16908501526101208084015173ffffffffffffffffffffffffffffffffffffffff16908501526101408084015160ff16908501526101608084015185830382870152614e4b8382614b7b565b925050506101808084015185830382870152614e678382614b7b565b6101a095860151969095019590955250919392505050565b60208152600061ffff80845116602084015280602085015116604084015250604083015160806060840152614eb760a0840182614cf6565b905060608401517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0848303016080850152614ef28282614c87565b95945050505050565b60008060408385031215614f0e57600080fd5b50508035926020909101359150565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015614f90577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0888603018452614f7e858351614cf6565b94509285019290850190600101614f44565b5092979650505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b81810381811115610f4157610f41614f9d565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261507257600080fd5b83018035915067ffffffffffffffff82111561508d57600080fd5b6020019150368190038213156120d857600080fd5b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b6040815260006150ff6040830186886150a2565b82810360208401526151128185876150a2565b979650505050505050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261515257600080fd5b83018035915067ffffffffffffffff82111561516d57600080fd5b6020019150600581901b36038213156120d857600080fd5b60006020828403121561519757600080fd5b81356fffffffffffffffffffffffffffffffff8116811461350157600080fd5b80820180821115610f4157610f41614f9d565b6000602082840312156151dc57600080fd5b5051919050565b6000602082840312156151f557600080fd5b815160ff8116811461350157600080fd5b600181815b8085111561525f57817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111561524557615245614f9d565b8085161561525257918102915b93841c939080029061520b565b509250929050565b60008261527657506001610f41565b8161528357506000610f41565b816001811461529957600281146152a3576152bf565b6001915050610f41565b60ff8411156152b4576152b4614f9d565b50506001821b610f41565b5060208310610133831016604e8410600b84101617156152e2575081810a610f41565b6152ec8383615206565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111561531e5761531e614f9d565b029392505050565b600061350160ff841683615267565b8082028115828204841417610f4157610f41614f9d565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361537d5761537d614f9d565b5060010190565b60608152600061539860608301888a6150a2565b82810360208401526153ab8187896150a2565b905082810360408401526153c08185876150a2565b9998505050505050505050565b600082615403577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60008161541757615417614f9d565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b60006020828403121561544f57600080fd5b813561ffff8116811461350157600080fd5b7fffffffffffffffffffffffffffffffffffffffff0000000000000000000000008460601b168152818360148301376000910160140190815292915050565b6000602082840312156154b257600080fd5b815167ffffffffffffffff808211156154ca57600080fd5b818401915084601f8301126154de57600080fd5b8151818111156154f0576154f061500e565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019083821181831017156155365761553661500e565b8160405282815287602084870101111561554f57600080fd5b615112836020830160208801614b57565b60008251615572818460208701614b57565b9190910192915050565b60006020828403121561558e57600080fd5b8151801515811461350157600080fdfea2646970667358221220351f2ae368865a13555f41433ee16f0aa1dd76517a44783ab00fbe69435f844964736f6c63430008140033000000000000000000000000aa70bc79fd1cb4a6fba717018351f0c3c64b79df0000000000000000000000006c61918eeccc306d35247338fdcf025af0f6120a00000000000000000000000082ca6d313bffe56e9096b16633dfd414148d66b100000000000000000000000000000000000000000000000000071afd498d000000000000000000000000000000000000000000000000000000000000000003e8
Deployed Bytecode
0x6080604052600436106102195760003560e01c8063995e5f921161011d578063c9cb204b116100b0578063f2fde38b1161007f578063f74bfe8e11610064578063f74bfe8e14610801578063fb8c13c814610821578063fccc28131461084157600080fd5b8063f2fde38b14610786578063f6a3d24e146107a657600080fd5b8063c9cb204b14610620578063cfc5562214610640578063d9fe0eae14610660578063dce0b4e41461077057600080fd5b8063a746ee2e116100ec578063a746ee2e14610586578063a9816b08146105b3578063ac4e9675146105e0578063c162c9161461060057600080fd5b8063995e5f92146104ec5780639c65003d146105195780639cc7becf146105515780639f181b5e1461057157600080fd5b8063715018a6116101b057806377e456cb1161017f57806385396d2b1161016457806385396d2b146104815780638da5cb5b14610494578063990e6005146104bf57600080fd5b806377e456cb1461042a578063840d885d1461044057600080fd5b8063715018a6146103a05780637348ed2f146103b5578063763e7da6146103d557806376a9864b146103f557600080fd5b806350801fb1116101ec57806350801fb1146102ce57806354fd4d50146103145780635a4d5311146103605780636fa237951461038057600080fd5b806307e329461461021e57806327e381a91461025457806330be6955146102765780634f64b2be146102ae575b600080fd5b34801561022a57600080fd5b5061023e6102393660046149df565b610857565b60405161024b9190614a12565b60405180910390f35b34801561026057600080fd5b5061027461026f366004614a6c565b610a90565b005b610289610284366004614a9f565b610b61565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161024b565b3480156102ba57600080fd5b506102896102c9366004614b0b565b610f47565b3480156102da57600080fd5b506103066102e9366004614b24565b600560209081526000928352604080842090915290825290205481565b60405190815260200161024b565b34801561032057600080fd5b50604080518082018252600781527f302e312e313230000000000000000000000000000000000000000000000000006020820152905161024b9190614bc5565b34801561036c57600080fd5b5061030661037b366004614bd8565b610f7e565b34801561038c57600080fd5b5061027461039b366004614b0b565b61119d565b3480156103ac57600080fd5b506102746111da565b3480156103c157600080fd5b506102746103d0366004614b0b565b6111ee565b3480156103e157600080fd5b506102746103f0366004614b24565b611267565b34801561040157600080fd5b50610415610410366004614c1e565b61138a565b6040805192835260208301919091520161024b565b34801561043657600080fd5b5061030660035481565b34801561044c57600080fd5b5061046061045b366004614a6c565b611859565b6040516fffffffffffffffffffffffffffffffff909116815260200161024b565b61028961048f366004614c48565b61197f565b3480156104a057600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff16610289565b3480156104cb57600080fd5b506001546102899073ffffffffffffffffffffffffffffffffffffffff1681565b3480156104f857600080fd5b5061050c610507366004614a6c565b611b94565b60405161024b9190614ce3565b34801561052557600080fd5b50610306610534366004614b24565b600460209081526000928352604080842090915290825290205481565b34801561055d57600080fd5b5061046061056c366004614a6c565b611c46565b34801561057d57600080fd5b50600754610306565b34801561059257600080fd5b506105a66105a1366004614a6c565b611cb0565b60405161024b9190614e7f565b3480156105bf57600080fd5b506105d36105ce366004614efb565b611ed3565b60405161024b9190614f1d565b3480156105ec57600080fd5b506104156105fb366004614b24565b61208c565b34801561060c57600080fd5b5061027461061b366004614a6c565b6120df565b34801561062c57600080fd5b5061041561063b366004614c1e565b612224565b34801561064c57600080fd5b5061027461065b366004614a6c565b6126ac565b34801561066c57600080fd5b5061071861067b366004614a6c565b60066020526000908152604090208054600182015460029092015473ffffffffffffffffffffffffffffffffffffffff8083169374010000000000000000000000000000000000000000840461ffff90811694760100000000000000000000000000000000000000000000810490911693780100000000000000000000000000000000000000000000000090910464ffffffffff16929091169086565b6040805173ffffffffffffffffffffffffffffffffffffffff978816815261ffff9687166020820152949095169484019490945264ffffffffff919091166060830152909216608083015260a082015260c00161024b565b34801561077c57600080fd5b5061030660025481565b34801561079257600080fd5b506102746107a1366004614a6c565b61282b565b3480156107b257600080fd5b506107f16107c1366004614a6c565b73ffffffffffffffffffffffffffffffffffffffff90811660009081526006602052604090206001015416151590565b604051901515815260200161024b565b34801561080d57600080fd5b5061030661081c366004614bd8565b612894565b34801561082d57600080fd5b5061023e61083c3660046149df565b612abb565b34801561084d57600080fd5b5061028961dead81565b6060818310158061087257506127106108708484614fcc565b115b156108a9576040517f891724d600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600754808311156108b8578092505b6000845b84811015610941578673ffffffffffffffffffffffffffffffffffffffff1660066000600784815481106108f2576108f2614fdf565b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff90811684529083019390935260409091019020600101541603610939578160010191505b6001016108bc565b508067ffffffffffffffff81111561095b5761095b61500e565b604051908082528060200260200182016040528015610984578160200160208202803683370190505b5092506000855b85811015610a85578773ffffffffffffffffffffffffffffffffffffffff1660066000600784815481106109c1576109c1614fdf565b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff90811684529083019390935260409091019020600101541603610a7d5760078181548110610a1457610a14614fdf565b6000918252602090912001548551600184019373ffffffffffffffffffffffffffffffffffffffff9092169187918110610a5057610a50614fdf565b73ffffffffffffffffffffffffffffffffffffffff90921660209283029190910190910152818314610a85575b60010161098b565b505050509392505050565b610a98612ce3565b60015473ffffffffffffffffffffffffffffffffffffffff16610ae7576040517f5059b85f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527fcf7686c0c53a1ab216c4cd81c1bc037136c791a61f30af4a78827c3915766044906020015b60405180910390a150565b60006002543414610b9e576040517f3403ce3700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610ba783612d36565b610bb082612e25565b6000610be87f000000000000000000000000aa70bc79fd1cb4a6fba717018351f0c3c64b79df610be3602087018761503d565b613451565b90508073ffffffffffffffffffffffffffffffffffffffff8116637029144c610c11878061503d565b610c1e60208a018a61503d565b6040518563ffffffff1660e01b8152600401610c3d94939291906150eb565b600060405180830381600087803b158015610c5757600080fd5b505af1158015610c6b573d6000803e3d6000fd5b5050600780546001810182556000919091527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c6880180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff861617905550610cea90508285613508565b610cfa6060850160408601614a6c565b73ffffffffffffffffffffffffffffffffffffffff9081169083167f6596c1670eb3390048d23721809c3da5d3f531375ac0e2cab0f77a808ed64331610d40888061503d565b610d4d60208b018b61503d565b604051610d5d94939291906150eb565b60405180910390a3610d7260a085018561511d565b6000818110610d8357610d83614fdf565b9050602002016020810190610d989190615185565b6fffffffffffffffffffffffffffffffff16600003610e975773ffffffffffffffffffffffffffffffffffffffff8116631b5ad8b533610ddb608088018861511d565b6000818110610dec57610dec614fdf565b9050602002016020810190610e019190615185565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815273ffffffffffffffffffffffffffffffffffffffff90921660048301526fffffffffffffffffffffffffffffffff166024820152604401600060405180830381600087803b158015610e7e57600080fd5b505af1158015610e92573d6000803e3d6000fd5b505050505b60025415610f3d5760015460025460405160009273ffffffffffffffffffffffffffffffffffffffff1691908381818185875af1925050503d8060008114610efb576040519150601f19603f3d011682016040523d82523d6000602084013e610f00565b606091505b5050905080610f3b576040517f0d4d59b300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505b5090505b92915050565b60078181548110610f5757600080fd5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16905081565b600073ffffffffffffffffffffffffffffffffffffffff8216610fcd576040517fd9b08f7600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080610fda8787612224565b9150915084821015611018576040517f07728bb000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff871660008181526006602052604080822081517ff4efe8f20000000000000000000000000000000000000000000000000000000081523360048201819052602482018c905292519194929363f4efe8f29260448084019382900301818387803b15801561109957600080fd5b505af11580156110ad573d6000803e3d6000fd5b5050505082846110bd91906151b7565b8260020160008282546110d09190614fcc565b9091555050815460018301546111009173ffffffffffffffffffffffffffffffffffffffff908116911685613a97565b600182015473ffffffffffffffffffffffffffffffffffffffff16611126818887613b59565b60018301546040805173ffffffffffffffffffffffffffffffffffffffff8a81168252602082018d905291810188905291811691848216918d16907f80a56de61873550ae491e454783a8dfc9d08a6f8bdace0887eabd4315c4b9da8906060015b60405180910390a4509298975050505050505050565b6111a5612ce3565b60028190556040518181527f88a973fd5506071e0cf878b30898776c47d5250a7ee1e6ee0b36df3b03c7c16a90602001610b56565b6111e2612ce3565b6111ec6000613bdf565b565b6111f6612ce3565b612710811115611232576040517f5059b85f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60038190556040518181527f21085b3501e0e4fa8e0c825e7ed36b44420471b9f3c5aef447cebe50b2db133d90602001610b56565b73ffffffffffffffffffffffffffffffffffffffff8281166000908152600660205260409020805490911633146112ca576040517f36a0203800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8216611317576040517f67f61c8200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8381169182178355604051908516907f9dcef3aa57f22970dfc6ff519e5421e041cc4153300a7dabe19bffe85e25568890600090a3505050565b73ffffffffffffffffffffffffffffffffffffffff808316600090815260066020526040812060010154909182918591166113f1576040517f2d350e9f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8360000361142b576040517fc01ae10500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8086166000908152600660209081526040808320815160e0810183528154808716825261ffff7401000000000000000000000000000000000000000082048116838701527601000000000000000000000000000000000000000000008204168285015264ffffffffff780100000000000000000000000000000000000000000000000090910416606082015260018201549095166080860152600281015460a0860152600381018054835181860281018601909452808452949594919360c08601939290879084015b8282101561156857600084815260209081902060408051808201909152908401546fffffffffffffffffffffffffffffffff80821683527001000000000000000000000000000000009091041681830152825260019092019101611509565b5050505081525050905060008160c001519050600087905060008173ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115f191906151ca565b905060006115ff89836151b7565b905061160a8a611c46565b6fffffffffffffffffffffffffffffffff16811115611655576040517f6b5b0f7c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008373ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156116a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116c691906151e3565b6116d190600a615326565b905089600080806116e28f88613c54565b90505b88518110156117e757600089828151811061170257611702614fdf565b602002602001015190508781600001516fffffffffffffffffffffffffffffffff1661172e9190614fcc565b92508483101561179a578260000361174657506117d7565b61177181602001516fffffffffffffffffffffffffffffffff168461176b9190615335565b87613d0c565b61177b90856151b7565b935061178783896151b7565b97506117938386614fcc565b94506117d5565b6117bf81602001516fffffffffffffffffffffffffffffffff168661176b9190615335565b6117c990856151b7565b935060009450506117e7565b505b6117e08161534c565b90506116e5565b508115806117f55750600083115b1561182c576040517fc01ae10500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61183a828a60200151613d5c565b9a506118468b836151b7565b9b50505050505050505050509250929050565b6000808273ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156118a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118cb91906151ca565b90506118d683611c46565b6fffffffffffffffffffffffffffffffff168110156118fb576118f88161534c565b90505b60006119078483613c54565b73ffffffffffffffffffffffffffffffffffffffff851660009081526006602052604090206003018054919250908290811061194557611945614fdf565b60009182526020909120015470010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff16949350505050565b600060025434146119bc576040517f3403ce3700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6119c583613d79565b6119ce82612e25565b6000611a017f0000000000000000000000006c61918eeccc306d35247338fdcf025af0f6120a610be3602087018761503d565b90508073ffffffffffffffffffffffffffffffffffffffff81166341e461a0611a2a878061503d565b611a3760208a018a61503d565b611a4460408c018c61503d565b6040518763ffffffff1660e01b8152600401611a6596959493929190615384565b600060405180830381600087803b158015611a7f57600080fd5b505af1158015611a93573d6000803e3d6000fd5b5050600780546001810182556000919091527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c6880180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff861617905550611b1290508285613508565b611b226060850160408601614a6c565b73ffffffffffffffffffffffffffffffffffffffff9081169083167f42d30c09380d6b8dbb77d95cae534a5c8fbf778789d87f58030bd74280437071611b68888061503d565b611b7560208b018b61503d565b611b8260408d018d61503d565b604051610d5d96959493929190615384565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600660209081526040808320600301805482518185028101850190935280835260609492939192909184015b82821015611c3b57600084815260209081902060408051808201909152908401546fffffffffffffffffffffffffffffffff80821683527001000000000000000000000000000000009091041681830152825260019092019101611bdc565b505050509050919050565b73ffffffffffffffffffffffffffffffffffffffff811660009081526006602052604081206003018054611c7c90600190614fcc565b81548110611c8c57611c8c614fdf565b6000918252602090912001546fffffffffffffffffffffffffffffffff1692915050565b611d4760408051608080820183526000808352602080840182905284516101c081018652828152908101829052808501829052606080820181905292810183905260a0810182905260c0810182905260e0810182905261010081018290526101208101829052610140810182905261016081018390526101808101929092526101a082015290918201908152602001606081525090565b73ffffffffffffffffffffffffffffffffffffffff8083166000908152600660209081526040808320815160e0810183528154808716825261ffff7401000000000000000000000000000000000000000082048116838701527601000000000000000000000000000000000000000000008204168285015264ffffffffff780100000000000000000000000000000000000000000000000090910416606082015260018201549095166080860152600281015460a0860152600381018054835181860281018601909452808452949594919360c08601939290879084015b82821015611e8457600084815260209081902060408051808201909152908401546fffffffffffffffffffffffffffffffff80821683527001000000000000000000000000000000009091041681830152825260019092019101611e25565b505050508152505090506040518060800160405280826020015161ffff168152602001826040015161ffff168152602001611ebe85613ee0565b81526020018260c00151815250915050919050565b60608183101580611eee57506103e8611eec8484614fcc565b115b15611f25576040517f891724d600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60075480831115611f34578092505b8383038067ffffffffffffffff811115611f5057611f5061500e565b60405190808252806020026020018201604052801561200c57816020015b604080516101c0810182526000808252602080830182905292820181905260608083018190526080830181905260a0830182905260c0830182905260e0830182905261010083018290526101208301829052610140830182905261016083018190526101808301526101a082015282527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff909201910181611f6e5790505b5092506000855b85811015612082576120586007828154811061203157612031614fdf565b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16613ee0565b855160018401938791811061206f5761206f614fdf565b6020908102919091010152600101612013565b5050505092915050565b73ffffffffffffffffffffffffffffffffffffffff8083166000818152600460209081526040808320948616808452948252808320549383526005825280832094835293905291909120545b9250929050565b33600081815260046020908152604080832073ffffffffffffffffffffffffffffffffffffffff861684529091528120549081900361214a576040517fbfa4e44600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff80831660008181526004602090815260408083209488168084529482528083208390559282526005815282822093825292909252812080548392906121a59084906151b7565b909155506121cc905073ffffffffffffffffffffffffffffffffffffffff84168383613b59565b6040805173ffffffffffffffffffffffffffffffffffffffff8581168252602082018490528416917fd1b893da855ca6a7c9cfbaff142da78c734a39d4811ad711fe7acfd6e5e433a4910160405180910390a2505050565b73ffffffffffffffffffffffffffffffffffffffff8083166000908152600660205260408120600101549091829185911661228b576040517f2d350e9f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b836000036122c5576040517fc01ae10500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8086166000908152600660209081526040808320815160e0810183528154808716825261ffff7401000000000000000000000000000000000000000082048116838701527601000000000000000000000000000000000000000000008204168285015264ffffffffff780100000000000000000000000000000000000000000000000090910416606082015260018201549095166080860152600281015460a0860152600381018054835181860281018601909452808452949594919360c08601939290879084015b8282101561240257600084815260209081902060408051808201909152908401546fffffffffffffffffffffffffffffffff808216835270010000000000000000000000000000000090910416818301528252600190920191016123a3565b5050505081525050905060008160c001519050600087905060008173ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612467573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061248b91906151ca565b9050808811156124c7576040517f4fffb8fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008273ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612514573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061253891906151e3565b61254390600a615326565b9050600089816125538d86613c54565b90505b811561264857600081156125ae5787612570600184614fcc565b8151811061258057612580614fdf565b6020026020010151600001516fffffffffffffffffffffffffffffffff16866125a99190614fcc565b6125b0565b855b905060008184106125c157816125c3565b835b9050858984815181106125d8576125d8614fdf565b6020026020010151602001516fffffffffffffffffffffffffffffffff16826126019190615335565b61260b91906153cd565b61261590866151b7565b94506126218185614fcc565b935061262d8188614fcc565b965082156126415761263e83615408565b92505b5050612556565b8115612680576040517fc01ae10500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61268e838960400151613d5c565b995061269a8a84614fcc565b9a505050505050505050509250929050565b73ffffffffffffffffffffffffffffffffffffffff811660009081527f42c63635470f1fb1d6d4b6441c413cb435b1ebb6fedd1896dd5e25d1399147dd60205260408120549081900361272b576040517fbfa4e44600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff821660009081527f42c63635470f1fb1d6d4b6441c413cb435b1ebb6fedd1896dd5e25d1399147dd602090815260408083208390557f7d509c07f0d4edcc2dd1b53aae68677132eb562dcba78e36381b63ccaf66e6ba909152812080548392906127ab9084906151b7565b909155506127d4905073ffffffffffffffffffffffffffffffffffffffff831661dead83613b59565b6040805173ffffffffffffffffffffffffffffffffffffffff841681526020810183905261dead917fd1b893da855ca6a7c9cfbaff142da78c734a39d4811ad711fe7acfd6e5e433a4910160405180910390a25050565b612833612ce3565b73ffffffffffffffffffffffffffffffffffffffff8116612888576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024015b60405180910390fd5b61289181613bdf565b50565b600073ffffffffffffffffffffffffffffffffffffffff82166128e3576040517fd9b08f7600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000806128f0878761138a565b915091508482111561292e576040517f07728bb000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8781166000908152600660205260409020600181015490913391166129688486614fcc565b83600201600082825461297b91906151b7565b9091555050825460018401546129ab9173ffffffffffffffffffffffffffffffffffffffff908116911686613a97565b6040517f1b5ad8b500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8881166004830152602482018b90528b1690631b5ad8b590604401600060405180830381600087803b158015612a1b57600080fd5b505af1158015612a2f573d6000803e3d6000fd5b50612a569250505073ffffffffffffffffffffffffffffffffffffffff8216833088614541565b60018301546040805173ffffffffffffffffffffffffffffffffffffffff8a81168252602082018d905291810188905291811691848216918d16907f02ed9b10d8b33a6a9fda664247bfd8f6248f74cff85cc84e56b7530c2fce560a90606001611187565b60608183101580612ad65750612710612ad48484614fcc565b115b15612b0d576040517f891724d600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60075480831115612b1c578092505b6000845b84811015612ba2578673ffffffffffffffffffffffffffffffffffffffff166006600060078481548110612b5657612b56614fdf565b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff90811684529083019390935260409091019020541603612b9a578160010191505b600101612b20565b508067ffffffffffffffff811115612bbc57612bbc61500e565b604051908082528060200260200182016040528015612be5578160200160208202803683370190505b5092506000855b85811015610a85578773ffffffffffffffffffffffffffffffffffffffff166006600060078481548110612c2257612c22614fdf565b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff90811684529083019390935260409091019020541603612cdb5760078181548110612c7257612c72614fdf565b6000918252602090912001548551600184019373ffffffffffffffffffffffffffffffffffffffff9092169187918110612cae57612cae614fdf565b73ffffffffffffffffffffffffffffffffffffffff90921660209283029190910190910152818314610a85575b600101612bec565b60005473ffffffffffffffffffffffffffffffffffffffff1633146111ec576040517f118cdaa700000000000000000000000000000000000000000000000000000000815233600482015260240161287f565b612d40818061503d565b9050600003612dad576040517f49d3358800000000000000000000000000000000000000000000000000000000815260040161287f9060208082526004908201527f6e616d6500000000000000000000000000000000000000000000000000000000604082015260600190565b612dba602082018261503d565b9050600003612891576040517f49d3358800000000000000000000000000000000000000000000000000000000815260206004820152600660248201527f73796d626f6c0000000000000000000000000000000000000000000000000000604482015260640161287f565b600354612e35602083018361543d565b61ffff161115612ea1576040517f49d3358800000000000000000000000000000000000000000000000000000000815260206004820152600b60248201527f6d696e74526f79616c7479000000000000000000000000000000000000000000604482015260640161287f565b600354612eb4604083016020840161543d565b61ffff161115612f20576040517f49d3358800000000000000000000000000000000000000000000000000000000815260206004820152600b60248201527f6275726e526f79616c7479000000000000000000000000000000000000000000604482015260640161287f565b6000612f326060830160408401614a6c565b905073ffffffffffffffffffffffffffffffffffffffff8116612fb1576040517f49d3358800000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f72657365727665546f6b656e0000000000000000000000000000000000000000604482015260640161287f565b612ff2816040518060400160405280600a81526020017f646563696d616c73282900000000000000000000000000000000000000000000815250601f61458d565b613058576040517f59f5822400000000000000000000000000000000000000000000000000000000815260206004820152600860248201527f646563696d616c73000000000000000000000000000000000000000000000000604482015260640161287f565b613099816040518060400160405280600681526020017f6e616d6528290000000000000000000000000000000000000000000000000000815250605f61458d565b613101576040517f59f5822400000000000000000000000000000000000000000000000000000000815260040161287f9060208082526004908201527f6e616d6500000000000000000000000000000000000000000000000000000000604082015260600190565b613142816040518060400160405280600881526020017f73796d626f6c2829000000000000000000000000000000000000000000000000815250605f61458d565b6131a8576040517f59f5822400000000000000000000000000000000000000000000000000000000815260206004820152600660248201527f73796d626f6c0000000000000000000000000000000000000000000000000000604482015260640161287f565b6131b86080830160608401615185565b6fffffffffffffffffffffffffffffffff16600003613233576040517f49d3358800000000000000000000000000000000000000000000000000000000815260206004820152600960248201527f6d6178537570706c790000000000000000000000000000000000000000000000604482015260640161287f565b613240608083018361511d565b1590508061327b57507f00000000000000000000000000000000000000000000000000000000000003e8613277608084018461511d565b9050115b156132e2576040517f1afd40d600000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f494e56414c49445f535445505f4c454e47544800000000000000000000000000604482015260640161287f565b6132ef60a083018361511d565b90506132fe608084018461511d565b905014613367576040517f1afd40d600000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f535445505f4c454e4754485f444f5f4e4f545f4d415443480000000000000000604482015260640161287f565b6133776080830160608401615185565b6fffffffffffffffffffffffffffffffff16613396608084018461511d565b60016133a5608087018761511d565b6133b0929150614fcc565b8181106133bf576133bf614fdf565b90506020020160208101906133d49190615185565b6fffffffffffffffffffffffffffffffff161461344d576040517f1afd40d600000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4d41585f535550504c595f4d49534d4154434800000000000000000000000000604482015260640161287f565b5050565b60008030848460405160200161346993929190615461565b604051602081830303815290604052805190602001209050600061348d8683614686565b73ffffffffffffffffffffffffffffffffffffffff80821660009081526006602052604090206001015491925016156134f2576040517f358b663800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6134fc86836146e6565b925050505b9392505050565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260066020908152604090912080547fffffffffffffffffffffffff00000000000000000000000000000000000000001633178155906135659083018361543d565b815461ffff9190911674010000000000000000000000000000000000000000027fffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffff9091161781556135bc604083016020840161543d565b81547fffffff00000000000000ffffffffffffffffffffffffffffffffffffffffffff1676010000000000000000000000000000000000000000000061ffff92909216919091027fffffff0000000000ffffffffffffffffffffffffffffffffffffffffffffffff161778010000000000000000000000000000000000000000000000004264ffffffffff160217815561365c6060830160408401614a6c565b8160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008373ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156136eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061370f91906151e3565b61371a90600a615326565b905060005b61372c608085018561511d565b9050811015613a90576000613744608086018661511d565b8381811061375457613754614fdf565b90506020020160208101906137699190615185565b6fffffffffffffffffffffffffffffffff169050600061378c60a087018761511d565b8481811061379c5761379c614fdf565b90506020020160208101906137b19190615185565b6fffffffffffffffffffffffffffffffff1690508160000361382f576040517f1afd40d600000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f535445505f43414e4e4f545f42455f5a45524f00000000000000000000000000604482015260640161287f565b6000811180156138475750836138458284615335565b105b156138ae576040517f1afd40d600000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f535445505f52414e475f4f525f50524943455f544f4f5f534d414c4c00000000604482015260640161287f565b8215613a20576138c1608087018761511d565b6138cc600186614fcc565b8181106138db576138db614fdf565b90506020020160208101906138f09190615185565b6fffffffffffffffffffffffffffffffff16821161396a576040517f1afd40d600000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f44454352454153494e475f52414e474500000000000000000000000000000000604482015260640161287f565b61397760a087018761511d565b613982600186614fcc565b81811061399157613991614fdf565b90506020020160208101906139a69190615185565b6fffffffffffffffffffffffffffffffff168111613a20576040517f1afd40d600000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f44454352454153494e475f505249434500000000000000000000000000000000604482015260640161287f565b604080518082019091526fffffffffffffffffffffffffffffffff928316815290821660208083019182526003870180546001810182556000918252919020925191518416700100000000000000000000000000000000029190931617910155613a898161534c565b905061371f565b5050505050565b6000612710613aa86107d084615335565b613ab291906153cd565b9050613abe8183614fcc565b73ffffffffffffffffffffffffffffffffffffffff808616600090815260046020908152604080832093881683529290529081208054909190613b029084906151b7565b909155505060015473ffffffffffffffffffffffffffffffffffffffff908116600090815260046020908152604080832093871683529290529081208054839290613b4e9084906151b7565b909155505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff838116602483015260448201839052613bda91859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505061477a565b505050565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600660205260408120815b6003820154811015613cd957816003018181548110613c9c57613c9c614fdf565b6000918252602090912001546fffffffffffffffffffffffffffffffff168411613cc9579150610f419050565b613cd28161534c565b9050613c7b565b506040517fd1ce01ea00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600081600003613d2757613d2082846153cd565b9050610f41565b8215613d535781613d39600185614fcc565b613d4391906153cd565b613d4e9060016151b7565b613501565b60009392505050565b6000612710613d6f61ffff841685615335565b61350191906153cd565b613d83818061503d565b9050600003613df0576040517f49d3358800000000000000000000000000000000000000000000000000000000815260040161287f9060208082526004908201527f6e616d6500000000000000000000000000000000000000000000000000000000604082015260600190565b613dfd602082018261503d565b9050600003613e68576040517f49d3358800000000000000000000000000000000000000000000000000000000815260206004820152600660248201527f73796d626f6c0000000000000000000000000000000000000000000000000000604482015260640161287f565b613e75604082018261503d565b9050600003612891576040517f49d3358800000000000000000000000000000000000000000000000000000000815260206004820152600360248201527f7572690000000000000000000000000000000000000000000000000000000000604482015260640161287f565b604080516101c08101825260008082526020820181905291810182905260608082018190526080820181905260a0820183905260c0820183905260e0820183905261010082018390526101208201839052610140820183905261016082018190526101808201526101a081019190915273ffffffffffffffffffffffffffffffffffffffff8083166000908152600660209081526040808320815160e0810183528154808716825261ffff7401000000000000000000000000000000000000000082048116838701527601000000000000000000000000000000000000000000008204168285015264ffffffffff780100000000000000000000000000000000000000000000000090910416606082015260018201549095166080860152600281015460a0860152600381018054835181860281018601909452808452889694929360c086019390929190879084015b8282101561408f57600084815260209081902060408051808201909152908401546fffffffffffffffffffffffffffffffff80821683527001000000000000000000000000000000009091041681830152825260019092019101614030565b50505050815250509050600081608001519050604051806101c00160405280836000015173ffffffffffffffffffffffffffffffffffffffff1681526020018673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015614135573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061415991906151e3565b60ff1681526020018473ffffffffffffffffffffffffffffffffffffffff166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa1580156141ac573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526141f291908101906154a0565b81526020018473ffffffffffffffffffffffffffffffffffffffff166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa158015614242573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405261428891908101906154a0565b8152602001836060015164ffffffffff1681526020016143158573ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156142ec573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061431091906151ca565b614810565b6fffffffffffffffffffffffffffffffff16815260200161433587611c46565b6fffffffffffffffffffffffffffffffff16815260200161435587611859565b6fffffffffffffffffffffffffffffffff168152602001836080015173ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156143d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143fb91906151e3565b60ff1681526020018273ffffffffffffffffffffffffffffffffffffffff166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa15801561444e573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405261449491908101906154a0565b81526020018273ffffffffffffffffffffffffffffffffffffffff166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa1580156144e4573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405261452a91908101906154a0565b81526020018360a001518152509350505050919050565b60405173ffffffffffffffffffffffffffffffffffffffff84811660248301528381166044830152606482018390526145879186918216906323b872dd90608401613b93565b50505050565b604080516004815260248101918290526000918291829173ffffffffffffffffffffffffffffffffffffffff881691906145c8908890615560565b60408051918290039091206020830180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009092169190911790525161462c9190615560565b600060405180830381855afa9150503d8060008114614667576040519150601f19603f3d011682016040523d82523d6000602084013e61466c565b606091505b50915091508180156134fc57505192909211949350505050565b6040513060388201526f5af43d82803e903d91602b57fd5bf3ff602482015260148101839052733d602d80600a3d3981f3363d3d373d3d3d363d738152605881018290526037600c82012060788201526055604390910120600090613501565b6000763d602d80600a3d3981f3363d3d373d3d3d363d730000008360601b60e81c176000526e5af43d82803e903d91602b57fd5bf38360781b1760205281603760096000f5905073ffffffffffffffffffffffffffffffffffffffff8116610f41576040517fc2f868f400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061479c73ffffffffffffffffffffffffffffffffffffffff84168361486a565b905080516000141580156147c15750808060200190518101906147bf919061557c565b155b15613bda576040517f5274afe700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416600482015260240161287f565b60006fffffffffffffffffffffffffffffffff821115614866576040517f6dfcc650000000000000000000000000000000000000000000000000000000008152608060048201526024810183905260440161287f565b5090565b606061350183836000846000808573ffffffffffffffffffffffffffffffffffffffff16848660405161489d9190615560565b60006040518083038185875af1925050503d80600081146148da576040519150601f19603f3d011682016040523d82523d6000602084013e6148df565b606091505b50915091506134fc8683836060826148fa57613d4e82614974565b815115801561491e575073ffffffffffffffffffffffffffffffffffffffff84163b155b1561496d576040517f9996b31500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8516600482015260240161287f565b5080613501565b8051156149845780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b803573ffffffffffffffffffffffffffffffffffffffff811681146149da57600080fd5b919050565b6000806000606084860312156149f457600080fd5b6149fd846149b6565b95602085013595506040909401359392505050565b6020808252825182820181905260009190848201906040850190845b81811015614a6057835173ffffffffffffffffffffffffffffffffffffffff1683529284019291840191600101614a2e565b50909695505050505050565b600060208284031215614a7e57600080fd5b613501826149b6565b600060c08284031215614a9957600080fd5b50919050565b60008060408385031215614ab257600080fd5b823567ffffffffffffffff80821115614aca57600080fd5b9084019060408287031215614ade57600080fd5b90925060208401359080821115614af457600080fd5b50614b0185828601614a87565b9150509250929050565b600060208284031215614b1d57600080fd5b5035919050565b60008060408385031215614b3757600080fd5b614b40836149b6565b9150614b4e602084016149b6565b90509250929050565b60005b83811015614b72578181015183820152602001614b5a565b50506000910152565b60008151808452614b93816020860160208601614b57565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006135016020830184614b7b565b60008060008060808587031215614bee57600080fd5b614bf7856149b6565b93506020850135925060408501359150614c13606086016149b6565b905092959194509250565b60008060408385031215614c3157600080fd5b614c3a836149b6565b946020939093013593505050565b60008060408385031215614c5b57600080fd5b823567ffffffffffffffff80821115614c7357600080fd5b9084019060608287031215614ade57600080fd5b600081518084526020808501945080840160005b83811015614cd857815180516fffffffffffffffffffffffffffffffff908116895290840151168388015260409096019590820190600101614c9b565b509495945050505050565b6020815260006135016020830184614c87565b805173ffffffffffffffffffffffffffffffffffffffff16825260006101c06020830151614d3c602086018273ffffffffffffffffffffffffffffffffffffffff169052565b506040830151614d51604086018260ff169052565b506060830151816060860152614d6982860182614b7b565b91505060808301518482036080860152614d838282614b7b565b91505060a0830151614d9e60a086018264ffffffffff169052565b5060c0830151614dc260c08601826fffffffffffffffffffffffffffffffff169052565b5060e0830151614de660e08601826fffffffffffffffffffffffffffffffff169052565b50610100838101516fffffffffffffffffffffffffffffffff16908501526101208084015173ffffffffffffffffffffffffffffffffffffffff16908501526101408084015160ff16908501526101608084015185830382870152614e4b8382614b7b565b925050506101808084015185830382870152614e678382614b7b565b6101a095860151969095019590955250919392505050565b60208152600061ffff80845116602084015280602085015116604084015250604083015160806060840152614eb760a0840182614cf6565b905060608401517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0848303016080850152614ef28282614c87565b95945050505050565b60008060408385031215614f0e57600080fd5b50508035926020909101359150565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015614f90577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0888603018452614f7e858351614cf6565b94509285019290850190600101614f44565b5092979650505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b81810381811115610f4157610f41614f9d565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261507257600080fd5b83018035915067ffffffffffffffff82111561508d57600080fd5b6020019150368190038213156120d857600080fd5b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b6040815260006150ff6040830186886150a2565b82810360208401526151128185876150a2565b979650505050505050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261515257600080fd5b83018035915067ffffffffffffffff82111561516d57600080fd5b6020019150600581901b36038213156120d857600080fd5b60006020828403121561519757600080fd5b81356fffffffffffffffffffffffffffffffff8116811461350157600080fd5b80820180821115610f4157610f41614f9d565b6000602082840312156151dc57600080fd5b5051919050565b6000602082840312156151f557600080fd5b815160ff8116811461350157600080fd5b600181815b8085111561525f57817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111561524557615245614f9d565b8085161561525257918102915b93841c939080029061520b565b509250929050565b60008261527657506001610f41565b8161528357506000610f41565b816001811461529957600281146152a3576152bf565b6001915050610f41565b60ff8411156152b4576152b4614f9d565b50506001821b610f41565b5060208310610133831016604e8410600b84101617156152e2575081810a610f41565b6152ec8383615206565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111561531e5761531e614f9d565b029392505050565b600061350160ff841683615267565b8082028115828204841417610f4157610f41614f9d565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361537d5761537d614f9d565b5060010190565b60608152600061539860608301888a6150a2565b82810360208401526153ab8187896150a2565b905082810360408401526153c08185876150a2565b9998505050505050505050565b600082615403577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60008161541757615417614f9d565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b60006020828403121561544f57600080fd5b813561ffff8116811461350157600080fd5b7fffffffffffffffffffffffffffffffffffffffff0000000000000000000000008460601b168152818360148301376000910160140190815292915050565b6000602082840312156154b257600080fd5b815167ffffffffffffffff808211156154ca57600080fd5b818401915084601f8301126154de57600080fd5b8151818111156154f0576154f061500e565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019083821181831017156155365761553661500e565b8160405282815287602084870101111561554f57600080fd5b615112836020830160208801614b57565b60008251615572818460208701614b57565b9190910192915050565b60006020828403121561558e57600080fd5b8151801515811461350157600080fdfea2646970667358221220351f2ae368865a13555f41433ee16f0aa1dd76517a44783ab00fbe69435f844964736f6c63430008140033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000aa70bc79fd1cb4a6fba717018351f0c3c64b79df0000000000000000000000006c61918eeccc306d35247338fdcf025af0f6120a00000000000000000000000082ca6d313bffe56e9096b16633dfd414148d66b100000000000000000000000000000000000000000000000000071afd498d000000000000000000000000000000000000000000000000000000000000000003e8
-----Decoded View---------------
Arg [0] : tokenImplementation (address): 0xAa70bC79fD1cB4a6FBA717018351F0C3c64B79Df
Arg [1] : multiTokenImplementation (address): 0x6c61918eECcC306D35247338FDcf025af0f6120A
Arg [2] : protocolBeneficiary_ (address): 0x82CA6d313BffE56E9096b16633dfD414148D66b1
Arg [3] : creationFee_ (uint256): 2000000000000000
Arg [4] : maxSteps (uint256): 1000
-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 000000000000000000000000aa70bc79fd1cb4a6fba717018351f0c3c64b79df
Arg [1] : 0000000000000000000000006c61918eeccc306d35247338fdcf025af0f6120a
Arg [2] : 00000000000000000000000082ca6d313bffe56e9096b16633dfd414148d66b1
Arg [3] : 00000000000000000000000000000000000000000000000000071afd498d0000
Arg [4] : 00000000000000000000000000000000000000000000000000000000000003e8
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|---|---|---|---|---|
BASE | 35.70% | $2,730.87 | 78.9597 | $215,628.61 | |
BASE | 27.44% | $0.303732 | 545,823.0788 | $165,783.94 | |
BASE | 12.11% | $0.011634 | 6,285,618.9256 | $73,128.59 | |
BASE | 8.89% | $0.000052 | 1,024,550,774.757 | $53,706.95 | |
BASE | 0.66% | $0.004248 | 945,441.8132 | $4,016.24 | |
BASE | 0.52% | $97,767 | 0.0322 | $3,152.23 | |
BASE | 0.26% | $0.000028 | 56,883,170.6377 | $1,598.42 | |
BASE | 0.16% | $0.000535 | 1,806,411.1828 | $965.85 | |
BASE | 0.14% | $0.999931 | 839.1714 | $839.11 | |
BASE | 0.11% | $0.000651 | 1,027,574.5098 | $669.21 | |
BASE | 0.09% | $0.045547 | 12,409.4253 | $565.21 | |
BASE | 0.07% | $0.069857 | 6,031.0303 | $421.31 | |
BASE | 0.06% | $0.000016 | 22,996,245.1154 | $378.98 | |
BASE | 0.05% | $0.023851 | 13,747.3277 | $327.88 | |
BASE | 0.05% | $0.00446 | 67,961.1898 | $303.12 | |
BASE | 0.03% | $0.826784 | 218.629 | $180.76 | |
BASE | 0.02% | $0.000122 | 1,085,987.8225 | $132.92 | |
BASE | 0.02% | $0.032676 | 3,472.9663 | $113.48 | |
BASE | 0.02% | $2,973.8 | 0.0336 | $100 | |
BASE | 0.01% | $0.003684 | 23,206.4802 | $85.5 | |
BASE | <0.01% | $0.009665 | 5,601.8612 | $54.14 | |
BASE | <0.01% | <$0.000001 | 632,241,754 | $16.31 | |
BASE | <0.01% | $0.000015 | 672,517.3093 | $10.38 | |
BASE | <0.01% | $97,495 | 0.00004038 | $3.94 | |
BASE | <0.01% | $0.169247 | 18.0946 | $3.06 | |
BASE | <0.01% | $0.016973 | 174.2001 | $2.96 | |
BASE | <0.01% | $0.000001 | 3,228,739.729 | $2.86 | |
BASE | <0.01% | $0.007083 | 388.374 | $2.75 | |
BASE | <0.01% | $0.999718 | 2.2807 | $2.28 | |
BASE | <0.01% | $0.999855 | 1.6177 | $1.62 | |
BASE | <0.01% | $152.06 | 0.0103 | $1.57 | |
BASE | <0.01% | $0.999629 | 1.1015 | $1.1 | |
BASE | <0.01% | $6.23 | 0.1602 | $0.9982 | |
BASE | <0.01% | $97,170 | 0.00001 | $0.9717 | |
BASE | <0.01% | $1 | 0.9312 | $0.9311 | |
BASE | <0.01% | $0.000001 | 741,500 | $0.7532 | |
BASE | <0.01% | $1 | 0.7428 | $0.7435 | |
BASE | <0.01% | $1 | 0.7333 | $0.7348 | |
BASE | <0.01% | <$0.000001 | 90,885,021.1993 | $0.4544 | |
BASE | <0.01% | $1.03 | 0.4001 | $0.4116 | |
BASE | <0.01% | $1.37 | 0.199 | $0.2726 | |
BASE | <0.01% | $0.006344 | 38 | $0.241 | |
BASE | <0.01% | $0.00023 | 500 | $0.1148 | |
BASE | <0.01% | <$0.000001 | 113,714,027.454 | $0.1023 | |
ETH | 5.93% | $3,255.74 | 11 | $35,813.14 | |
ETH | 1.36% | $0.002053 | 4,006,180.0343 | $8,222.8 | |
ETH | 0.11% | $2,728.93 | 0.2414 | $658.68 | |
ETH | 0.07% | $0.303732 | 1,342.4757 | $407.75 | |
ETH | 0.02% | $97,767 | 0.00123369 | $120.61 | |
ETH | <0.01% | $0.000017 | 3,160,812.1799 | $53.35 | |
ETH | <0.01% | $0.999938 | 48.5923 | $48.59 | |
ETH | <0.01% | $0.95939 | 18.8466 | $18.08 | |
ETH | <0.01% | $0.999931 | 10.9642 | $10.96 | |
ETH | <0.01% | $97,555 | 0.0001003 | $9.78 | |
ETH | <0.01% | $0.00001 | 319,204.5895 | $3.22 | |
ETH | <0.01% | $0.756857 | 3.0007 | $2.27 | |
BSC | 3.45% | $697.25 | 29.8598 | $20,819.68 | |
BSC | 0.58% | $0.000003 | 1,380,414,639.1978 | $3,492.45 | |
BSC | <0.01% | $0.99994 | 16.0371 | $16.04 | |
BSC | <0.01% | $97,685.33 | 0.00010016 | $9.78 | |
BSC | <0.01% | $0.000005 | 804,828 | $3.89 | |
BSC | <0.01% | $2.66 | 0.9247 | $2.46 | |
BSC | <0.01% | $0.000017 | 110,577.2536 | $1.86 | |
BSC | <0.01% | $2.46 | 0.2948 | $0.7261 | |
BSC | <0.01% | $2,727.44 | 0.00009995 | $0.2726 | |
BSC | <0.01% | $1 | 0.1037 | $0.1037 | |
ARB | 1.44% | $2,727.12 | 3.1998 | $8,726.29 | |
ARB | 0.04% | $3,254.85 | 0.0654 | $212.78 | |
ARB | <0.01% | $0.494129 | 72.5024 | $35.83 | |
ARB | <0.01% | $0.123691 | 69.3775 | $8.58 | |
ARB | <0.01% | $0.999903 | 2.6412 | $2.64 | |
ARB | <0.01% | $0.999346 | 1.5867 | $1.59 | |
ARB | <0.01% | $0.999941 | 1.0164 | $1.02 | |
APE | 0.29% | $0.75302 | 2,341.836 | $1,763.45 | |
POL | 0.10% | $0.99994 | 594.8523 | $594.82 | |
POL | 0.08% | $0.328567 | 1,382.8865 | $454.37 | |
POL | 0.02% | $0.00085 | 107,814.7902 | $91.68 | |
POL | 0.01% | $0.999469 | 67.5364 | $67.5 | |
POL | <0.01% | $0.999902 | 14.043 | $14.04 | |
POL | <0.01% | $2,729.37 | 0.00054827 | $1.5 | |
POL | <0.01% | $0.000017 | 31,824.3585 | $0.5368 | |
OP | 0.02% | $2,730.87 | 0.0373 | $101.83 | |
OP | <0.01% | $1.28 | 43.0797 | $55.04 | |
OP | <0.01% | $0.999931 | 5.0203 | $5.02 | |
OP | <0.01% | $0.999425 | 3.6669 | $3.66 | |
OP | <0.01% | $0.999938 | 3.1008 | $3.1 | |
OP | <0.01% | $1.12 | 1.4782 | $1.65 |
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.