More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 55 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Create Token | 5161282 | 30 mins ago | IN | 1 APE | 0.3256145 | ||||
Create Token | 5119138 | 9 hrs ago | IN | 1 APE | 0.32846231 | ||||
Create Token | 5111937 | 11 hrs ago | IN | 1 APE | 0.32844433 | ||||
Create Token | 5092570 | 16 hrs ago | IN | 1 APE | 0.32800176 | ||||
Create Token | 5076586 | 21 hrs ago | IN | 1 APE | 0.32800616 | ||||
Create Token | 5072718 | 22 hrs ago | IN | 1 APE | 0.32561603 | ||||
Claim Royalties | 4967956 | 42 hrs ago | IN | 0 APE | 0.00292808 | ||||
Claim Royalties | 3528645 | 19 days ago | IN | 0 APE | 0.00292808 | ||||
Create Token | 2636824 | 25 days ago | IN | 1 APE | 0.07239283 | ||||
Burn | 1162255 | 31 days ago | IN | 0 APE | 0.03440812 | ||||
Create Token | 916103 | 32 days ago | IN | 1 APE | 0.05084201 | ||||
Claim Royalties | 823641 | 32 days ago | IN | 0 APE | 0.00162397 | ||||
Claim Royalties | 823054 | 32 days ago | IN | 0 APE | 0.00292805 | ||||
Create Token | 818872 | 32 days ago | IN | 1 APE | 0.0705657 | ||||
Create Token | 814697 | 32 days ago | IN | 1 APE | 0.00862793 | ||||
Create Token | 770001 | 32 days ago | IN | 1 APE | 0.07057101 | ||||
Claim Royalties | 719545 | 32 days ago | IN | 0 APE | 0.00162397 | ||||
Claim Royalties | 718806 | 32 days ago | IN | 0 APE | 0.00162397 | ||||
Burn | 672797 | 32 days ago | IN | 0 APE | 0.03423378 | ||||
Create Token | 633156 | 33 days ago | IN | 1 APE | 0.32557238 | ||||
Claim Royalties | 612414 | 33 days ago | IN | 0 APE | 0.00292805 | ||||
Create Token | 571933 | 33 days ago | IN | 1 APE | 0.3255736 | ||||
Create Token | 567919 | 33 days ago | IN | 1 APE | 0.07053455 | ||||
Create Token | 566121 | 33 days ago | IN | 1 APE | 0.0724092 | ||||
Burn | 561419 | 33 days ago | IN | 0 APE | 0.03595708 |
Latest 25 internal transactions (View All)
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
5161282 | 30 mins ago | 1 APE | ||||
5161282 | 30 mins ago | Contract Creation | 0 APE | |||
5119138 | 9 hrs ago | 1 APE | ||||
5119138 | 9 hrs ago | Contract Creation | 0 APE | |||
5111937 | 11 hrs ago | 1 APE | ||||
5111937 | 11 hrs ago | Contract Creation | 0 APE | |||
5092570 | 16 hrs ago | 1 APE | ||||
5092570 | 16 hrs ago | Contract Creation | 0 APE | |||
5076586 | 21 hrs ago | 1 APE | ||||
5076586 | 21 hrs ago | Contract Creation | 0 APE | |||
5072718 | 22 hrs ago | 1 APE | ||||
5072718 | 22 hrs ago | Contract Creation | 0 APE | |||
2636824 | 25 days ago | 1 APE | ||||
2636824 | 25 days ago | Contract Creation | 0 APE | |||
916103 | 32 days ago | 1 APE | ||||
916103 | 32 days ago | Contract Creation | 0 APE | |||
818872 | 32 days ago | 1 APE | ||||
818872 | 32 days ago | Contract Creation | 0 APE | |||
814697 | 32 days ago | 1 APE | ||||
814697 | 32 days ago | Contract Creation | 0 APE | |||
770001 | 32 days ago | 1 APE | ||||
770001 | 32 days ago | Contract Creation | 0 APE | |||
633156 | 33 days ago | 1 APE | ||||
633156 | 33 days ago | Contract Creation | 0 APE | |||
571933 | 33 days ago | 1 APE |
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 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: BUSL-1.1 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: BUSL-1.1 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: BUSL-1.1 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: BUSL-1.1 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: BUSL-1.1 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
60e06040526113886003553480156200001757600080fd5b50604051620058be380380620058be8339810160408190526200003a916200025f565b82823380806200006557604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b6200007081620001f2565b5050600180546001600160a01b0319166001600160a01b039384161790556002558516620000e25760405163643b81d760e01b815260206004820152601360248201527f746f6b656e496d706c656d656e746174696f6e0000000000000000000000000060448201526064016200005c565b6001600160a01b0384166200013b5760405163643b81d760e01b815260206004820152601860248201527f6d756c7469546f6b656e496d706c656d656e746174696f6e000000000000000060448201526064016200005c565b6001600160a01b038316620001945760405163643b81d760e01b815260206004820152601360248201527f70726f746f636f6c42656e65666963696172790000000000000000000000000060448201526064016200005c565b80600003620001d25760405163643b81d760e01b81526020600482015260086024820152676d6178537465707360c01b60448201526064016200005c565b6001600160a01b0394851660a0529290931660c0525060805250620002bc565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b03811681146200025a57600080fd5b919050565b600080600080600060a086880312156200027857600080fd5b620002838662000242565b9450620002936020870162000242565b9350620002a36040870162000242565b6060870151608090970151959894975095949392505050565b60805160a05160c0516155d2620002ec60003960006119d301526000610bb50152600061324901526155d26000f3fe6080604052600436106102195760003560e01c8063995e5f921161011d578063c9cb204b116100b0578063f2fde38b1161007f578063f74bfe8e11610064578063f74bfe8e14610801578063fb8c13c814610821578063fccc28131461084157600080fd5b8063f2fde38b14610786578063f6a3d24e146107a657600080fd5b8063c9cb204b14610620578063cfc5562214610640578063d9fe0eae14610660578063dce0b4e41461077057600080fd5b8063a746ee2e116100ec578063a746ee2e14610586578063a9816b08146105b3578063ac4e9675146105e0578063c162c9161461060057600080fd5b8063995e5f92146104ec5780639c65003d146105195780639cc7becf146105515780639f181b5e1461057157600080fd5b8063715018a6116101b057806377e456cb1161017f57806385396d2b1161016457806385396d2b146104815780638da5cb5b14610494578063990e6005146104bf57600080fd5b806377e456cb1461042a578063840d885d1461044057600080fd5b8063715018a6146103a05780637348ed2f146103b5578063763e7da6146103d557806376a9864b146103f557600080fd5b806350801fb1116101ec57806350801fb1146102ce57806354fd4d50146103145780635a4d5311146103605780636fa237951461038057600080fd5b806307e329461461021e57806327e381a91461025457806330be6955146102765780634f64b2be146102ae575b600080fd5b34801561022a57600080fd5b5061023e6102393660046149dd565b610857565b60405161024b9190614a10565b60405180910390f35b34801561026057600080fd5b5061027461026f366004614a6a565b610a90565b005b610289610284366004614a9d565b610b5f565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161024b565b3480156102ba57600080fd5b506102896102c9366004614b09565b610f45565b3480156102da57600080fd5b506103066102e9366004614b22565b600560209081526000928352604080842090915290825290205481565b60405190815260200161024b565b34801561032057600080fd5b50604080518082018252600781527f302e312e313230000000000000000000000000000000000000000000000000006020820152905161024b9190614bc3565b34801561036c57600080fd5b5061030661037b366004614bd6565b610f7c565b34801561038c57600080fd5b5061027461039b366004614b09565b61119b565b3480156103ac57600080fd5b506102746111d8565b3480156103c157600080fd5b506102746103d0366004614b09565b6111ec565b3480156103e157600080fd5b506102746103f0366004614b22565b611265565b34801561040157600080fd5b50610415610410366004614c1c565b611388565b6040805192835260208301919091520161024b565b34801561043657600080fd5b5061030660035481565b34801561044c57600080fd5b5061046061045b366004614a6a565b611857565b6040516fffffffffffffffffffffffffffffffff909116815260200161024b565b61028961048f366004614c46565b61197d565b3480156104a057600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff16610289565b3480156104cb57600080fd5b506001546102899073ffffffffffffffffffffffffffffffffffffffff1681565b3480156104f857600080fd5b5061050c610507366004614a6a565b611b92565b60405161024b9190614ce1565b34801561052557600080fd5b50610306610534366004614b22565b600460209081526000928352604080842090915290825290205481565b34801561055d57600080fd5b5061046061056c366004614a6a565b611c44565b34801561057d57600080fd5b50600754610306565b34801561059257600080fd5b506105a66105a1366004614a6a565b611cae565b60405161024b9190614e7d565b3480156105bf57600080fd5b506105d36105ce366004614ef9565b611ed1565b60405161024b9190614f1b565b3480156105ec57600080fd5b506104156105fb366004614b22565b61208a565b34801561060c57600080fd5b5061027461061b366004614a6a565b6120dd565b34801561062c57600080fd5b5061041561063b366004614c1c565b612222565b34801561064c57600080fd5b5061027461065b366004614a6a565b6126aa565b34801561066c57600080fd5b5061071861067b366004614a6a565b60066020526000908152604090208054600182015460029092015473ffffffffffffffffffffffffffffffffffffffff8083169374010000000000000000000000000000000000000000840461ffff90811694760100000000000000000000000000000000000000000000810490911693780100000000000000000000000000000000000000000000000090910464ffffffffff16929091169086565b6040805173ffffffffffffffffffffffffffffffffffffffff978816815261ffff9687166020820152949095169484019490945264ffffffffff919091166060830152909216608083015260a082015260c00161024b565b34801561077c57600080fd5b5061030660025481565b34801561079257600080fd5b506102746107a1366004614a6a565b612829565b3480156107b257600080fd5b506107f16107c1366004614a6a565b73ffffffffffffffffffffffffffffffffffffffff90811660009081526006602052604090206001015416151590565b604051901515815260200161024b565b34801561080d57600080fd5b5061030661081c366004614bd6565b612892565b34801561082d57600080fd5b5061023e61083c3660046149dd565b612ab9565b34801561084d57600080fd5b5061028961dead81565b6060818310158061087257506127106108708484614fca565b115b156108a9576040517f891724d600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600754808311156108b8578092505b6000845b84811015610941578673ffffffffffffffffffffffffffffffffffffffff1660066000600784815481106108f2576108f2614fdd565b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff90811684529083019390935260409091019020600101541603610939578160010191505b6001016108bc565b508067ffffffffffffffff81111561095b5761095b61500c565b604051908082528060200260200182016040528015610984578160200160208202803683370190505b5092506000855b85811015610a85578773ffffffffffffffffffffffffffffffffffffffff1660066000600784815481106109c1576109c1614fdd565b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff90811684529083019390935260409091019020600101541603610a7d5760078181548110610a1457610a14614fdd565b6000918252602090912001548551600184019373ffffffffffffffffffffffffffffffffffffffff9092169187918110610a5057610a50614fdd565b73ffffffffffffffffffffffffffffffffffffffff90921660209283029190910190910152818314610a85575b60010161098b565b505050509392505050565b610a98612ce1565b73ffffffffffffffffffffffffffffffffffffffff8116610ae5576040517f5059b85f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527fcf7686c0c53a1ab216c4cd81c1bc037136c791a61f30af4a78827c3915766044906020015b60405180910390a150565b60006002543414610b9c576040517f3403ce3700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610ba583612d34565b610bae82612e23565b6000610be67f0000000000000000000000000000000000000000000000000000000000000000610be1602087018761503b565b61344f565b90508073ffffffffffffffffffffffffffffffffffffffff8116637029144c610c0f878061503b565b610c1c60208a018a61503b565b6040518563ffffffff1660e01b8152600401610c3b94939291906150e9565b600060405180830381600087803b158015610c5557600080fd5b505af1158015610c69573d6000803e3d6000fd5b5050600780546001810182556000919091527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c6880180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff861617905550610ce890508285613506565b610cf86060850160408601614a6a565b73ffffffffffffffffffffffffffffffffffffffff9081169083167f6596c1670eb3390048d23721809c3da5d3f531375ac0e2cab0f77a808ed64331610d3e888061503b565b610d4b60208b018b61503b565b604051610d5b94939291906150e9565b60405180910390a3610d7060a085018561511b565b6000818110610d8157610d81614fdd565b9050602002016020810190610d969190615183565b6fffffffffffffffffffffffffffffffff16600003610e955773ffffffffffffffffffffffffffffffffffffffff8116631b5ad8b533610dd9608088018861511b565b6000818110610dea57610dea614fdd565b9050602002016020810190610dff9190615183565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815273ffffffffffffffffffffffffffffffffffffffff90921660048301526fffffffffffffffffffffffffffffffff166024820152604401600060405180830381600087803b158015610e7c57600080fd5b505af1158015610e90573d6000803e3d6000fd5b505050505b60025415610f3b5760015460025460405160009273ffffffffffffffffffffffffffffffffffffffff1691908381818185875af1925050503d8060008114610ef9576040519150601f19603f3d011682016040523d82523d6000602084013e610efe565b606091505b5050905080610f39576040517f0d4d59b300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505b5090505b92915050565b60078181548110610f5557600080fd5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16905081565b600073ffffffffffffffffffffffffffffffffffffffff8216610fcb576040517fd9b08f7600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080610fd88787612222565b9150915084821015611016576040517f07728bb000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff871660008181526006602052604080822081517ff4efe8f20000000000000000000000000000000000000000000000000000000081523360048201819052602482018c905292519194929363f4efe8f29260448084019382900301818387803b15801561109757600080fd5b505af11580156110ab573d6000803e3d6000fd5b5050505082846110bb91906151b5565b8260020160008282546110ce9190614fca565b9091555050815460018301546110fe9173ffffffffffffffffffffffffffffffffffffffff908116911685613a95565b600182015473ffffffffffffffffffffffffffffffffffffffff16611124818887613b57565b60018301546040805173ffffffffffffffffffffffffffffffffffffffff8a81168252602082018d905291810188905291811691848216918d16907f80a56de61873550ae491e454783a8dfc9d08a6f8bdace0887eabd4315c4b9da8906060015b60405180910390a4509298975050505050505050565b6111a3612ce1565b60028190556040518181527f88a973fd5506071e0cf878b30898776c47d5250a7ee1e6ee0b36df3b03c7c16a90602001610b54565b6111e0612ce1565b6111ea6000613bdd565b565b6111f4612ce1565b612710811115611230576040517f5059b85f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60038190556040518181527f21085b3501e0e4fa8e0c825e7ed36b44420471b9f3c5aef447cebe50b2db133d90602001610b54565b73ffffffffffffffffffffffffffffffffffffffff8281166000908152600660205260409020805490911633146112c8576040517f36a0203800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8216611315576040517f67f61c8200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8381169182178355604051908516907f9dcef3aa57f22970dfc6ff519e5421e041cc4153300a7dabe19bffe85e25568890600090a3505050565b73ffffffffffffffffffffffffffffffffffffffff808316600090815260066020526040812060010154909182918591166113ef576040517f2d350e9f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b83600003611429576040517fc01ae10500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8086166000908152600660209081526040808320815160e0810183528154808716825261ffff7401000000000000000000000000000000000000000082048116838701527601000000000000000000000000000000000000000000008204168285015264ffffffffff780100000000000000000000000000000000000000000000000090910416606082015260018201549095166080860152600281015460a0860152600381018054835181860281018601909452808452949594919360c08601939290879084015b8282101561156657600084815260209081902060408051808201909152908401546fffffffffffffffffffffffffffffffff80821683527001000000000000000000000000000000009091041681830152825260019092019101611507565b5050505081525050905060008160c001519050600087905060008173ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ef91906151c8565b905060006115fd89836151b5565b90506116088a611c44565b6fffffffffffffffffffffffffffffffff16811115611653576040517f6b5b0f7c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008373ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156116a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116c491906151e1565b6116cf90600a615324565b905089600080806116e08f88613c52565b90505b88518110156117e557600089828151811061170057611700614fdd565b602002602001015190508781600001516fffffffffffffffffffffffffffffffff1661172c9190614fca565b925084831015611798578260000361174457506117d5565b61176f81602001516fffffffffffffffffffffffffffffffff16846117699190615333565b87613d0a565b61177990856151b5565b935061178583896151b5565b97506117918386614fca565b94506117d3565b6117bd81602001516fffffffffffffffffffffffffffffffff16866117699190615333565b6117c790856151b5565b935060009450506117e5565b505b6117de8161534a565b90506116e3565b508115806117f35750600083115b1561182a576040517fc01ae10500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611838828a60200151613d5a565b9a506118448b836151b5565b9b50505050505050505050509250929050565b6000808273ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156118a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118c991906151c8565b90506118d483611c44565b6fffffffffffffffffffffffffffffffff168110156118f9576118f68161534a565b90505b60006119058483613c52565b73ffffffffffffffffffffffffffffffffffffffff851660009081526006602052604090206003018054919250908290811061194357611943614fdd565b60009182526020909120015470010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff16949350505050565b600060025434146119ba576040517f3403ce3700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6119c383613d77565b6119cc82612e23565b60006119ff7f0000000000000000000000000000000000000000000000000000000000000000610be1602087018761503b565b90508073ffffffffffffffffffffffffffffffffffffffff81166341e461a0611a28878061503b565b611a3560208a018a61503b565b611a4260408c018c61503b565b6040518763ffffffff1660e01b8152600401611a6396959493929190615382565b600060405180830381600087803b158015611a7d57600080fd5b505af1158015611a91573d6000803e3d6000fd5b5050600780546001810182556000919091527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c6880180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff861617905550611b1090508285613506565b611b206060850160408601614a6a565b73ffffffffffffffffffffffffffffffffffffffff9081169083167f42d30c09380d6b8dbb77d95cae534a5c8fbf778789d87f58030bd74280437071611b66888061503b565b611b7360208b018b61503b565b611b8060408d018d61503b565b604051610d5b96959493929190615382565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600660209081526040808320600301805482518185028101850190935280835260609492939192909184015b82821015611c3957600084815260209081902060408051808201909152908401546fffffffffffffffffffffffffffffffff80821683527001000000000000000000000000000000009091041681830152825260019092019101611bda565b505050509050919050565b73ffffffffffffffffffffffffffffffffffffffff811660009081526006602052604081206003018054611c7a90600190614fca565b81548110611c8a57611c8a614fdd565b6000918252602090912001546fffffffffffffffffffffffffffffffff1692915050565b611d4560408051608080820183526000808352602080840182905284516101c081018652828152908101829052808501829052606080820181905292810183905260a0810182905260c0810182905260e0810182905261010081018290526101208101829052610140810182905261016081018390526101808101929092526101a082015290918201908152602001606081525090565b73ffffffffffffffffffffffffffffffffffffffff8083166000908152600660209081526040808320815160e0810183528154808716825261ffff7401000000000000000000000000000000000000000082048116838701527601000000000000000000000000000000000000000000008204168285015264ffffffffff780100000000000000000000000000000000000000000000000090910416606082015260018201549095166080860152600281015460a0860152600381018054835181860281018601909452808452949594919360c08601939290879084015b82821015611e8257600084815260209081902060408051808201909152908401546fffffffffffffffffffffffffffffffff80821683527001000000000000000000000000000000009091041681830152825260019092019101611e23565b505050508152505090506040518060800160405280826020015161ffff168152602001826040015161ffff168152602001611ebc85613ede565b81526020018260c00151815250915050919050565b60608183101580611eec57506103e8611eea8484614fca565b115b15611f23576040517f891724d600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60075480831115611f32578092505b8383038067ffffffffffffffff811115611f4e57611f4e61500c565b60405190808252806020026020018201604052801561200a57816020015b604080516101c0810182526000808252602080830182905292820181905260608083018190526080830181905260a0830182905260c0830182905260e0830182905261010083018290526101208301829052610140830182905261016083018190526101808301526101a082015282527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff909201910181611f6c5790505b5092506000855b85811015612080576120566007828154811061202f5761202f614fdd565b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16613ede565b855160018401938791811061206d5761206d614fdd565b6020908102919091010152600101612011565b5050505092915050565b73ffffffffffffffffffffffffffffffffffffffff8083166000818152600460209081526040808320948616808452948252808320549383526005825280832094835293905291909120545b9250929050565b33600081815260046020908152604080832073ffffffffffffffffffffffffffffffffffffffff8616845290915281205490819003612148576040517fbfa4e44600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff80831660008181526004602090815260408083209488168084529482528083208390559282526005815282822093825292909252812080548392906121a39084906151b5565b909155506121ca905073ffffffffffffffffffffffffffffffffffffffff84168383613b57565b6040805173ffffffffffffffffffffffffffffffffffffffff8581168252602082018490528416917fd1b893da855ca6a7c9cfbaff142da78c734a39d4811ad711fe7acfd6e5e433a4910160405180910390a2505050565b73ffffffffffffffffffffffffffffffffffffffff80831660009081526006602052604081206001015490918291859116612289576040517f2d350e9f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b836000036122c3576040517fc01ae10500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8086166000908152600660209081526040808320815160e0810183528154808716825261ffff7401000000000000000000000000000000000000000082048116838701527601000000000000000000000000000000000000000000008204168285015264ffffffffff780100000000000000000000000000000000000000000000000090910416606082015260018201549095166080860152600281015460a0860152600381018054835181860281018601909452808452949594919360c08601939290879084015b8282101561240057600084815260209081902060408051808201909152908401546fffffffffffffffffffffffffffffffff808216835270010000000000000000000000000000000090910416818301528252600190920191016123a1565b5050505081525050905060008160c001519050600087905060008173ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612465573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061248991906151c8565b9050808811156124c5576040517f4fffb8fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008273ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612512573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061253691906151e1565b61254190600a615324565b9050600089816125518d86613c52565b90505b811561264657600081156125ac578761256e600184614fca565b8151811061257e5761257e614fdd565b6020026020010151600001516fffffffffffffffffffffffffffffffff16866125a79190614fca565b6125ae565b855b905060008184106125bf57816125c1565b835b9050858984815181106125d6576125d6614fdd565b6020026020010151602001516fffffffffffffffffffffffffffffffff16826125ff9190615333565b61260991906153cb565b61261390866151b5565b945061261f8185614fca565b935061262b8188614fca565b9650821561263f5761263c83615406565b92505b5050612554565b811561267e576040517fc01ae10500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61268c838960400151613d5a565b99506126988a84614fca565b9a505050505050505050509250929050565b73ffffffffffffffffffffffffffffffffffffffff811660009081527f42c63635470f1fb1d6d4b6441c413cb435b1ebb6fedd1896dd5e25d1399147dd602052604081205490819003612729576040517fbfa4e44600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff821660009081527f42c63635470f1fb1d6d4b6441c413cb435b1ebb6fedd1896dd5e25d1399147dd602090815260408083208390557f7d509c07f0d4edcc2dd1b53aae68677132eb562dcba78e36381b63ccaf66e6ba909152812080548392906127a99084906151b5565b909155506127d2905073ffffffffffffffffffffffffffffffffffffffff831661dead83613b57565b6040805173ffffffffffffffffffffffffffffffffffffffff841681526020810183905261dead917fd1b893da855ca6a7c9cfbaff142da78c734a39d4811ad711fe7acfd6e5e433a4910160405180910390a25050565b612831612ce1565b73ffffffffffffffffffffffffffffffffffffffff8116612886576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024015b60405180910390fd5b61288f81613bdd565b50565b600073ffffffffffffffffffffffffffffffffffffffff82166128e1576040517fd9b08f7600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000806128ee8787611388565b915091508482111561292c576040517f07728bb000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8781166000908152600660205260409020600181015490913391166129668486614fca565b83600201600082825461297991906151b5565b9091555050825460018401546129a99173ffffffffffffffffffffffffffffffffffffffff908116911686613a95565b6040517f1b5ad8b500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8881166004830152602482018b90528b1690631b5ad8b590604401600060405180830381600087803b158015612a1957600080fd5b505af1158015612a2d573d6000803e3d6000fd5b50612a549250505073ffffffffffffffffffffffffffffffffffffffff821683308861453f565b60018301546040805173ffffffffffffffffffffffffffffffffffffffff8a81168252602082018d905291810188905291811691848216918d16907f02ed9b10d8b33a6a9fda664247bfd8f6248f74cff85cc84e56b7530c2fce560a90606001611185565b60608183101580612ad45750612710612ad28484614fca565b115b15612b0b576040517f891724d600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60075480831115612b1a578092505b6000845b84811015612ba0578673ffffffffffffffffffffffffffffffffffffffff166006600060078481548110612b5457612b54614fdd565b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff90811684529083019390935260409091019020541603612b98578160010191505b600101612b1e565b508067ffffffffffffffff811115612bba57612bba61500c565b604051908082528060200260200182016040528015612be3578160200160208202803683370190505b5092506000855b85811015610a85578773ffffffffffffffffffffffffffffffffffffffff166006600060078481548110612c2057612c20614fdd565b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff90811684529083019390935260409091019020541603612cd95760078181548110612c7057612c70614fdd565b6000918252602090912001548551600184019373ffffffffffffffffffffffffffffffffffffffff9092169187918110612cac57612cac614fdd565b73ffffffffffffffffffffffffffffffffffffffff90921660209283029190910190910152818314610a85575b600101612bea565b60005473ffffffffffffffffffffffffffffffffffffffff1633146111ea576040517f118cdaa700000000000000000000000000000000000000000000000000000000815233600482015260240161287d565b612d3e818061503b565b9050600003612dab576040517f49d3358800000000000000000000000000000000000000000000000000000000815260040161287d9060208082526004908201527f6e616d6500000000000000000000000000000000000000000000000000000000604082015260600190565b612db8602082018261503b565b905060000361288f576040517f49d3358800000000000000000000000000000000000000000000000000000000815260206004820152600660248201527f73796d626f6c0000000000000000000000000000000000000000000000000000604482015260640161287d565b600354612e33602083018361543b565b61ffff161115612e9f576040517f49d3358800000000000000000000000000000000000000000000000000000000815260206004820152600b60248201527f6d696e74526f79616c7479000000000000000000000000000000000000000000604482015260640161287d565b600354612eb2604083016020840161543b565b61ffff161115612f1e576040517f49d3358800000000000000000000000000000000000000000000000000000000815260206004820152600b60248201527f6275726e526f79616c7479000000000000000000000000000000000000000000604482015260640161287d565b6000612f306060830160408401614a6a565b905073ffffffffffffffffffffffffffffffffffffffff8116612faf576040517f49d3358800000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f72657365727665546f6b656e0000000000000000000000000000000000000000604482015260640161287d565b612ff0816040518060400160405280600a81526020017f646563696d616c73282900000000000000000000000000000000000000000000815250601f61458b565b613056576040517f59f5822400000000000000000000000000000000000000000000000000000000815260206004820152600860248201527f646563696d616c73000000000000000000000000000000000000000000000000604482015260640161287d565b613097816040518060400160405280600681526020017f6e616d6528290000000000000000000000000000000000000000000000000000815250605f61458b565b6130ff576040517f59f5822400000000000000000000000000000000000000000000000000000000815260040161287d9060208082526004908201527f6e616d6500000000000000000000000000000000000000000000000000000000604082015260600190565b613140816040518060400160405280600881526020017f73796d626f6c2829000000000000000000000000000000000000000000000000815250605f61458b565b6131a6576040517f59f5822400000000000000000000000000000000000000000000000000000000815260206004820152600660248201527f73796d626f6c0000000000000000000000000000000000000000000000000000604482015260640161287d565b6131b66080830160608401615183565b6fffffffffffffffffffffffffffffffff16600003613231576040517f49d3358800000000000000000000000000000000000000000000000000000000815260206004820152600960248201527f6d6178537570706c790000000000000000000000000000000000000000000000604482015260640161287d565b61323e608083018361511b565b1590508061327957507f0000000000000000000000000000000000000000000000000000000000000000613275608084018461511b565b9050115b156132e0576040517f1afd40d600000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f494e56414c49445f535445505f4c454e47544800000000000000000000000000604482015260640161287d565b6132ed60a083018361511b565b90506132fc608084018461511b565b905014613365576040517f1afd40d600000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f535445505f4c454e4754485f444f5f4e4f545f4d415443480000000000000000604482015260640161287d565b6133756080830160608401615183565b6fffffffffffffffffffffffffffffffff16613394608084018461511b565b60016133a3608087018761511b565b6133ae929150614fca565b8181106133bd576133bd614fdd565b90506020020160208101906133d29190615183565b6fffffffffffffffffffffffffffffffff161461344b576040517f1afd40d600000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4d41585f535550504c595f4d49534d4154434800000000000000000000000000604482015260640161287d565b5050565b6000803084846040516020016134679392919061545f565b604051602081830303815290604052805190602001209050600061348b8683614684565b73ffffffffffffffffffffffffffffffffffffffff80821660009081526006602052604090206001015491925016156134f0576040517f358b663800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6134fa86836146e4565b925050505b9392505050565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260066020908152604090912080547fffffffffffffffffffffffff00000000000000000000000000000000000000001633178155906135639083018361543b565b815461ffff9190911674010000000000000000000000000000000000000000027fffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffff9091161781556135ba604083016020840161543b565b81547fffffff00000000000000ffffffffffffffffffffffffffffffffffffffffffff1676010000000000000000000000000000000000000000000061ffff92909216919091027fffffff0000000000ffffffffffffffffffffffffffffffffffffffffffffffff161778010000000000000000000000000000000000000000000000004264ffffffffff160217815561365a6060830160408401614a6a565b8160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008373ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156136e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061370d91906151e1565b61371890600a615324565b905060005b61372a608085018561511b565b9050811015613a8e576000613742608086018661511b565b8381811061375257613752614fdd565b90506020020160208101906137679190615183565b6fffffffffffffffffffffffffffffffff169050600061378a60a087018761511b565b8481811061379a5761379a614fdd565b90506020020160208101906137af9190615183565b6fffffffffffffffffffffffffffffffff1690508160000361382d576040517f1afd40d600000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f535445505f43414e4e4f545f42455f5a45524f00000000000000000000000000604482015260640161287d565b6000811180156138455750836138438284615333565b105b156138ac576040517f1afd40d600000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f535445505f52414e475f4f525f50524943455f544f4f5f534d414c4c00000000604482015260640161287d565b8215613a1e576138bf608087018761511b565b6138ca600186614fca565b8181106138d9576138d9614fdd565b90506020020160208101906138ee9190615183565b6fffffffffffffffffffffffffffffffff168211613968576040517f1afd40d600000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f44454352454153494e475f52414e474500000000000000000000000000000000604482015260640161287d565b61397560a087018761511b565b613980600186614fca565b81811061398f5761398f614fdd565b90506020020160208101906139a49190615183565b6fffffffffffffffffffffffffffffffff168111613a1e576040517f1afd40d600000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f44454352454153494e475f505249434500000000000000000000000000000000604482015260640161287d565b604080518082019091526fffffffffffffffffffffffffffffffff928316815290821660208083019182526003870180546001810182556000918252919020925191518416700100000000000000000000000000000000029190931617910155613a878161534a565b905061371d565b5050505050565b6000612710613aa66107d084615333565b613ab091906153cb565b9050613abc8183614fca565b73ffffffffffffffffffffffffffffffffffffffff808616600090815260046020908152604080832093881683529290529081208054909190613b009084906151b5565b909155505060015473ffffffffffffffffffffffffffffffffffffffff908116600090815260046020908152604080832093871683529290529081208054839290613b4c9084906151b5565b909155505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff838116602483015260448201839052613bd891859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050614778565b505050565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600660205260408120815b6003820154811015613cd757816003018181548110613c9a57613c9a614fdd565b6000918252602090912001546fffffffffffffffffffffffffffffffff168411613cc7579150610f3f9050565b613cd08161534a565b9050613c79565b506040517fd1ce01ea00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600081600003613d2557613d1e82846153cb565b9050610f3f565b8215613d515781613d37600185614fca565b613d4191906153cb565b613d4c9060016151b5565b6134ff565b60009392505050565b6000612710613d6d61ffff841685615333565b6134ff91906153cb565b613d81818061503b565b9050600003613dee576040517f49d3358800000000000000000000000000000000000000000000000000000000815260040161287d9060208082526004908201527f6e616d6500000000000000000000000000000000000000000000000000000000604082015260600190565b613dfb602082018261503b565b9050600003613e66576040517f49d3358800000000000000000000000000000000000000000000000000000000815260206004820152600660248201527f73796d626f6c0000000000000000000000000000000000000000000000000000604482015260640161287d565b613e73604082018261503b565b905060000361288f576040517f49d3358800000000000000000000000000000000000000000000000000000000815260206004820152600360248201527f7572690000000000000000000000000000000000000000000000000000000000604482015260640161287d565b604080516101c08101825260008082526020820181905291810182905260608082018190526080820181905260a0820183905260c0820183905260e0820183905261010082018390526101208201839052610140820183905261016082018190526101808201526101a081019190915273ffffffffffffffffffffffffffffffffffffffff8083166000908152600660209081526040808320815160e0810183528154808716825261ffff7401000000000000000000000000000000000000000082048116838701527601000000000000000000000000000000000000000000008204168285015264ffffffffff780100000000000000000000000000000000000000000000000090910416606082015260018201549095166080860152600281015460a0860152600381018054835181860281018601909452808452889694929360c086019390929190879084015b8282101561408d57600084815260209081902060408051808201909152908401546fffffffffffffffffffffffffffffffff8082168352700100000000000000000000000000000000909104168183015282526001909201910161402e565b50505050815250509050600081608001519050604051806101c00160405280836000015173ffffffffffffffffffffffffffffffffffffffff1681526020018673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015614133573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061415791906151e1565b60ff1681526020018473ffffffffffffffffffffffffffffffffffffffff166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa1580156141aa573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526141f0919081019061549e565b81526020018473ffffffffffffffffffffffffffffffffffffffff166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa158015614240573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052614286919081019061549e565b8152602001836060015164ffffffffff1681526020016143138573ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156142ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061430e91906151c8565b61480e565b6fffffffffffffffffffffffffffffffff16815260200161433387611c44565b6fffffffffffffffffffffffffffffffff16815260200161435387611857565b6fffffffffffffffffffffffffffffffff168152602001836080015173ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156143d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143f991906151e1565b60ff1681526020018273ffffffffffffffffffffffffffffffffffffffff166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa15801561444c573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052614492919081019061549e565b81526020018273ffffffffffffffffffffffffffffffffffffffff166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa1580156144e2573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052614528919081019061549e565b81526020018360a001518152509350505050919050565b60405173ffffffffffffffffffffffffffffffffffffffff84811660248301528381166044830152606482018390526145859186918216906323b872dd90608401613b91565b50505050565b604080516004815260248101918290526000918291829173ffffffffffffffffffffffffffffffffffffffff881691906145c690889061555e565b60408051918290039091206020830180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009092169190911790525161462a919061555e565b600060405180830381855afa9150503d8060008114614665576040519150601f19603f3d011682016040523d82523d6000602084013e61466a565b606091505b50915091508180156134fa57505192909211949350505050565b6040513060388201526f5af43d82803e903d91602b57fd5bf3ff602482015260148101839052733d602d80600a3d3981f3363d3d373d3d3d363d738152605881018290526037600c820120607882015260556043909101206000906134ff565b6000763d602d80600a3d3981f3363d3d373d3d3d363d730000008360601b60e81c176000526e5af43d82803e903d91602b57fd5bf38360781b1760205281603760096000f5905073ffffffffffffffffffffffffffffffffffffffff8116610f3f576040517fc2f868f400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061479a73ffffffffffffffffffffffffffffffffffffffff841683614868565b905080516000141580156147bf5750808060200190518101906147bd919061557a565b155b15613bd8576040517f5274afe700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416600482015260240161287d565b60006fffffffffffffffffffffffffffffffff821115614864576040517f6dfcc650000000000000000000000000000000000000000000000000000000008152608060048201526024810183905260440161287d565b5090565b60606134ff83836000846000808573ffffffffffffffffffffffffffffffffffffffff16848660405161489b919061555e565b60006040518083038185875af1925050503d80600081146148d8576040519150601f19603f3d011682016040523d82523d6000602084013e6148dd565b606091505b50915091506134fa8683836060826148f857613d4c82614972565b815115801561491c575073ffffffffffffffffffffffffffffffffffffffff84163b155b1561496b576040517f9996b31500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8516600482015260240161287d565b50806134ff565b8051156149825780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b803573ffffffffffffffffffffffffffffffffffffffff811681146149d857600080fd5b919050565b6000806000606084860312156149f257600080fd5b6149fb846149b4565b95602085013595506040909401359392505050565b6020808252825182820181905260009190848201906040850190845b81811015614a5e57835173ffffffffffffffffffffffffffffffffffffffff1683529284019291840191600101614a2c565b50909695505050505050565b600060208284031215614a7c57600080fd5b6134ff826149b4565b600060c08284031215614a9757600080fd5b50919050565b60008060408385031215614ab057600080fd5b823567ffffffffffffffff80821115614ac857600080fd5b9084019060408287031215614adc57600080fd5b90925060208401359080821115614af257600080fd5b50614aff85828601614a85565b9150509250929050565b600060208284031215614b1b57600080fd5b5035919050565b60008060408385031215614b3557600080fd5b614b3e836149b4565b9150614b4c602084016149b4565b90509250929050565b60005b83811015614b70578181015183820152602001614b58565b50506000910152565b60008151808452614b91816020860160208601614b55565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006134ff6020830184614b79565b60008060008060808587031215614bec57600080fd5b614bf5856149b4565b93506020850135925060408501359150614c11606086016149b4565b905092959194509250565b60008060408385031215614c2f57600080fd5b614c38836149b4565b946020939093013593505050565b60008060408385031215614c5957600080fd5b823567ffffffffffffffff80821115614c7157600080fd5b9084019060608287031215614adc57600080fd5b600081518084526020808501945080840160005b83811015614cd657815180516fffffffffffffffffffffffffffffffff908116895290840151168388015260409096019590820190600101614c99565b509495945050505050565b6020815260006134ff6020830184614c85565b805173ffffffffffffffffffffffffffffffffffffffff16825260006101c06020830151614d3a602086018273ffffffffffffffffffffffffffffffffffffffff169052565b506040830151614d4f604086018260ff169052565b506060830151816060860152614d6782860182614b79565b91505060808301518482036080860152614d818282614b79565b91505060a0830151614d9c60a086018264ffffffffff169052565b5060c0830151614dc060c08601826fffffffffffffffffffffffffffffffff169052565b5060e0830151614de460e08601826fffffffffffffffffffffffffffffffff169052565b50610100838101516fffffffffffffffffffffffffffffffff16908501526101208084015173ffffffffffffffffffffffffffffffffffffffff16908501526101408084015160ff16908501526101608084015185830382870152614e498382614b79565b925050506101808084015185830382870152614e658382614b79565b6101a095860151969095019590955250919392505050565b60208152600061ffff80845116602084015280602085015116604084015250604083015160806060840152614eb560a0840182614cf4565b905060608401517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0848303016080850152614ef08282614c85565b95945050505050565b60008060408385031215614f0c57600080fd5b50508035926020909101359150565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015614f8e577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0888603018452614f7c858351614cf4565b94509285019290850190600101614f42565b5092979650505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b81810381811115610f3f57610f3f614f9b565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261507057600080fd5b83018035915067ffffffffffffffff82111561508b57600080fd5b6020019150368190038213156120d657600080fd5b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b6040815260006150fd6040830186886150a0565b82810360208401526151108185876150a0565b979650505050505050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261515057600080fd5b83018035915067ffffffffffffffff82111561516b57600080fd5b6020019150600581901b36038213156120d657600080fd5b60006020828403121561519557600080fd5b81356fffffffffffffffffffffffffffffffff811681146134ff57600080fd5b80820180821115610f3f57610f3f614f9b565b6000602082840312156151da57600080fd5b5051919050565b6000602082840312156151f357600080fd5b815160ff811681146134ff57600080fd5b600181815b8085111561525d57817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111561524357615243614f9b565b8085161561525057918102915b93841c9390800290615209565b509250929050565b60008261527457506001610f3f565b8161528157506000610f3f565b816001811461529757600281146152a1576152bd565b6001915050610f3f565b60ff8411156152b2576152b2614f9b565b50506001821b610f3f565b5060208310610133831016604e8410600b84101617156152e0575081810a610f3f565b6152ea8383615204565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111561531c5761531c614f9b565b029392505050565b60006134ff60ff841683615265565b8082028115828204841417610f3f57610f3f614f9b565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361537b5761537b614f9b565b5060010190565b60608152600061539660608301888a6150a0565b82810360208401526153a98187896150a0565b905082810360408401526153be8185876150a0565b9998505050505050505050565b600082615401577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60008161541557615415614f9b565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b60006020828403121561544d57600080fd5b813561ffff811681146134ff57600080fd5b7fffffffffffffffffffffffffffffffffffffffff0000000000000000000000008460601b168152818360148301376000910160140190815292915050565b6000602082840312156154b057600080fd5b815167ffffffffffffffff808211156154c857600080fd5b818401915084601f8301126154dc57600080fd5b8151818111156154ee576154ee61500c565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019083821181831017156155345761553461500c565b8160405282815287602084870101111561554d57600080fd5b615110836020830160208801614b55565b60008251615570818460208701614b55565b9190910192915050565b60006020828403121561558c57600080fd5b815180151581146134ff57600080fdfea2646970667358221220c646ba442cc31600a00994df0d5fbd01797b6e975d5c41bc27b79242d6fcbefd64736f6c63430008140033000000000000000000000000aa70bc79fd1cb4a6fba717018351f0c3c64b79df0000000000000000000000006c61918eeccc306d35247338fdcf025af0f6120a00000000000000000000000082ca6d313bffe56e9096b16633dfd414148d66b10000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000003e8
Deployed Bytecode
0x6080604052600436106102195760003560e01c8063995e5f921161011d578063c9cb204b116100b0578063f2fde38b1161007f578063f74bfe8e11610064578063f74bfe8e14610801578063fb8c13c814610821578063fccc28131461084157600080fd5b8063f2fde38b14610786578063f6a3d24e146107a657600080fd5b8063c9cb204b14610620578063cfc5562214610640578063d9fe0eae14610660578063dce0b4e41461077057600080fd5b8063a746ee2e116100ec578063a746ee2e14610586578063a9816b08146105b3578063ac4e9675146105e0578063c162c9161461060057600080fd5b8063995e5f92146104ec5780639c65003d146105195780639cc7becf146105515780639f181b5e1461057157600080fd5b8063715018a6116101b057806377e456cb1161017f57806385396d2b1161016457806385396d2b146104815780638da5cb5b14610494578063990e6005146104bf57600080fd5b806377e456cb1461042a578063840d885d1461044057600080fd5b8063715018a6146103a05780637348ed2f146103b5578063763e7da6146103d557806376a9864b146103f557600080fd5b806350801fb1116101ec57806350801fb1146102ce57806354fd4d50146103145780635a4d5311146103605780636fa237951461038057600080fd5b806307e329461461021e57806327e381a91461025457806330be6955146102765780634f64b2be146102ae575b600080fd5b34801561022a57600080fd5b5061023e6102393660046149dd565b610857565b60405161024b9190614a10565b60405180910390f35b34801561026057600080fd5b5061027461026f366004614a6a565b610a90565b005b610289610284366004614a9d565b610b5f565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161024b565b3480156102ba57600080fd5b506102896102c9366004614b09565b610f45565b3480156102da57600080fd5b506103066102e9366004614b22565b600560209081526000928352604080842090915290825290205481565b60405190815260200161024b565b34801561032057600080fd5b50604080518082018252600781527f302e312e313230000000000000000000000000000000000000000000000000006020820152905161024b9190614bc3565b34801561036c57600080fd5b5061030661037b366004614bd6565b610f7c565b34801561038c57600080fd5b5061027461039b366004614b09565b61119b565b3480156103ac57600080fd5b506102746111d8565b3480156103c157600080fd5b506102746103d0366004614b09565b6111ec565b3480156103e157600080fd5b506102746103f0366004614b22565b611265565b34801561040157600080fd5b50610415610410366004614c1c565b611388565b6040805192835260208301919091520161024b565b34801561043657600080fd5b5061030660035481565b34801561044c57600080fd5b5061046061045b366004614a6a565b611857565b6040516fffffffffffffffffffffffffffffffff909116815260200161024b565b61028961048f366004614c46565b61197d565b3480156104a057600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff16610289565b3480156104cb57600080fd5b506001546102899073ffffffffffffffffffffffffffffffffffffffff1681565b3480156104f857600080fd5b5061050c610507366004614a6a565b611b92565b60405161024b9190614ce1565b34801561052557600080fd5b50610306610534366004614b22565b600460209081526000928352604080842090915290825290205481565b34801561055d57600080fd5b5061046061056c366004614a6a565b611c44565b34801561057d57600080fd5b50600754610306565b34801561059257600080fd5b506105a66105a1366004614a6a565b611cae565b60405161024b9190614e7d565b3480156105bf57600080fd5b506105d36105ce366004614ef9565b611ed1565b60405161024b9190614f1b565b3480156105ec57600080fd5b506104156105fb366004614b22565b61208a565b34801561060c57600080fd5b5061027461061b366004614a6a565b6120dd565b34801561062c57600080fd5b5061041561063b366004614c1c565b612222565b34801561064c57600080fd5b5061027461065b366004614a6a565b6126aa565b34801561066c57600080fd5b5061071861067b366004614a6a565b60066020526000908152604090208054600182015460029092015473ffffffffffffffffffffffffffffffffffffffff8083169374010000000000000000000000000000000000000000840461ffff90811694760100000000000000000000000000000000000000000000810490911693780100000000000000000000000000000000000000000000000090910464ffffffffff16929091169086565b6040805173ffffffffffffffffffffffffffffffffffffffff978816815261ffff9687166020820152949095169484019490945264ffffffffff919091166060830152909216608083015260a082015260c00161024b565b34801561077c57600080fd5b5061030660025481565b34801561079257600080fd5b506102746107a1366004614a6a565b612829565b3480156107b257600080fd5b506107f16107c1366004614a6a565b73ffffffffffffffffffffffffffffffffffffffff90811660009081526006602052604090206001015416151590565b604051901515815260200161024b565b34801561080d57600080fd5b5061030661081c366004614bd6565b612892565b34801561082d57600080fd5b5061023e61083c3660046149dd565b612ab9565b34801561084d57600080fd5b5061028961dead81565b6060818310158061087257506127106108708484614fca565b115b156108a9576040517f891724d600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600754808311156108b8578092505b6000845b84811015610941578673ffffffffffffffffffffffffffffffffffffffff1660066000600784815481106108f2576108f2614fdd565b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff90811684529083019390935260409091019020600101541603610939578160010191505b6001016108bc565b508067ffffffffffffffff81111561095b5761095b61500c565b604051908082528060200260200182016040528015610984578160200160208202803683370190505b5092506000855b85811015610a85578773ffffffffffffffffffffffffffffffffffffffff1660066000600784815481106109c1576109c1614fdd565b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff90811684529083019390935260409091019020600101541603610a7d5760078181548110610a1457610a14614fdd565b6000918252602090912001548551600184019373ffffffffffffffffffffffffffffffffffffffff9092169187918110610a5057610a50614fdd565b73ffffffffffffffffffffffffffffffffffffffff90921660209283029190910190910152818314610a85575b60010161098b565b505050509392505050565b610a98612ce1565b73ffffffffffffffffffffffffffffffffffffffff8116610ae5576040517f5059b85f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527fcf7686c0c53a1ab216c4cd81c1bc037136c791a61f30af4a78827c3915766044906020015b60405180910390a150565b60006002543414610b9c576040517f3403ce3700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610ba583612d34565b610bae82612e23565b6000610be67f000000000000000000000000aa70bc79fd1cb4a6fba717018351f0c3c64b79df610be1602087018761503b565b61344f565b90508073ffffffffffffffffffffffffffffffffffffffff8116637029144c610c0f878061503b565b610c1c60208a018a61503b565b6040518563ffffffff1660e01b8152600401610c3b94939291906150e9565b600060405180830381600087803b158015610c5557600080fd5b505af1158015610c69573d6000803e3d6000fd5b5050600780546001810182556000919091527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c6880180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff861617905550610ce890508285613506565b610cf86060850160408601614a6a565b73ffffffffffffffffffffffffffffffffffffffff9081169083167f6596c1670eb3390048d23721809c3da5d3f531375ac0e2cab0f77a808ed64331610d3e888061503b565b610d4b60208b018b61503b565b604051610d5b94939291906150e9565b60405180910390a3610d7060a085018561511b565b6000818110610d8157610d81614fdd565b9050602002016020810190610d969190615183565b6fffffffffffffffffffffffffffffffff16600003610e955773ffffffffffffffffffffffffffffffffffffffff8116631b5ad8b533610dd9608088018861511b565b6000818110610dea57610dea614fdd565b9050602002016020810190610dff9190615183565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815273ffffffffffffffffffffffffffffffffffffffff90921660048301526fffffffffffffffffffffffffffffffff166024820152604401600060405180830381600087803b158015610e7c57600080fd5b505af1158015610e90573d6000803e3d6000fd5b505050505b60025415610f3b5760015460025460405160009273ffffffffffffffffffffffffffffffffffffffff1691908381818185875af1925050503d8060008114610ef9576040519150601f19603f3d011682016040523d82523d6000602084013e610efe565b606091505b5050905080610f39576040517f0d4d59b300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505b5090505b92915050565b60078181548110610f5557600080fd5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16905081565b600073ffffffffffffffffffffffffffffffffffffffff8216610fcb576040517fd9b08f7600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080610fd88787612222565b9150915084821015611016576040517f07728bb000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff871660008181526006602052604080822081517ff4efe8f20000000000000000000000000000000000000000000000000000000081523360048201819052602482018c905292519194929363f4efe8f29260448084019382900301818387803b15801561109757600080fd5b505af11580156110ab573d6000803e3d6000fd5b5050505082846110bb91906151b5565b8260020160008282546110ce9190614fca565b9091555050815460018301546110fe9173ffffffffffffffffffffffffffffffffffffffff908116911685613a95565b600182015473ffffffffffffffffffffffffffffffffffffffff16611124818887613b57565b60018301546040805173ffffffffffffffffffffffffffffffffffffffff8a81168252602082018d905291810188905291811691848216918d16907f80a56de61873550ae491e454783a8dfc9d08a6f8bdace0887eabd4315c4b9da8906060015b60405180910390a4509298975050505050505050565b6111a3612ce1565b60028190556040518181527f88a973fd5506071e0cf878b30898776c47d5250a7ee1e6ee0b36df3b03c7c16a90602001610b54565b6111e0612ce1565b6111ea6000613bdd565b565b6111f4612ce1565b612710811115611230576040517f5059b85f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60038190556040518181527f21085b3501e0e4fa8e0c825e7ed36b44420471b9f3c5aef447cebe50b2db133d90602001610b54565b73ffffffffffffffffffffffffffffffffffffffff8281166000908152600660205260409020805490911633146112c8576040517f36a0203800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8216611315576040517f67f61c8200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8381169182178355604051908516907f9dcef3aa57f22970dfc6ff519e5421e041cc4153300a7dabe19bffe85e25568890600090a3505050565b73ffffffffffffffffffffffffffffffffffffffff808316600090815260066020526040812060010154909182918591166113ef576040517f2d350e9f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b83600003611429576040517fc01ae10500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8086166000908152600660209081526040808320815160e0810183528154808716825261ffff7401000000000000000000000000000000000000000082048116838701527601000000000000000000000000000000000000000000008204168285015264ffffffffff780100000000000000000000000000000000000000000000000090910416606082015260018201549095166080860152600281015460a0860152600381018054835181860281018601909452808452949594919360c08601939290879084015b8282101561156657600084815260209081902060408051808201909152908401546fffffffffffffffffffffffffffffffff80821683527001000000000000000000000000000000009091041681830152825260019092019101611507565b5050505081525050905060008160c001519050600087905060008173ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ef91906151c8565b905060006115fd89836151b5565b90506116088a611c44565b6fffffffffffffffffffffffffffffffff16811115611653576040517f6b5b0f7c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008373ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156116a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116c491906151e1565b6116cf90600a615324565b905089600080806116e08f88613c52565b90505b88518110156117e557600089828151811061170057611700614fdd565b602002602001015190508781600001516fffffffffffffffffffffffffffffffff1661172c9190614fca565b925084831015611798578260000361174457506117d5565b61176f81602001516fffffffffffffffffffffffffffffffff16846117699190615333565b87613d0a565b61177990856151b5565b935061178583896151b5565b97506117918386614fca565b94506117d3565b6117bd81602001516fffffffffffffffffffffffffffffffff16866117699190615333565b6117c790856151b5565b935060009450506117e5565b505b6117de8161534a565b90506116e3565b508115806117f35750600083115b1561182a576040517fc01ae10500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611838828a60200151613d5a565b9a506118448b836151b5565b9b50505050505050505050509250929050565b6000808273ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156118a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118c991906151c8565b90506118d483611c44565b6fffffffffffffffffffffffffffffffff168110156118f9576118f68161534a565b90505b60006119058483613c52565b73ffffffffffffffffffffffffffffffffffffffff851660009081526006602052604090206003018054919250908290811061194357611943614fdd565b60009182526020909120015470010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff16949350505050565b600060025434146119ba576040517f3403ce3700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6119c383613d77565b6119cc82612e23565b60006119ff7f0000000000000000000000006c61918eeccc306d35247338fdcf025af0f6120a610be1602087018761503b565b90508073ffffffffffffffffffffffffffffffffffffffff81166341e461a0611a28878061503b565b611a3560208a018a61503b565b611a4260408c018c61503b565b6040518763ffffffff1660e01b8152600401611a6396959493929190615382565b600060405180830381600087803b158015611a7d57600080fd5b505af1158015611a91573d6000803e3d6000fd5b5050600780546001810182556000919091527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c6880180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff861617905550611b1090508285613506565b611b206060850160408601614a6a565b73ffffffffffffffffffffffffffffffffffffffff9081169083167f42d30c09380d6b8dbb77d95cae534a5c8fbf778789d87f58030bd74280437071611b66888061503b565b611b7360208b018b61503b565b611b8060408d018d61503b565b604051610d5b96959493929190615382565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600660209081526040808320600301805482518185028101850190935280835260609492939192909184015b82821015611c3957600084815260209081902060408051808201909152908401546fffffffffffffffffffffffffffffffff80821683527001000000000000000000000000000000009091041681830152825260019092019101611bda565b505050509050919050565b73ffffffffffffffffffffffffffffffffffffffff811660009081526006602052604081206003018054611c7a90600190614fca565b81548110611c8a57611c8a614fdd565b6000918252602090912001546fffffffffffffffffffffffffffffffff1692915050565b611d4560408051608080820183526000808352602080840182905284516101c081018652828152908101829052808501829052606080820181905292810183905260a0810182905260c0810182905260e0810182905261010081018290526101208101829052610140810182905261016081018390526101808101929092526101a082015290918201908152602001606081525090565b73ffffffffffffffffffffffffffffffffffffffff8083166000908152600660209081526040808320815160e0810183528154808716825261ffff7401000000000000000000000000000000000000000082048116838701527601000000000000000000000000000000000000000000008204168285015264ffffffffff780100000000000000000000000000000000000000000000000090910416606082015260018201549095166080860152600281015460a0860152600381018054835181860281018601909452808452949594919360c08601939290879084015b82821015611e8257600084815260209081902060408051808201909152908401546fffffffffffffffffffffffffffffffff80821683527001000000000000000000000000000000009091041681830152825260019092019101611e23565b505050508152505090506040518060800160405280826020015161ffff168152602001826040015161ffff168152602001611ebc85613ede565b81526020018260c00151815250915050919050565b60608183101580611eec57506103e8611eea8484614fca565b115b15611f23576040517f891724d600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60075480831115611f32578092505b8383038067ffffffffffffffff811115611f4e57611f4e61500c565b60405190808252806020026020018201604052801561200a57816020015b604080516101c0810182526000808252602080830182905292820181905260608083018190526080830181905260a0830182905260c0830182905260e0830182905261010083018290526101208301829052610140830182905261016083018190526101808301526101a082015282527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff909201910181611f6c5790505b5092506000855b85811015612080576120566007828154811061202f5761202f614fdd565b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16613ede565b855160018401938791811061206d5761206d614fdd565b6020908102919091010152600101612011565b5050505092915050565b73ffffffffffffffffffffffffffffffffffffffff8083166000818152600460209081526040808320948616808452948252808320549383526005825280832094835293905291909120545b9250929050565b33600081815260046020908152604080832073ffffffffffffffffffffffffffffffffffffffff8616845290915281205490819003612148576040517fbfa4e44600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff80831660008181526004602090815260408083209488168084529482528083208390559282526005815282822093825292909252812080548392906121a39084906151b5565b909155506121ca905073ffffffffffffffffffffffffffffffffffffffff84168383613b57565b6040805173ffffffffffffffffffffffffffffffffffffffff8581168252602082018490528416917fd1b893da855ca6a7c9cfbaff142da78c734a39d4811ad711fe7acfd6e5e433a4910160405180910390a2505050565b73ffffffffffffffffffffffffffffffffffffffff80831660009081526006602052604081206001015490918291859116612289576040517f2d350e9f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b836000036122c3576040517fc01ae10500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8086166000908152600660209081526040808320815160e0810183528154808716825261ffff7401000000000000000000000000000000000000000082048116838701527601000000000000000000000000000000000000000000008204168285015264ffffffffff780100000000000000000000000000000000000000000000000090910416606082015260018201549095166080860152600281015460a0860152600381018054835181860281018601909452808452949594919360c08601939290879084015b8282101561240057600084815260209081902060408051808201909152908401546fffffffffffffffffffffffffffffffff808216835270010000000000000000000000000000000090910416818301528252600190920191016123a1565b5050505081525050905060008160c001519050600087905060008173ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612465573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061248991906151c8565b9050808811156124c5576040517f4fffb8fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008273ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612512573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061253691906151e1565b61254190600a615324565b9050600089816125518d86613c52565b90505b811561264657600081156125ac578761256e600184614fca565b8151811061257e5761257e614fdd565b6020026020010151600001516fffffffffffffffffffffffffffffffff16866125a79190614fca565b6125ae565b855b905060008184106125bf57816125c1565b835b9050858984815181106125d6576125d6614fdd565b6020026020010151602001516fffffffffffffffffffffffffffffffff16826125ff9190615333565b61260991906153cb565b61261390866151b5565b945061261f8185614fca565b935061262b8188614fca565b9650821561263f5761263c83615406565b92505b5050612554565b811561267e576040517fc01ae10500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61268c838960400151613d5a565b99506126988a84614fca565b9a505050505050505050509250929050565b73ffffffffffffffffffffffffffffffffffffffff811660009081527f42c63635470f1fb1d6d4b6441c413cb435b1ebb6fedd1896dd5e25d1399147dd602052604081205490819003612729576040517fbfa4e44600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff821660009081527f42c63635470f1fb1d6d4b6441c413cb435b1ebb6fedd1896dd5e25d1399147dd602090815260408083208390557f7d509c07f0d4edcc2dd1b53aae68677132eb562dcba78e36381b63ccaf66e6ba909152812080548392906127a99084906151b5565b909155506127d2905073ffffffffffffffffffffffffffffffffffffffff831661dead83613b57565b6040805173ffffffffffffffffffffffffffffffffffffffff841681526020810183905261dead917fd1b893da855ca6a7c9cfbaff142da78c734a39d4811ad711fe7acfd6e5e433a4910160405180910390a25050565b612831612ce1565b73ffffffffffffffffffffffffffffffffffffffff8116612886576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024015b60405180910390fd5b61288f81613bdd565b50565b600073ffffffffffffffffffffffffffffffffffffffff82166128e1576040517fd9b08f7600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000806128ee8787611388565b915091508482111561292c576040517f07728bb000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8781166000908152600660205260409020600181015490913391166129668486614fca565b83600201600082825461297991906151b5565b9091555050825460018401546129a99173ffffffffffffffffffffffffffffffffffffffff908116911686613a95565b6040517f1b5ad8b500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8881166004830152602482018b90528b1690631b5ad8b590604401600060405180830381600087803b158015612a1957600080fd5b505af1158015612a2d573d6000803e3d6000fd5b50612a549250505073ffffffffffffffffffffffffffffffffffffffff821683308861453f565b60018301546040805173ffffffffffffffffffffffffffffffffffffffff8a81168252602082018d905291810188905291811691848216918d16907f02ed9b10d8b33a6a9fda664247bfd8f6248f74cff85cc84e56b7530c2fce560a90606001611185565b60608183101580612ad45750612710612ad28484614fca565b115b15612b0b576040517f891724d600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60075480831115612b1a578092505b6000845b84811015612ba0578673ffffffffffffffffffffffffffffffffffffffff166006600060078481548110612b5457612b54614fdd565b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff90811684529083019390935260409091019020541603612b98578160010191505b600101612b1e565b508067ffffffffffffffff811115612bba57612bba61500c565b604051908082528060200260200182016040528015612be3578160200160208202803683370190505b5092506000855b85811015610a85578773ffffffffffffffffffffffffffffffffffffffff166006600060078481548110612c2057612c20614fdd565b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff90811684529083019390935260409091019020541603612cd95760078181548110612c7057612c70614fdd565b6000918252602090912001548551600184019373ffffffffffffffffffffffffffffffffffffffff9092169187918110612cac57612cac614fdd565b73ffffffffffffffffffffffffffffffffffffffff90921660209283029190910190910152818314610a85575b600101612bea565b60005473ffffffffffffffffffffffffffffffffffffffff1633146111ea576040517f118cdaa700000000000000000000000000000000000000000000000000000000815233600482015260240161287d565b612d3e818061503b565b9050600003612dab576040517f49d3358800000000000000000000000000000000000000000000000000000000815260040161287d9060208082526004908201527f6e616d6500000000000000000000000000000000000000000000000000000000604082015260600190565b612db8602082018261503b565b905060000361288f576040517f49d3358800000000000000000000000000000000000000000000000000000000815260206004820152600660248201527f73796d626f6c0000000000000000000000000000000000000000000000000000604482015260640161287d565b600354612e33602083018361543b565b61ffff161115612e9f576040517f49d3358800000000000000000000000000000000000000000000000000000000815260206004820152600b60248201527f6d696e74526f79616c7479000000000000000000000000000000000000000000604482015260640161287d565b600354612eb2604083016020840161543b565b61ffff161115612f1e576040517f49d3358800000000000000000000000000000000000000000000000000000000815260206004820152600b60248201527f6275726e526f79616c7479000000000000000000000000000000000000000000604482015260640161287d565b6000612f306060830160408401614a6a565b905073ffffffffffffffffffffffffffffffffffffffff8116612faf576040517f49d3358800000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f72657365727665546f6b656e0000000000000000000000000000000000000000604482015260640161287d565b612ff0816040518060400160405280600a81526020017f646563696d616c73282900000000000000000000000000000000000000000000815250601f61458b565b613056576040517f59f5822400000000000000000000000000000000000000000000000000000000815260206004820152600860248201527f646563696d616c73000000000000000000000000000000000000000000000000604482015260640161287d565b613097816040518060400160405280600681526020017f6e616d6528290000000000000000000000000000000000000000000000000000815250605f61458b565b6130ff576040517f59f5822400000000000000000000000000000000000000000000000000000000815260040161287d9060208082526004908201527f6e616d6500000000000000000000000000000000000000000000000000000000604082015260600190565b613140816040518060400160405280600881526020017f73796d626f6c2829000000000000000000000000000000000000000000000000815250605f61458b565b6131a6576040517f59f5822400000000000000000000000000000000000000000000000000000000815260206004820152600660248201527f73796d626f6c0000000000000000000000000000000000000000000000000000604482015260640161287d565b6131b66080830160608401615183565b6fffffffffffffffffffffffffffffffff16600003613231576040517f49d3358800000000000000000000000000000000000000000000000000000000815260206004820152600960248201527f6d6178537570706c790000000000000000000000000000000000000000000000604482015260640161287d565b61323e608083018361511b565b1590508061327957507f00000000000000000000000000000000000000000000000000000000000003e8613275608084018461511b565b9050115b156132e0576040517f1afd40d600000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f494e56414c49445f535445505f4c454e47544800000000000000000000000000604482015260640161287d565b6132ed60a083018361511b565b90506132fc608084018461511b565b905014613365576040517f1afd40d600000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f535445505f4c454e4754485f444f5f4e4f545f4d415443480000000000000000604482015260640161287d565b6133756080830160608401615183565b6fffffffffffffffffffffffffffffffff16613394608084018461511b565b60016133a3608087018761511b565b6133ae929150614fca565b8181106133bd576133bd614fdd565b90506020020160208101906133d29190615183565b6fffffffffffffffffffffffffffffffff161461344b576040517f1afd40d600000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4d41585f535550504c595f4d49534d4154434800000000000000000000000000604482015260640161287d565b5050565b6000803084846040516020016134679392919061545f565b604051602081830303815290604052805190602001209050600061348b8683614684565b73ffffffffffffffffffffffffffffffffffffffff80821660009081526006602052604090206001015491925016156134f0576040517f358b663800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6134fa86836146e4565b925050505b9392505050565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260066020908152604090912080547fffffffffffffffffffffffff00000000000000000000000000000000000000001633178155906135639083018361543b565b815461ffff9190911674010000000000000000000000000000000000000000027fffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffff9091161781556135ba604083016020840161543b565b81547fffffff00000000000000ffffffffffffffffffffffffffffffffffffffffffff1676010000000000000000000000000000000000000000000061ffff92909216919091027fffffff0000000000ffffffffffffffffffffffffffffffffffffffffffffffff161778010000000000000000000000000000000000000000000000004264ffffffffff160217815561365a6060830160408401614a6a565b8160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008373ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156136e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061370d91906151e1565b61371890600a615324565b905060005b61372a608085018561511b565b9050811015613a8e576000613742608086018661511b565b8381811061375257613752614fdd565b90506020020160208101906137679190615183565b6fffffffffffffffffffffffffffffffff169050600061378a60a087018761511b565b8481811061379a5761379a614fdd565b90506020020160208101906137af9190615183565b6fffffffffffffffffffffffffffffffff1690508160000361382d576040517f1afd40d600000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f535445505f43414e4e4f545f42455f5a45524f00000000000000000000000000604482015260640161287d565b6000811180156138455750836138438284615333565b105b156138ac576040517f1afd40d600000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f535445505f52414e475f4f525f50524943455f544f4f5f534d414c4c00000000604482015260640161287d565b8215613a1e576138bf608087018761511b565b6138ca600186614fca565b8181106138d9576138d9614fdd565b90506020020160208101906138ee9190615183565b6fffffffffffffffffffffffffffffffff168211613968576040517f1afd40d600000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f44454352454153494e475f52414e474500000000000000000000000000000000604482015260640161287d565b61397560a087018761511b565b613980600186614fca565b81811061398f5761398f614fdd565b90506020020160208101906139a49190615183565b6fffffffffffffffffffffffffffffffff168111613a1e576040517f1afd40d600000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f44454352454153494e475f505249434500000000000000000000000000000000604482015260640161287d565b604080518082019091526fffffffffffffffffffffffffffffffff928316815290821660208083019182526003870180546001810182556000918252919020925191518416700100000000000000000000000000000000029190931617910155613a878161534a565b905061371d565b5050505050565b6000612710613aa66107d084615333565b613ab091906153cb565b9050613abc8183614fca565b73ffffffffffffffffffffffffffffffffffffffff808616600090815260046020908152604080832093881683529290529081208054909190613b009084906151b5565b909155505060015473ffffffffffffffffffffffffffffffffffffffff908116600090815260046020908152604080832093871683529290529081208054839290613b4c9084906151b5565b909155505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff838116602483015260448201839052613bd891859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050614778565b505050565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600660205260408120815b6003820154811015613cd757816003018181548110613c9a57613c9a614fdd565b6000918252602090912001546fffffffffffffffffffffffffffffffff168411613cc7579150610f3f9050565b613cd08161534a565b9050613c79565b506040517fd1ce01ea00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600081600003613d2557613d1e82846153cb565b9050610f3f565b8215613d515781613d37600185614fca565b613d4191906153cb565b613d4c9060016151b5565b6134ff565b60009392505050565b6000612710613d6d61ffff841685615333565b6134ff91906153cb565b613d81818061503b565b9050600003613dee576040517f49d3358800000000000000000000000000000000000000000000000000000000815260040161287d9060208082526004908201527f6e616d6500000000000000000000000000000000000000000000000000000000604082015260600190565b613dfb602082018261503b565b9050600003613e66576040517f49d3358800000000000000000000000000000000000000000000000000000000815260206004820152600660248201527f73796d626f6c0000000000000000000000000000000000000000000000000000604482015260640161287d565b613e73604082018261503b565b905060000361288f576040517f49d3358800000000000000000000000000000000000000000000000000000000815260206004820152600360248201527f7572690000000000000000000000000000000000000000000000000000000000604482015260640161287d565b604080516101c08101825260008082526020820181905291810182905260608082018190526080820181905260a0820183905260c0820183905260e0820183905261010082018390526101208201839052610140820183905261016082018190526101808201526101a081019190915273ffffffffffffffffffffffffffffffffffffffff8083166000908152600660209081526040808320815160e0810183528154808716825261ffff7401000000000000000000000000000000000000000082048116838701527601000000000000000000000000000000000000000000008204168285015264ffffffffff780100000000000000000000000000000000000000000000000090910416606082015260018201549095166080860152600281015460a0860152600381018054835181860281018601909452808452889694929360c086019390929190879084015b8282101561408d57600084815260209081902060408051808201909152908401546fffffffffffffffffffffffffffffffff8082168352700100000000000000000000000000000000909104168183015282526001909201910161402e565b50505050815250509050600081608001519050604051806101c00160405280836000015173ffffffffffffffffffffffffffffffffffffffff1681526020018673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015614133573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061415791906151e1565b60ff1681526020018473ffffffffffffffffffffffffffffffffffffffff166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa1580156141aa573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526141f0919081019061549e565b81526020018473ffffffffffffffffffffffffffffffffffffffff166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa158015614240573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052614286919081019061549e565b8152602001836060015164ffffffffff1681526020016143138573ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156142ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061430e91906151c8565b61480e565b6fffffffffffffffffffffffffffffffff16815260200161433387611c44565b6fffffffffffffffffffffffffffffffff16815260200161435387611857565b6fffffffffffffffffffffffffffffffff168152602001836080015173ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156143d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143f991906151e1565b60ff1681526020018273ffffffffffffffffffffffffffffffffffffffff166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa15801561444c573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052614492919081019061549e565b81526020018273ffffffffffffffffffffffffffffffffffffffff166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa1580156144e2573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052614528919081019061549e565b81526020018360a001518152509350505050919050565b60405173ffffffffffffffffffffffffffffffffffffffff84811660248301528381166044830152606482018390526145859186918216906323b872dd90608401613b91565b50505050565b604080516004815260248101918290526000918291829173ffffffffffffffffffffffffffffffffffffffff881691906145c690889061555e565b60408051918290039091206020830180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009092169190911790525161462a919061555e565b600060405180830381855afa9150503d8060008114614665576040519150601f19603f3d011682016040523d82523d6000602084013e61466a565b606091505b50915091508180156134fa57505192909211949350505050565b6040513060388201526f5af43d82803e903d91602b57fd5bf3ff602482015260148101839052733d602d80600a3d3981f3363d3d373d3d3d363d738152605881018290526037600c820120607882015260556043909101206000906134ff565b6000763d602d80600a3d3981f3363d3d373d3d3d363d730000008360601b60e81c176000526e5af43d82803e903d91602b57fd5bf38360781b1760205281603760096000f5905073ffffffffffffffffffffffffffffffffffffffff8116610f3f576040517fc2f868f400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061479a73ffffffffffffffffffffffffffffffffffffffff841683614868565b905080516000141580156147bf5750808060200190518101906147bd919061557a565b155b15613bd8576040517f5274afe700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416600482015260240161287d565b60006fffffffffffffffffffffffffffffffff821115614864576040517f6dfcc650000000000000000000000000000000000000000000000000000000008152608060048201526024810183905260440161287d565b5090565b60606134ff83836000846000808573ffffffffffffffffffffffffffffffffffffffff16848660405161489b919061555e565b60006040518083038185875af1925050503d80600081146148d8576040519150601f19603f3d011682016040523d82523d6000602084013e6148dd565b606091505b50915091506134fa8683836060826148f857613d4c82614972565b815115801561491c575073ffffffffffffffffffffffffffffffffffffffff84163b155b1561496b576040517f9996b31500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8516600482015260240161287d565b50806134ff565b8051156149825780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b803573ffffffffffffffffffffffffffffffffffffffff811681146149d857600080fd5b919050565b6000806000606084860312156149f257600080fd5b6149fb846149b4565b95602085013595506040909401359392505050565b6020808252825182820181905260009190848201906040850190845b81811015614a5e57835173ffffffffffffffffffffffffffffffffffffffff1683529284019291840191600101614a2c565b50909695505050505050565b600060208284031215614a7c57600080fd5b6134ff826149b4565b600060c08284031215614a9757600080fd5b50919050565b60008060408385031215614ab057600080fd5b823567ffffffffffffffff80821115614ac857600080fd5b9084019060408287031215614adc57600080fd5b90925060208401359080821115614af257600080fd5b50614aff85828601614a85565b9150509250929050565b600060208284031215614b1b57600080fd5b5035919050565b60008060408385031215614b3557600080fd5b614b3e836149b4565b9150614b4c602084016149b4565b90509250929050565b60005b83811015614b70578181015183820152602001614b58565b50506000910152565b60008151808452614b91816020860160208601614b55565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006134ff6020830184614b79565b60008060008060808587031215614bec57600080fd5b614bf5856149b4565b93506020850135925060408501359150614c11606086016149b4565b905092959194509250565b60008060408385031215614c2f57600080fd5b614c38836149b4565b946020939093013593505050565b60008060408385031215614c5957600080fd5b823567ffffffffffffffff80821115614c7157600080fd5b9084019060608287031215614adc57600080fd5b600081518084526020808501945080840160005b83811015614cd657815180516fffffffffffffffffffffffffffffffff908116895290840151168388015260409096019590820190600101614c99565b509495945050505050565b6020815260006134ff6020830184614c85565b805173ffffffffffffffffffffffffffffffffffffffff16825260006101c06020830151614d3a602086018273ffffffffffffffffffffffffffffffffffffffff169052565b506040830151614d4f604086018260ff169052565b506060830151816060860152614d6782860182614b79565b91505060808301518482036080860152614d818282614b79565b91505060a0830151614d9c60a086018264ffffffffff169052565b5060c0830151614dc060c08601826fffffffffffffffffffffffffffffffff169052565b5060e0830151614de460e08601826fffffffffffffffffffffffffffffffff169052565b50610100838101516fffffffffffffffffffffffffffffffff16908501526101208084015173ffffffffffffffffffffffffffffffffffffffff16908501526101408084015160ff16908501526101608084015185830382870152614e498382614b79565b925050506101808084015185830382870152614e658382614b79565b6101a095860151969095019590955250919392505050565b60208152600061ffff80845116602084015280602085015116604084015250604083015160806060840152614eb560a0840182614cf4565b905060608401517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0848303016080850152614ef08282614c85565b95945050505050565b60008060408385031215614f0c57600080fd5b50508035926020909101359150565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015614f8e577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0888603018452614f7c858351614cf4565b94509285019290850190600101614f42565b5092979650505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b81810381811115610f3f57610f3f614f9b565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261507057600080fd5b83018035915067ffffffffffffffff82111561508b57600080fd5b6020019150368190038213156120d657600080fd5b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b6040815260006150fd6040830186886150a0565b82810360208401526151108185876150a0565b979650505050505050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261515057600080fd5b83018035915067ffffffffffffffff82111561516b57600080fd5b6020019150600581901b36038213156120d657600080fd5b60006020828403121561519557600080fd5b81356fffffffffffffffffffffffffffffffff811681146134ff57600080fd5b80820180821115610f3f57610f3f614f9b565b6000602082840312156151da57600080fd5b5051919050565b6000602082840312156151f357600080fd5b815160ff811681146134ff57600080fd5b600181815b8085111561525d57817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111561524357615243614f9b565b8085161561525057918102915b93841c9390800290615209565b509250929050565b60008261527457506001610f3f565b8161528157506000610f3f565b816001811461529757600281146152a1576152bd565b6001915050610f3f565b60ff8411156152b2576152b2614f9b565b50506001821b610f3f565b5060208310610133831016604e8410600b84101617156152e0575081810a610f3f565b6152ea8383615204565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111561531c5761531c614f9b565b029392505050565b60006134ff60ff841683615265565b8082028115828204841417610f3f57610f3f614f9b565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361537b5761537b614f9b565b5060010190565b60608152600061539660608301888a6150a0565b82810360208401526153a98187896150a0565b905082810360408401526153be8185876150a0565b9998505050505050505050565b600082615401577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60008161541557615415614f9b565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b60006020828403121561544d57600080fd5b813561ffff811681146134ff57600080fd5b7fffffffffffffffffffffffffffffffffffffffff0000000000000000000000008460601b168152818360148301376000910160140190815292915050565b6000602082840312156154b057600080fd5b815167ffffffffffffffff808211156154c857600080fd5b818401915084601f8301126154dc57600080fd5b8151818111156154ee576154ee61500c565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019083821181831017156155345761553461500c565b8160405282815287602084870101111561554d57600080fd5b615110836020830160208801614b55565b60008251615570818460208701614b55565b9190910192915050565b60006020828403121561558c57600080fd5b815180151581146134ff57600080fdfea2646970667358221220c646ba442cc31600a00994df0d5fbd01797b6e975d5c41bc27b79242d6fcbefd64736f6c63430008140033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000aa70bc79fd1cb4a6fba717018351f0c3c64b79df0000000000000000000000006c61918eeccc306d35247338fdcf025af0f6120a00000000000000000000000082ca6d313bffe56e9096b16633dfd414148d66b10000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000003e8
-----Decoded View---------------
Arg [0] : tokenImplementation (address): 0xAa70bC79fD1cB4a6FBA717018351F0C3c64B79Df
Arg [1] : multiTokenImplementation (address): 0x6c61918eECcC306D35247338FDcf025af0f6120A
Arg [2] : protocolBeneficiary_ (address): 0x82CA6d313BffE56E9096b16633dfD414148D66b1
Arg [3] : creationFee_ (uint256): 1000000000000000000
Arg [4] : maxSteps (uint256): 1000
-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 000000000000000000000000aa70bc79fd1cb4a6fba717018351f0c3c64b79df
Arg [1] : 0000000000000000000000006c61918eeccc306d35247338fdcf025af0f6120a
Arg [2] : 00000000000000000000000082ca6d313bffe56e9096b16633dfd414148d66b1
Arg [3] : 0000000000000000000000000000000000000000000000000de0b6b3a7640000
Arg [4] : 00000000000000000000000000000000000000000000000000000000000003e8
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|---|---|---|---|---|
BASE | 33.69% | $0.03639 | 6,913,695.6546 | $251,588.62 | |
BASE | 29.70% | $3,435.98 | 64.5518 | $221,798.77 | |
BASE | 21.27% | $0.402872 | 394,310.5006 | $158,856.66 | |
BASE | 2.75% | $0.020511 | 1,002,902.2066 | $20,570.72 | |
BASE | 0.90% | $0.000125 | 53,807,631.7231 | $6,721.65 | |
BASE | 0.50% | $1 | 3,709.237 | $3,709.24 | |
BASE | 0.45% | $98,353 | 0.0344 | $3,379.26 | |
BASE | 0.20% | $0.170579 | 8,644.9953 | $1,474.65 | |
BASE | 0.12% | $0.00062 | 1,421,747.1961 | $881.44 | |
BASE | 0.11% | $0.073348 | 11,274.8525 | $826.98 | |
BASE | 0.10% | $0.119371 | 6,030.8078 | $719.9 | |
BASE | 0.09% | $0.000033 | 20,522,476.9138 | $676.42 | |
BASE | 0.04% | $0.000268 | 1,018,455.032 | $272.91 | |
BASE | 0.03% | $1.4 | 165.6457 | $231.9 | |
BASE | 0.03% | $0.008795 | 23,192.9708 | $203.98 | |
BASE | 0.03% | $0.000205 | 978,062.0015 | $200.26 | |
BASE | 0.02% | $0.028548 | 5,690.7911 | $162.46 | |
BASE | 0.01% | $0.027982 | 3,472.9663 | $97.18 | |
BASE | 0.01% | $0.001231 | 64,438.1919 | $79.33 | |
BASE | <0.01% | <$0.000001 | 632,239,423 | $31.99 | |
BASE | <0.01% | $0.000033 | 772,132.1743 | $25.58 | |
BASE | <0.01% | $3,718.75 | 0.00604627 | $22.48 | |
BASE | <0.01% | $97,936 | 0.00004038 | $3.95 | |
BASE | <0.01% | $167.78 | 0.0103 | $1.73 | |
BASE | <0.01% | $0.023015 | 38 | $0.8745 | |
BASE | <0.01% | <$0.000001 | 90,885,021.1993 | $0.7543 | |
BASE | <0.01% | $0.007596 | 87 | $0.6608 | |
BASE | <0.01% | <$0.000001 | 101,614,027.454 | $0.4267 | |
BASE | <0.01% | $0.000433 | 500 | $0.2164 | |
BASE | <0.01% | $0.407575 | 0.4919 | $0.2004 | |
BASE | <0.01% | $1 | 0.1003 | $0.1003 | |
ETH | 6.52% | $4,057.34 | 12 | $48,688.08 | |
ETH | 0.11% | $3,448.99 | 0.2413 | $832.39 | |
ETH | 0.07% | $0.404171 | 1,342.4757 | $542.59 | |
ETH | 0.07% | $0.000021 | 23,290,369.6491 | $491.43 | |
ETH | 0.03% | $1 | 218.7642 | $218.76 | |
ETH | 0.02% | $98,332 | 0.00123369 | $121.31 | |
ETH | 0.01% | $0.000027 | 3,160,812.1799 | $86.73 | |
ETH | <0.01% | $17.94 | 3.5 | $62.79 | |
ETH | <0.01% | $1 | 47.9709 | $48.07 | |
ETH | <0.01% | $1.1 | 18.8466 | $20.71 | |
ETH | <0.01% | $98,049 | 0.0001003 | $9.83 | |
ETH | <0.01% | $1.35 | 3.0007 | $4.05 | |
ARB | 1.59% | $3,437.48 | 3.4535 | $11,871.41 | |
ARB | 0.26% | $4,062.74 | 0.4833 | $1,963.71 | |
ARB | <0.01% | $0.884555 | 13.9317 | $12.32 | |
ARB | <0.01% | $0.123691 | 69.3775 | $8.58 | |
ARB | <0.01% | $1 | 2.0131 | $2.01 | |
BSC | 0.49% | $0.000003 | 1,349,444,901.8085 | $3,643.5 | |
BSC | 0.21% | $662.01 | 2.384 | $1,578.24 | |
BSC | <0.01% | $98,279.41 | 0.00010016 | $9.84 | |
BSC | <0.01% | $1 | 2.7915 | $2.79 | |
BSC | <0.01% | $2.35 | 0.9247 | $2.17 | |
BSC | <0.01% | $1.48 | 0.2379 | $0.3522 | |
BSC | <0.01% | $0.000027 | 10,577.2536 | $0.2904 | |
BSC | <0.01% | $0.999989 | 0.1036 | $0.1036 | |
APE | 0.31% | $1.34 | 1,752.0362 | $2,347.73 | |
POL | 0.10% | $0.58803 | 1,313.3286 | $772.28 | |
POL | 0.07% | $1 | 555.2295 | $555.78 | |
POL | <0.01% | $0.999773 | 11.4254 | $11.42 | |
POL | <0.01% | $3,438.6 | 0.00004677 | $0.1608 | |
OP | 0.02% | $2.55 | 64.5555 | $164.38 | |
OP | 0.02% | $3,437.48 | 0.0374 | $128.65 | |
OP | <0.01% | $1 | 5.02 | $5.02 | |
OP | <0.01% | $1 | 3.6669 | $3.67 | |
OP | <0.01% | $1 | 3.0018 | $3 | |
OP | <0.01% | $2.29 | 1.2832 | $2.94 |
[ 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.