Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00Cross-Chain Transactions
Loading...
Loading
Contract Name:
PresaleTokenRenderer
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 999999 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity 0.8.20; import {TokenURIRenderer} from "../interfaces/TokenURIRenderer.sol"; import {Strings} from "openzeppelin-contracts/contracts/utils/Strings.sol"; import {DecimalString} from "./DecimalString.sol"; import {DateString} from "./DateString.sol"; import {Base64} from "openzeppelin-contracts/contracts/utils/Base64.sol"; /// @title PresaleTokenRenderer /// @notice Renders the token URI for the presale token contract PresaleTokenRenderer is TokenURIRenderer { function renderSvg(uint256 tokenId, uint256, uint256 notionalUnderlyingAmount, uint256, uint256, uint256) public pure returns (string memory) { // Generate SVG string memory svg = string.concat( // SVG defs & background '<svg width="290" height="500" viewBox="0 0 290 500" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">', '<defs><path id="text-path-a" d="M40 12 H250 A28 28 0 0 1 278 40 V460 A28 28 0 0 1 250 488 H40 A28 28 0 0 1 12 460 V40 A28 28 0 0 1 40 12 z" /></defs>', '<rect x="0" y="0" width="290" height="500" rx="42" fill="#E3E6F9" stroke="#F4F5F9"/>', '<rect x="16" y="16" width="258" height="468" rx="26" ry="26" stroke="#D5DAEF"/>', // STRAT Logo '<path fill="#000" d="M65.5 34a19.5 19.5 0 1 1-6.44 37.91l1.55-1.55a17.56 17.56 0 1 0-11.4-10.33l-1.5 1.49A19.5 19.5 0 0 1 65.5 34M54.3 67.02a18 18 0 0 0 4.28 2.61l-1.47 1.48a20 20 0 0 1-4.19-2.7zM50.1 61.9a18 18 0 0 0 2.78 3.79l-1.37 1.38a20 20 0 0 1-2.84-3.73z"/>', '<path fill="#000" d="M72.14 58.84 60.6 70.36q-1.04-.3-2.03-.73l12.18-12.17zm-3.22-6.44L54.3 67.02q-.75-.63-1.44-1.33l14.67-14.67zm-3.02-6.3L50.09 61.9q-.5-.9-.88-1.87l15.3-15.31z"/>', // Pink ETH '<path d="M145 201 84 229 145 127z" fill="#F1E2E9"/>', '<path d="M145 201 84 229l61 36z" fill="#F6ADC4"/>', '<path d="m145 201 61 28L145 127z" fill="#FFAAC3"/>', '<path d="m145 201 61 28-61 36z" fill="#F78AA8"/>', '<path d="m84 240.5 61 86.5v-45z" fill="#F4C1D1"/>', '<path d="M207 240.5 145 327v-45z" fill="#FEA4BA"/>', '<path d="M145 277 84 240.5l61 42 61-42z" fill="#FECADF"/>', // Title Text '<path fill="#000" d="M94.82 96V84.8h4.2q1.42 0 2.44.46 1.03.45 1.57 1.32.57.84.56 2.06 0 1.18-.56 2.05-.54.84-1.57 1.31-1.03.45-2.44.46h-3.54l.53-.56V96zm1.19-4-.53-.58h3.5q1.68 0 2.55-.72.87-.73.88-2.06 0-1.35-.88-2.08-.87-.75-2.55-.74h-3.5l.53-.56zm10.94 4V84.8h4.2q1.42 0 2.44.46 1.03.45 1.57 1.32.56.84.56 2.06 0 1.18-.56 2.05-.54.84-1.57 1.31-1.02.45-2.45.45h-3.53l.53-.55V96zm7.65 0-2.88-4.06H113l2.9 4.06zm-6.46-4-.53-.56h3.5q1.68 0 2.55-.74.88-.73.88-2.06 0-1.35-.88-2.08-.87-.75-2.55-.74h-3.5l.53-.56zm12.23-2.2h5.92v1.02h-5.92zm.13 5.18h6.74V96h-7.92V84.8H127v1.02h-6.5zm13.4 1.12q-1.25 0-2.4-.4a5 5 0 0 1-1.75-1.06l.46-.91q.6.57 1.58.97a6 6 0 0 0 3.83.13q.67-.27.97-.72.32-.45.32-.99 0-.66-.38-1.06a2.5 2.5 0 0 0-.98-.62q-.6-.24-1.34-.42t-1.47-.36a7 7 0 0 1-1.36-.55q-.6-.34-1-.88a2.6 2.6 0 0 1-.36-1.45 2.8 2.8 0 0 1 1.79-2.64q.9-.44 2.34-.44a6.6 6.6 0 0 1 3.47 1l-.4.94q-.72-.48-1.54-.7a6 6 0 0 0-1.55-.23q-1.01 0-1.66.27-.66.28-.98.74-.3.45-.3 1.02 0 .66.36 1.06.39.4 1 .62.61.23 1.36.4.73.18 1.45.39.74.21 1.35.54.61.32.99.87.38.54.38 1.42 0 .81-.45 1.52-.45.69-1.37 1.12-.92.42-2.35.42m5.77-.1 5.12-11.2h1.17l5.12 11.2h-1.25l-4.7-10.51h.48L140.9 96zm2.02-3 .35-.95h6.51l.35.96zm14.06 3v-4.16l.27.74-4.75-7.78h1.26l4.18 6.83h-.68l4.18-6.83h1.18l-4.75 7.78.27-.74V96zm8.05 0V84.8h1.18v10.18h6.27V96zm14.9.1q-1.27 0-2.36-.42a6 6 0 0 1-1.87-1.2 6 6 0 0 1-1.23-1.8 6 6 0 0 1-.43-2.28q0-1.23.43-2.26a5.6 5.6 0 0 1 3.1-3q1.08-.44 2.35-.44t2.34.44a5.4 5.4 0 0 1 3.09 2.99q.45 1.05.45 2.27a5.7 5.7 0 0 1-1.68 4.08q-.79.77-1.86 1.2a6 6 0 0 1-2.34.42m0-1.06a5 5 0 0 0 1.85-.34 4.5 4.5 0 0 0 2.48-2.44q.36-.85.35-1.86a4.7 4.7 0 0 0-1.34-3.31 4.8 4.8 0 0 0-3.34-1.33 5 5 0 0 0-3.38 1.33q-.63.61-1 1.47a5 5 0 0 0-.34 1.84 4.8 4.8 0 0 0 1.34 3.33 4.6 4.6 0 0 0 3.38 1.31m9.32.96V84.8h4.2q1.41 0 2.44.46 1.02.45 1.57 1.32.56.84.56 2.06 0 1.18-.56 2.05-.55.84-1.57 1.31-1.02.45-2.45.45h-3.53l.53-.55V96zm7.65 0-2.88-4.06h1.28l2.9 4.06zm-6.46-4-.53-.56h3.5q1.68 0 2.54-.74.89-.73.88-2.06 0-1.35-.87-2.08-.87-.75-2.55-.74h-3.5l.53-.56zM65.5 34a19.5 19.5 0 1 1-6.44 37.91l1.55-1.55a17.56 17.56 0 1 0-11.4-10.33l-1.5 1.49A19.5 19.5 0 0 1 65.5 34M54.3 67.02a18 18 0 0 0 4.28 2.61l-1.47 1.48a20 20 0 0 1-4.19-2.7zM50.1 61.9a18 18 0 0 0 2.78 3.79l-1.37 1.38a20 20 0 0 1-2.84-3.73z"/>', '<path fill="#000" d="M72.14 58.84 60.6 70.36q-1.04-.3-2.03-.73l12.18-12.17zm-3.22-6.44L54.3 67.02q-.75-.63-1.44-1.33l14.67-14.67zm-3.02-6.3L50.09 61.9q-.5-.9-.88-1.87l15.3-15.31zM100.8 64.42q-2.15 0-4.11-.68a8 8 0 0 1-3.01-1.81l.8-1.56a8 8 0 0 0 2.7 1.67q1.73.66 3.62.65a8 8 0 0 0 2.93-.43 3.6 3.6 0 0 0 1.67-1.24q.55-.75.55-1.7a2.5 2.5 0 0 0-.66-1.8 4 4 0 0 0-1.67-1.07q-1.05-.4-2.3-.71l-2.52-.63q-1.26-.36-2.33-.93a5 5 0 0 1-1.7-1.5 4.5 4.5 0 0 1-.63-2.5q0-1.43.74-2.6a5.2 5.2 0 0 1 2.33-1.92 9 9 0 0 1 4-.74 11.3 11.3 0 0 1 5.94 1.7l-.68 1.61a9.83 9.83 0 0 0-5.29-1.59 8 8 0 0 0-2.85.47q-1.11.46-1.67 1.26-.52.77-.52 1.75 0 1.12.63 1.81.66.69 1.7 1.07 1.07.38 2.33.68t2.5.66q1.25.36 2.3.93 1.06.55 1.69 1.48.66.93.66 2.44 0 1.4-.77 2.6a5.5 5.5 0 0 1-2.36 1.92 10 10 0 0 1-4.02.71m16.4-.16V46.84h-6.75v-1.76h15.5v1.76h-6.73v17.42zm13.36 0V45.08h7.18q2.43 0 4.19.8a6 6 0 0 1 2.68 2.24q.96 1.45.96 3.54a6.3 6.3 0 0 1-.96 3.5 6 6 0 0 1-2.68 2.25q-1.75.77-4.2.77h-6.04l.9-.94v7.02zm13.1 0-4.94-6.96h2.2l4.95 6.96zm-11.07-6.85-.9-.96h6q2.87 0 4.35-1.26 1.5-1.26 1.5-3.53 0-2.3-1.5-3.56-1.48-1.26-4.36-1.26h-6l.91-.96zm16.07 6.85 8.76-19.18h2l8.77 19.18h-2.14l-8.05-18h.82l-8.05 18zm3.45-5.13.6-1.64h11.15l.6 1.64zm23.38 5.13V46.84h-6.74v-1.76h15.5v1.76h-6.73v17.42zm40.24.16q-2.18 0-4.05-.71a10 10 0 0 1-3.2-2.06q-1.35-1.3-2.11-3.1-.75-1.77-.74-3.88 0-2.1.74-3.89a9.4 9.4 0 0 1 5.34-5.12q1.86-.75 4.05-.74 2.2 0 4 .68a8 8 0 0 1 3.12 2.09l-1.26 1.28a7 7 0 0 0-2.66-1.72q-1.44-.52-3.12-.52-1.78 0-3.28.6a7.7 7.7 0 0 0-4.94 7.34q0 1.7.6 3.15.64 1.45 1.73 2.55a8 8 0 0 0 2.6 1.67q1.52.57 3.26.57 1.65 0 3.1-.5a7 7 0 0 0 2.71-1.66l1.15 1.53a9 9 0 0 1-3.2 1.84q-1.84.6-3.84.6m5.1-2.68v-7.07h1.94v7.31zm13.62 2.52v-7.13l.47 1.26-8.14-13.3h2.17l7.15 11.69h-1.16l7.15-11.7h2.03l-8.13 13.31.46-1.26v7.13zM188.8 62.5v1.76h14.15l-1.18-1.76zM188.8 53.74v1.75h11.94v-1.75zM188.8 45.08v1.76h12.97l1.16-1.76z"/>', // Token ID '<text x="30" y="370" fill="black" font-family="sans-serif" font-size="14px" font-weight="300">Token ID</text>', '<text x="30" y="390" fill="black" font-family="sans-serif" font-size="16px" font-weight="500">', Strings.toString(tokenId), "</text>", // STRAT Purchased '<text x="260" y="370" text-anchor="end" fill="black" font-family="sans-serif" font-size="14px" font-weight="300">STRAT Purchased</text>', '<text x="260" y="390" text-anchor="end" fill="black" font-family="sans-serif" font-size="16px" font-weight="500">', DecimalString.toDecimalString(notionalUnderlyingAmount, 18, 0), "</text>", // Unlock Time '<text x="30" y="420" fill="black" font-family="sans-serif" font-size="14px" font-weight="300">Vesting Terms</text>', '<text x="30" y="440" fill="black" font-family="sans-serif" font-size="12px" font-weight="500">STRAT vests for 6 months post-launch</text>', // Border text generateSVGBorderText(), "</svg>" ); return svg; } function render( uint256 tokenId, uint256 strikeAmount, uint256 notionalUnderlyingAmount, uint256 notionalUSDAmount, uint256 expiry, uint256 timelock ) external pure returns (string memory) { // If not a presale token, return nothing if (!(strikeAmount == 0 && notionalUSDAmount == 0)) { return ""; } string memory svg = renderSvg(tokenId, strikeAmount, notionalUnderlyingAmount, notionalUSDAmount, expiry, timelock); // Encode SVG to base64 string memory base64Svg = Base64.encode(bytes(svg)); return string.concat( "{", string.concat('"name": "', "ETH Strategy Presale", '",'), string.concat('"symbol": "', "oSTRAT", '",'), string.concat('"image": "', "data:image/svg+xml;base64,", base64Svg, '",'), '"attributes": []', "}" ); } function generateSVGBorderText() private pure returns (string memory svg) { svg = string( abi.encodePacked( '<text text-rendering="optimizeSpeed">', '<textPath startOffset="-100%" fill="black" font-family="monospace" font-size="10px" xlink:href="#text-path-a">', "Presale STRAT locked up for 4 months...", ' <animate additive="sum" attributeName="startOffset" from="0%" to="100%" begin="0s" dur="30s" repeatCount="indefinite" />', '</textPath> <textPath startOffset="0%" fill="black" font-family="monospace" font-size="10px" xlink:href="#text-path-a">', "Presale STRAT locked up for 4 months...", ' <animate additive="sum" attributeName="startOffset" from="0%" to="100%" begin="0s" dur="30s" repeatCount="indefinite" /> </textPath>', '<textPath startOffset="50%" fill="black" font-family="monospace" font-size="10px" xlink:href="#text-path-a">', "...then vests linearly over 2 months", ' <animate additive="sum" attributeName="startOffset" from="0%" to="100%" begin="0s" dur="30s"', ' repeatCount="indefinite" /></textPath><textPath startOffset="-50%" fill="black" font-family="monospace" font-size="10px" xlink:href="#text-path-a">', "...then vests linearly over 2 months", ' <animate additive="sum" attributeName="startOffset" from="0%" to="100%" begin="0s" dur="30s" repeatCount="indefinite" /></textPath></text>' ) ); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.0; interface TokenURIRenderer { function render( uint256 tokenId, uint256 strikeAmount, uint256 notionalUnderlyingAmount, uint256 notionalUSDAmount, uint256 expiry, uint256 timelock ) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.2.0) (utils/Strings.sol) pragma solidity ^0.8.20; import {Math} from "./math/Math.sol"; import {SafeCast} from "./math/SafeCast.sol"; import {SignedMath} from "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { using SafeCast for *; 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 The string being parsed contains characters that are not in scope of the given base. */ error StringsInvalidChar(); /** * @dev The string being parsed is not a properly formatted address. */ error StringsInvalidAddressFormat(); /** * @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; assembly ("memory-safe") { ptr := add(buffer, add(32, length)) } while (true) { ptr--; assembly ("memory-safe") { 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 Converts an `address` with fixed length of 20 bytes to its checksummed ASCII `string` hexadecimal * representation, according to EIP-55. */ function toChecksumHexString(address addr) internal pure returns (string memory) { bytes memory buffer = bytes(toHexString(addr)); // hash the hex part of buffer (skip length + 2 bytes, length 40) uint256 hashValue; assembly ("memory-safe") { hashValue := shr(96, keccak256(add(buffer, 0x22), 40)) } for (uint256 i = 41; i > 1; --i) { // possible values for buffer[i] are 48 (0) to 57 (9) and 97 (a) to 102 (f) if (hashValue & 0xf > 7 && uint8(buffer[i]) > 96) { // case shift by xoring with 0x20 buffer[i] ^= 0x20; } hashValue >>= 4; } return string(buffer); } /** * @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)); } /** * @dev Parse a decimal string and returns the value as a `uint256`. * * Requirements: * - The string must be formatted as `[0-9]*` * - The result must fit into an `uint256` type */ function parseUint(string memory input) internal pure returns (uint256) { return parseUint(input, 0, bytes(input).length); } /** * @dev Variant of {parseUint-string} that parses a substring of `input` located between position `begin` (included) and * `end` (excluded). * * Requirements: * - The substring must be formatted as `[0-9]*` * - The result must fit into an `uint256` type */ function parseUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) { (bool success, uint256 value) = tryParseUint(input, begin, end); if (!success) revert StringsInvalidChar(); return value; } /** * @dev Variant of {parseUint-string} that returns false if the parsing fails because of an invalid character. * * NOTE: This function will revert if the result does not fit in a `uint256`. */ function tryParseUint(string memory input) internal pure returns (bool success, uint256 value) { return _tryParseUintUncheckedBounds(input, 0, bytes(input).length); } /** * @dev Variant of {parseUint-string-uint256-uint256} that returns false if the parsing fails because of an invalid * character. * * NOTE: This function will revert if the result does not fit in a `uint256`. */ function tryParseUint( string memory input, uint256 begin, uint256 end ) internal pure returns (bool success, uint256 value) { if (end > bytes(input).length || begin > end) return (false, 0); return _tryParseUintUncheckedBounds(input, begin, end); } /** * @dev Implementation of {tryParseUint-string-uint256-uint256} that does not check bounds. Caller should make sure that * `begin <= end <= input.length`. Other inputs would result in undefined behavior. */ function _tryParseUintUncheckedBounds( string memory input, uint256 begin, uint256 end ) private pure returns (bool success, uint256 value) { bytes memory buffer = bytes(input); uint256 result = 0; for (uint256 i = begin; i < end; ++i) { uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i))); if (chr > 9) return (false, 0); result *= 10; result += chr; } return (true, result); } /** * @dev Parse a decimal string and returns the value as a `int256`. * * Requirements: * - The string must be formatted as `[-+]?[0-9]*` * - The result must fit in an `int256` type. */ function parseInt(string memory input) internal pure returns (int256) { return parseInt(input, 0, bytes(input).length); } /** * @dev Variant of {parseInt-string} that parses a substring of `input` located between position `begin` (included) and * `end` (excluded). * * Requirements: * - The substring must be formatted as `[-+]?[0-9]*` * - The result must fit in an `int256` type. */ function parseInt(string memory input, uint256 begin, uint256 end) internal pure returns (int256) { (bool success, int256 value) = tryParseInt(input, begin, end); if (!success) revert StringsInvalidChar(); return value; } /** * @dev Variant of {parseInt-string} that returns false if the parsing fails because of an invalid character or if * the result does not fit in a `int256`. * * NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`. */ function tryParseInt(string memory input) internal pure returns (bool success, int256 value) { return _tryParseIntUncheckedBounds(input, 0, bytes(input).length); } uint256 private constant ABS_MIN_INT256 = 2 ** 255; /** * @dev Variant of {parseInt-string-uint256-uint256} that returns false if the parsing fails because of an invalid * character or if the result does not fit in a `int256`. * * NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`. */ function tryParseInt( string memory input, uint256 begin, uint256 end ) internal pure returns (bool success, int256 value) { if (end > bytes(input).length || begin > end) return (false, 0); return _tryParseIntUncheckedBounds(input, begin, end); } /** * @dev Implementation of {tryParseInt-string-uint256-uint256} that does not check bounds. Caller should make sure that * `begin <= end <= input.length`. Other inputs would result in undefined behavior. */ function _tryParseIntUncheckedBounds( string memory input, uint256 begin, uint256 end ) private pure returns (bool success, int256 value) { bytes memory buffer = bytes(input); // Check presence of a negative sign. bytes1 sign = begin == end ? bytes1(0) : bytes1(_unsafeReadBytesOffset(buffer, begin)); // don't do out-of-bound (possibly unsafe) read if sub-string is empty bool positiveSign = sign == bytes1("+"); bool negativeSign = sign == bytes1("-"); uint256 offset = (positiveSign || negativeSign).toUint(); (bool absSuccess, uint256 absValue) = tryParseUint(input, begin + offset, end); if (absSuccess && absValue < ABS_MIN_INT256) { return (true, negativeSign ? -int256(absValue) : int256(absValue)); } else if (absSuccess && negativeSign && absValue == ABS_MIN_INT256) { return (true, type(int256).min); } else return (false, 0); } /** * @dev Parse a hexadecimal string (with or without "0x" prefix), and returns the value as a `uint256`. * * Requirements: * - The string must be formatted as `(0x)?[0-9a-fA-F]*` * - The result must fit in an `uint256` type. */ function parseHexUint(string memory input) internal pure returns (uint256) { return parseHexUint(input, 0, bytes(input).length); } /** * @dev Variant of {parseHexUint-string} that parses a substring of `input` located between position `begin` (included) and * `end` (excluded). * * Requirements: * - The substring must be formatted as `(0x)?[0-9a-fA-F]*` * - The result must fit in an `uint256` type. */ function parseHexUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) { (bool success, uint256 value) = tryParseHexUint(input, begin, end); if (!success) revert StringsInvalidChar(); return value; } /** * @dev Variant of {parseHexUint-string} that returns false if the parsing fails because of an invalid character. * * NOTE: This function will revert if the result does not fit in a `uint256`. */ function tryParseHexUint(string memory input) internal pure returns (bool success, uint256 value) { return _tryParseHexUintUncheckedBounds(input, 0, bytes(input).length); } /** * @dev Variant of {parseHexUint-string-uint256-uint256} that returns false if the parsing fails because of an * invalid character. * * NOTE: This function will revert if the result does not fit in a `uint256`. */ function tryParseHexUint( string memory input, uint256 begin, uint256 end ) internal pure returns (bool success, uint256 value) { if (end > bytes(input).length || begin > end) return (false, 0); return _tryParseHexUintUncheckedBounds(input, begin, end); } /** * @dev Implementation of {tryParseHexUint-string-uint256-uint256} that does not check bounds. Caller should make sure that * `begin <= end <= input.length`. Other inputs would result in undefined behavior. */ function _tryParseHexUintUncheckedBounds( string memory input, uint256 begin, uint256 end ) private pure returns (bool success, uint256 value) { bytes memory buffer = bytes(input); // skip 0x prefix if present bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(buffer, begin)) == bytes2("0x"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty uint256 offset = hasPrefix.toUint() * 2; uint256 result = 0; for (uint256 i = begin + offset; i < end; ++i) { uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i))); if (chr > 15) return (false, 0); result *= 16; unchecked { // Multiplying by 16 is equivalent to a shift of 4 bits (with additional overflow check). // This guarantees that adding a value < 16 will not cause an overflow, hence the unchecked. result += chr; } } return (true, result); } /** * @dev Parse a hexadecimal string (with or without "0x" prefix), and returns the value as an `address`. * * Requirements: * - The string must be formatted as `(0x)?[0-9a-fA-F]{40}` */ function parseAddress(string memory input) internal pure returns (address) { return parseAddress(input, 0, bytes(input).length); } /** * @dev Variant of {parseAddress-string} that parses a substring of `input` located between position `begin` (included) and * `end` (excluded). * * Requirements: * - The substring must be formatted as `(0x)?[0-9a-fA-F]{40}` */ function parseAddress(string memory input, uint256 begin, uint256 end) internal pure returns (address) { (bool success, address value) = tryParseAddress(input, begin, end); if (!success) revert StringsInvalidAddressFormat(); return value; } /** * @dev Variant of {parseAddress-string} that returns false if the parsing fails because the input is not a properly * formatted address. See {parseAddress-string} requirements. */ function tryParseAddress(string memory input) internal pure returns (bool success, address value) { return tryParseAddress(input, 0, bytes(input).length); } /** * @dev Variant of {parseAddress-string-uint256-uint256} that returns false if the parsing fails because input is not a properly * formatted address. See {parseAddress-string-uint256-uint256} requirements. */ function tryParseAddress( string memory input, uint256 begin, uint256 end ) internal pure returns (bool success, address value) { if (end > bytes(input).length || begin > end) return (false, address(0)); bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(bytes(input), begin)) == bytes2("0x"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty uint256 expectedLength = 40 + hasPrefix.toUint() * 2; // check that input is the correct length if (end - begin == expectedLength) { // length guarantees that this does not overflow, and value is at most type(uint160).max (bool s, uint256 v) = _tryParseHexUintUncheckedBounds(input, begin, end); return (s, address(uint160(v))); } else { return (false, address(0)); } } function _tryParseChr(bytes1 chr) private pure returns (uint8) { uint8 value = uint8(chr); // Try to parse `chr`: // - Case 1: [0-9] // - Case 2: [a-f] // - Case 3: [A-F] // - otherwise not supported unchecked { if (value > 47 && value < 58) value -= 48; else if (value > 96 && value < 103) value -= 87; else if (value > 64 && value < 71) value -= 55; else return type(uint8).max; } return value; } /** * @dev Reads a bytes32 from a bytes array without bounds checking. * * NOTE: making this function internal would mean it could be used with memory unsafe offset, and marking the * assembly block as such would prevent some optimizations. */ function _unsafeReadBytesOffset(bytes memory buffer, uint256 offset) private pure returns (bytes32 value) { // This is not memory safe in the general case, but all calls to this private function are within bounds. assembly ("memory-safe") { value := mload(add(buffer, add(0x20, offset))) } } }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity ^0.8; import {Strings} from "openzeppelin-contracts/contracts/utils/Strings.sol"; library DecimalString { /// @notice Converts a uint256 value to a string with a specified number of decimal places. /// The value is adjusted by the scale factor and then formatted to the specified number of decimal places. /// The decimal places are not zero-padded, so the result is not always the same length. /// @dev This is inspired by code in /// [FixedStrikeOptionTeller](https://github.com/Bond-Protocol/option-contracts/blob/b8ce2ca2bae3bd06f0e7665c3aa8d827e4d8ca2c/src/fixed-strike/FixedStrikeOptionTeller.sol#L722). /// /// @param value_ The uint256 value to convert to a string. /// @param valueDecimals_ The scale factor of the value. /// @param decimalPlaces_ The number of decimal places to format the value to. /// @return result A string representation of the value with the specified number of decimal places. function toDecimalString(uint256 value_, uint8 valueDecimals_, uint8 decimalPlaces_) internal pure returns (string memory) { // Handle zero case if (value_ == 0) return "0"; // Convert the entire number to string first string memory str = Strings.toString(value_); bytes memory bStr = bytes(str); // If no decimal places requested, just handle the scaling and return if (decimalPlaces_ == 0) { if (bStr.length <= valueDecimals_) return "0"; return Strings.toString(value_ / (10 ** valueDecimals_)); } // If value is a whole number, return as-is if (valueDecimals_ == 0) return str; // Calculate decimal places to show (limited by request and available decimals) uint256 maxDecimalPlaces = valueDecimals_ > decimalPlaces_ ? decimalPlaces_ : valueDecimals_; // Handle numbers smaller than 1 if (bStr.length <= valueDecimals_) { bytes memory smallResult = new bytes(2 + maxDecimalPlaces); smallResult[0] = "0"; smallResult[1] = "."; uint256 leadingZeros = valueDecimals_ - bStr.length; uint256 zerosToAdd = leadingZeros > maxDecimalPlaces ? maxDecimalPlaces : leadingZeros; // Add leading zeros after decimal for (uint256 i = 0; i < zerosToAdd; i++) { smallResult[i + 2] = "0"; } // Add available digits for (uint256 i = 0; i < maxDecimalPlaces - zerosToAdd && i < bStr.length; i++) { smallResult[i + 2 + zerosToAdd] = bStr[i]; } return string(smallResult); } // Find decimal position and last significant digit uint256 decimalPosition = bStr.length - valueDecimals_; uint256 lastNonZeroPos = decimalPosition; for (uint256 i = 0; i < maxDecimalPlaces && i + decimalPosition < bStr.length; i++) { if (bStr[decimalPosition + i] != "0") { lastNonZeroPos = decimalPosition + i + 1; } } // Create and populate result bytes memory finalResult = new bytes(lastNonZeroPos - decimalPosition > 0 ? lastNonZeroPos + 1 : lastNonZeroPos); for (uint256 i = 0; i < decimalPosition; i++) { finalResult[i] = bStr[i]; } if (lastNonZeroPos > decimalPosition) { finalResult[decimalPosition] = "."; for (uint256 i = 0; i < lastNonZeroPos - decimalPosition; i++) { finalResult[decimalPosition + 1 + i] = bStr[decimalPosition + i]; } } return string(finalResult); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8; import {Strings} from "openzeppelin-contracts/contracts/utils/Strings.sol"; library DateString { function toPaddedString(uint256 timestamp) internal pure returns (string memory) { // Convert a number of days into a human-readable date, courtesy of BokkyPooBah. // Source: // https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary/blob/master/contracts/BokkyPooBahsDateTimeLibrary.sol uint256 year; uint256 month; uint256 day; { int256 __days = int256(int256(timestamp) / 1 days); int256 num1 = __days + 68_569 + 2_440_588; // 2440588 = OFFSET19700101 int256 num2 = (4 * num1) / 146_097; num1 = num1 - (146_097 * num2 + 3) / 4; int256 _year = (4000 * (num1 + 1)) / 1_461_001; num1 = num1 - (1461 * _year) / 4 + 31; int256 _month = (80 * num1) / 2447; int256 _day = num1 - (2447 * _month) / 80; num1 = _month / 11; _month = _month + 2 - 12 * num1; _year = 100 * (num2 - 49) + _year + num1; year = uint256(_year); month = uint256(_month); day = uint256(_day); } string memory yearStr = Strings.toString(year % 10_000); string memory monthStr = month < 10 ? string(abi.encodePacked("0", Strings.toString(month))) : Strings.toString(month); string memory dayStr = day < 10 ? string(abi.encodePacked("0", Strings.toString(day))) : Strings.toString(day); return string.concat(yearStr, "-", monthStr, "-", dayStr); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Base64.sol) pragma solidity ^0.8.20; /** * @dev Provides a set of functions to operate with Base64 strings. */ library Base64 { /** * @dev Base64 Encoding/Decoding Table * See sections 4 and 5 of https://datatracker.ietf.org/doc/html/rfc4648 */ string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; string internal constant _TABLE_URL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; /** * @dev Converts a `bytes` to its Bytes64 `string` representation. */ function encode(bytes memory data) internal pure returns (string memory) { return _encode(data, _TABLE, true); } /** * @dev Converts a `bytes` to its Bytes64Url `string` representation. * Output is not padded with `=` as specified in https://www.rfc-editor.org/rfc/rfc4648[rfc4648]. */ function encodeURL(bytes memory data) internal pure returns (string memory) { return _encode(data, _TABLE_URL, false); } /** * @dev Internal table-agnostic conversion */ function _encode(bytes memory data, string memory table, bool withPadding) private pure returns (string memory) { /** * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol */ if (data.length == 0) return ""; // If padding is enabled, the final length should be `bytes` data length divided by 3 rounded up and then // multiplied by 4 so that it leaves room for padding the last chunk // - `data.length + 2` -> Prepare for division rounding up // - `/ 3` -> Number of 3-bytes chunks (rounded up) // - `4 *` -> 4 characters for each chunk // This is equivalent to: 4 * Math.ceil(data.length / 3) // // If padding is disabled, the final length should be `bytes` data length multiplied by 4/3 rounded up as // opposed to when padding is required to fill the last chunk. // - `4 * data.length` -> 4 characters for each chunk // - ` + 2` -> Prepare for division rounding up // - `/ 3` -> Number of 3-bytes chunks (rounded up) // This is equivalent to: Math.ceil((4 * data.length) / 3) uint256 resultLength = withPadding ? 4 * ((data.length + 2) / 3) : (4 * data.length + 2) / 3; string memory result = new string(resultLength); assembly ("memory-safe") { // Prepare the lookup table (skip the first "length" byte) let tablePtr := add(table, 1) // Prepare result pointer, jump over length let resultPtr := add(result, 0x20) let dataPtr := data let endPtr := add(data, mload(data)) // In some cases, the last iteration will read bytes after the end of the data. We cache the value, and // set it to zero to make sure no dirty bytes are read in that section. let afterPtr := add(endPtr, 0x20) let afterCache := mload(afterPtr) mstore(afterPtr, 0x00) // Run over the input, 3 bytes at a time for { } lt(dataPtr, endPtr) { } { // Advance 3 bytes dataPtr := add(dataPtr, 3) let input := mload(dataPtr) // To write each character, shift the 3 byte (24 bits) chunk // 4 times in blocks of 6 bits for each character (18, 12, 6, 0) // and apply logical AND with 0x3F to bitmask the least significant 6 bits. // Use this as an index into the lookup table, mload an entire word // so the desired character is in the least significant byte, and // mstore8 this least significant byte into the result and continue. mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F)))) resultPtr := add(resultPtr, 1) // Advance mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F)))) resultPtr := add(resultPtr, 1) // Advance mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F)))) resultPtr := add(resultPtr, 1) // Advance mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F)))) resultPtr := add(resultPtr, 1) // Advance } // Reset the value that was cached mstore(afterPtr, afterCache) if withPadding { // When data `bytes` is not exactly 3 bytes long // it is padded with `=` characters at the end switch mod(mload(data), 3) case 1 { mstore8(sub(resultPtr, 1), 0x3d) mstore8(sub(resultPtr, 2), 0x3d) } case 2 { mstore8(sub(resultPtr, 1), 0x3d) } } } return result; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/math/Math.sol) pragma solidity ^0.8.20; import {Panic} from "../Panic.sol"; import {SafeCast} from "./SafeCast.sol"; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an success flag (no overflow). */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an success flag (no overflow). */ function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an success flag (no overflow). */ function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a success flag (no division by zero). */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero). */ function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant. * * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone. * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute * one branch when needed, making this function more expensive. */ function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) { unchecked { // branchless ternary works because: // b ^ (a ^ b) == a // b ^ 0 == b return b ^ ((a ^ b) * SafeCast.toUint(condition)); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return ternary(a > b, a, b); } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return ternary(a < b, a, b); } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. Panic.panic(Panic.DIVISION_BY_ZERO); } // The following calculation ensures accurate ceiling division without overflow. // Since a is non-zero, (a - 1) / b will not overflow. // The largest possible result occurs when (a - 1) / b is type(uint256).max, // but the largest value we can obtain is type(uint256).max - 1, which happens // when a = type(uint256).max and b = 1. unchecked { return SafeCast.toUint(a > 0) * ((a - 1) / b + 1); } } /** * @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * * Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by * Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2²⁵⁶ and mod 2²⁵⁶ - 1, then use // the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2²⁵⁶ + prod0. uint256 prod0 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0. if (denominator <= prod1) { Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW)); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. // Always >= 1. See https://cs.stackexchange.com/q/138556/92363. uint256 twos = denominator & (0 - denominator); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2²⁵⁶ / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such // that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv ≡ 1 mod 2⁴. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also // works in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2⁸ inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶ inverse *= 2 - denominator * inverse; // inverse mod 2³² inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴ inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸ inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶ // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2²⁵⁶. Since the preconditions guarantee that the outcome is // less than 2²⁵⁶, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @dev Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0); } /** * @dev Calculate the modular multiplicative inverse of a number in Z/nZ. * * If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0. * If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible. * * If the input value is not inversible, 0 is returned. * * NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the * inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}. */ function invMod(uint256 a, uint256 n) internal pure returns (uint256) { unchecked { if (n == 0) return 0; // The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version) // Used to compute integers x and y such that: ax + ny = gcd(a, n). // When the gcd is 1, then the inverse of a modulo n exists and it's x. // ax + ny = 1 // ax = 1 + (-y)n // ax ≡ 1 (mod n) # x is the inverse of a modulo n // If the remainder is 0 the gcd is n right away. uint256 remainder = a % n; uint256 gcd = n; // Therefore the initial coefficients are: // ax + ny = gcd(a, n) = n // 0a + 1n = n int256 x = 0; int256 y = 1; while (remainder != 0) { uint256 quotient = gcd / remainder; (gcd, remainder) = ( // The old remainder is the next gcd to try. remainder, // Compute the next remainder. // Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd // where gcd is at most n (capped to type(uint256).max) gcd - remainder * quotient ); (x, y) = ( // Increment the coefficient of a. y, // Decrement the coefficient of n. // Can overflow, but the result is casted to uint256 so that the // next value of y is "wrapped around" to a value between 0 and n - 1. x - y * int256(quotient) ); } if (gcd != 1) return 0; // No inverse exists. return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative. } } /** * @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`. * * From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is * prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that * `a**(p-2)` is the modular multiplicative inverse of a in Fp. * * NOTE: this function does NOT check that `p` is a prime greater than `2`. */ function invModPrime(uint256 a, uint256 p) internal view returns (uint256) { unchecked { return Math.modExp(a, p - 2, p); } } /** * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m) * * Requirements: * - modulus can't be zero * - underlying staticcall to precompile must succeed * * IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make * sure the chain you're using it on supports the precompiled contract for modular exponentiation * at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, * the underlying function will succeed given the lack of a revert, but the result may be incorrectly * interpreted as 0. */ function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) { (bool success, uint256 result) = tryModExp(b, e, m); if (!success) { Panic.panic(Panic.DIVISION_BY_ZERO); } return result; } /** * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m). * It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying * to operate modulo 0 or if the underlying precompile reverted. * * IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain * you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in * https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack * of a revert, but the result may be incorrectly interpreted as 0. */ function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) { if (m == 0) return (false, 0); assembly ("memory-safe") { let ptr := mload(0x40) // | Offset | Content | Content (Hex) | // |-----------|------------|--------------------------------------------------------------------| // | 0x00:0x1f | size of b | 0x0000000000000000000000000000000000000000000000000000000000000020 | // | 0x20:0x3f | size of e | 0x0000000000000000000000000000000000000000000000000000000000000020 | // | 0x40:0x5f | size of m | 0x0000000000000000000000000000000000000000000000000000000000000020 | // | 0x60:0x7f | value of b | 0x<.............................................................b> | // | 0x80:0x9f | value of e | 0x<.............................................................e> | // | 0xa0:0xbf | value of m | 0x<.............................................................m> | mstore(ptr, 0x20) mstore(add(ptr, 0x20), 0x20) mstore(add(ptr, 0x40), 0x20) mstore(add(ptr, 0x60), b) mstore(add(ptr, 0x80), e) mstore(add(ptr, 0xa0), m) // Given the result < m, it's guaranteed to fit in 32 bytes, // so we can use the memory scratch space located at offset 0. success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20) result := mload(0x00) } } /** * @dev Variant of {modExp} that supports inputs of arbitrary length. */ function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) { (bool success, bytes memory result) = tryModExp(b, e, m); if (!success) { Panic.panic(Panic.DIVISION_BY_ZERO); } return result; } /** * @dev Variant of {tryModExp} that supports inputs of arbitrary length. */ function tryModExp( bytes memory b, bytes memory e, bytes memory m ) internal view returns (bool success, bytes memory result) { if (_zeroBytes(m)) return (false, new bytes(0)); uint256 mLen = m.length; // Encode call args in result and move the free memory pointer result = abi.encodePacked(b.length, e.length, mLen, b, e, m); assembly ("memory-safe") { let dataPtr := add(result, 0x20) // Write result on top of args to avoid allocating extra memory. success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen) // Overwrite the length. // result.length > returndatasize() is guaranteed because returndatasize() == m.length mstore(result, mLen) // Set the memory pointer after the returned data. mstore(0x40, add(dataPtr, mLen)) } } /** * @dev Returns whether the provided byte array is zero. */ function _zeroBytes(bytes memory byteArray) private pure returns (bool) { for (uint256 i = 0; i < byteArray.length; ++i) { if (byteArray[i] != 0) { return false; } } return true; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * This method is based on Newton's method for computing square roots; the algorithm is restricted to only * using integer operations. */ function sqrt(uint256 a) internal pure returns (uint256) { unchecked { // Take care of easy edge cases when a == 0 or a == 1 if (a <= 1) { return a; } // In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a // sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between // the current value as `ε_n = | x_n - sqrt(a) |`. // // For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root // of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is // bigger than any uint256. // // By noticing that // `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)` // we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar // to the msb function. uint256 aa = a; uint256 xn = 1; if (aa >= (1 << 128)) { aa >>= 128; xn <<= 64; } if (aa >= (1 << 64)) { aa >>= 64; xn <<= 32; } if (aa >= (1 << 32)) { aa >>= 32; xn <<= 16; } if (aa >= (1 << 16)) { aa >>= 16; xn <<= 8; } if (aa >= (1 << 8)) { aa >>= 8; xn <<= 4; } if (aa >= (1 << 4)) { aa >>= 4; xn <<= 2; } if (aa >= (1 << 2)) { xn <<= 1; } // We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1). // // We can refine our estimation by noticing that the middle of that interval minimizes the error. // If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2). // This is going to be our x_0 (and ε_0) xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2) // From here, Newton's method give us: // x_{n+1} = (x_n + a / x_n) / 2 // // One should note that: // x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a // = ((x_n² + a) / (2 * x_n))² - a // = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a // = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²) // = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²) // = (x_n² - a)² / (2 * x_n)² // = ((x_n² - a) / (2 * x_n))² // ≥ 0 // Which proves that for all n ≥ 1, sqrt(a) ≤ x_n // // This gives us the proof of quadratic convergence of the sequence: // ε_{n+1} = | x_{n+1} - sqrt(a) | // = | (x_n + a / x_n) / 2 - sqrt(a) | // = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) | // = | (x_n - sqrt(a))² / (2 * x_n) | // = | ε_n² / (2 * x_n) | // = ε_n² / | (2 * x_n) | // // For the first iteration, we have a special case where x_0 is known: // ε_1 = ε_0² / | (2 * x_0) | // ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2))) // ≤ 2**(2*e-4) / (3 * 2**(e-1)) // ≤ 2**(e-3) / 3 // ≤ 2**(e-3-log2(3)) // ≤ 2**(e-4.5) // // For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n: // ε_{n+1} = ε_n² / | (2 * x_n) | // ≤ (2**(e-k))² / (2 * 2**(e-1)) // ≤ 2**(2*e-2*k) / 2**e // ≤ 2**(e-2*k) xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5) -- special case, see above xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9) -- general case with k = 4.5 xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18) -- general case with k = 9 xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36) -- general case with k = 18 xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72) -- general case with k = 36 xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144) -- general case with k = 72 // Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision // ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either // sqrt(a) or sqrt(a) + 1. return xn - SafeCast.toUint(xn > a / xn); } } /** * @dev Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log2(uint256 x) internal pure returns (uint256 r) { // If value has upper 128 bits set, log2 result is at least 128 r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7; // If upper 64 bits of 128-bit half set, add 64 to result r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6; // If upper 32 bits of 64-bit half set, add 32 to result r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5; // If upper 16 bits of 32-bit half set, add 16 to result r |= SafeCast.toUint((x >> r) > 0xffff) << 4; // If upper 8 bits of 16-bit half set, add 8 to result r |= SafeCast.toUint((x >> r) > 0xff) << 3; // If upper 4 bits of 8-bit half set, add 4 to result r |= SafeCast.toUint((x >> r) > 0xf) << 2; // Shifts value right by the current result and use it as an index into this lookup table: // // | x (4 bits) | index | table[index] = MSB position | // |------------|---------|-----------------------------| // | 0000 | 0 | table[0] = 0 | // | 0001 | 1 | table[1] = 0 | // | 0010 | 2 | table[2] = 1 | // | 0011 | 3 | table[3] = 1 | // | 0100 | 4 | table[4] = 2 | // | 0101 | 5 | table[5] = 2 | // | 0110 | 6 | table[6] = 2 | // | 0111 | 7 | table[7] = 2 | // | 1000 | 8 | table[8] = 3 | // | 1001 | 9 | table[9] = 3 | // | 1010 | 10 | table[10] = 3 | // | 1011 | 11 | table[11] = 3 | // | 1100 | 12 | table[12] = 3 | // | 1101 | 13 | table[13] = 3 | // | 1110 | 14 | table[14] = 3 | // | 1111 | 15 | table[15] = 3 | // // The lookup table is represented as a 32-byte value with the MSB positions for 0-15 in the last 16 bytes. assembly ("memory-safe") { r := or(r, byte(shr(r, x), 0x0000010102020202030303030303030300000000000000000000000000000000)) } } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 x) internal pure returns (uint256 r) { // If value has upper 128 bits set, log2 result is at least 128 r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7; // If upper 64 bits of 128-bit half set, add 64 to result r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6; // If upper 32 bits of 64-bit half set, add 32 to result r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5; // If upper 16 bits of 32-bit half set, add 16 to result r |= SafeCast.toUint((x >> r) > 0xffff) << 4; // Add 1 if upper 8 bits of 16-bit half set, and divide accumulated result by 8 return (r >> 3) | SafeCast.toUint((x >> r) > 0xff); } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.20; /** * @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeCast { /** * @dev Value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value); /** * @dev An int value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedIntToUint(int256 value); /** * @dev Value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedIntDowncast(uint8 bits, int256 value); /** * @dev An uint value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedUintToInt(uint256 value); /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits */ function toUint248(uint256 value) internal pure returns (uint248) { if (value > type(uint248).max) { revert SafeCastOverflowedUintDowncast(248, value); } return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits */ function toUint240(uint256 value) internal pure returns (uint240) { if (value > type(uint240).max) { revert SafeCastOverflowedUintDowncast(240, value); } return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits */ function toUint232(uint256 value) internal pure returns (uint232) { if (value > type(uint232).max) { revert SafeCastOverflowedUintDowncast(232, value); } return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits */ function toUint224(uint256 value) internal pure returns (uint224) { if (value > type(uint224).max) { revert SafeCastOverflowedUintDowncast(224, value); } return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits */ function toUint216(uint256 value) internal pure returns (uint216) { if (value > type(uint216).max) { revert SafeCastOverflowedUintDowncast(216, value); } return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits */ function toUint208(uint256 value) internal pure returns (uint208) { if (value > type(uint208).max) { revert SafeCastOverflowedUintDowncast(208, value); } return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits */ function toUint200(uint256 value) internal pure returns (uint200) { if (value > type(uint200).max) { revert SafeCastOverflowedUintDowncast(200, value); } return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits */ function toUint192(uint256 value) internal pure returns (uint192) { if (value > type(uint192).max) { revert SafeCastOverflowedUintDowncast(192, value); } return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits */ function toUint184(uint256 value) internal pure returns (uint184) { if (value > type(uint184).max) { revert SafeCastOverflowedUintDowncast(184, value); } return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits */ function toUint176(uint256 value) internal pure returns (uint176) { if (value > type(uint176).max) { revert SafeCastOverflowedUintDowncast(176, value); } return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits */ function toUint168(uint256 value) internal pure returns (uint168) { if (value > type(uint168).max) { revert SafeCastOverflowedUintDowncast(168, value); } return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits */ function toUint160(uint256 value) internal pure returns (uint160) { if (value > type(uint160).max) { revert SafeCastOverflowedUintDowncast(160, value); } return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits */ function toUint152(uint256 value) internal pure returns (uint152) { if (value > type(uint152).max) { revert SafeCastOverflowedUintDowncast(152, value); } return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits */ function toUint144(uint256 value) internal pure returns (uint144) { if (value > type(uint144).max) { revert SafeCastOverflowedUintDowncast(144, value); } return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits */ function toUint136(uint256 value) internal pure returns (uint136) { if (value > type(uint136).max) { revert SafeCastOverflowedUintDowncast(136, value); } return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { if (value > type(uint128).max) { revert SafeCastOverflowedUintDowncast(128, value); } return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits */ function toUint120(uint256 value) internal pure returns (uint120) { if (value > type(uint120).max) { revert SafeCastOverflowedUintDowncast(120, value); } return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits */ function toUint112(uint256 value) internal pure returns (uint112) { if (value > type(uint112).max) { revert SafeCastOverflowedUintDowncast(112, value); } return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits */ function toUint104(uint256 value) internal pure returns (uint104) { if (value > type(uint104).max) { revert SafeCastOverflowedUintDowncast(104, value); } return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits */ function toUint96(uint256 value) internal pure returns (uint96) { if (value > type(uint96).max) { revert SafeCastOverflowedUintDowncast(96, value); } return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits */ function toUint88(uint256 value) internal pure returns (uint88) { if (value > type(uint88).max) { revert SafeCastOverflowedUintDowncast(88, value); } return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits */ function toUint80(uint256 value) internal pure returns (uint80) { if (value > type(uint80).max) { revert SafeCastOverflowedUintDowncast(80, value); } return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits */ function toUint72(uint256 value) internal pure returns (uint72) { if (value > type(uint72).max) { revert SafeCastOverflowedUintDowncast(72, value); } return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { if (value > type(uint64).max) { revert SafeCastOverflowedUintDowncast(64, value); } return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits */ function toUint56(uint256 value) internal pure returns (uint56) { if (value > type(uint56).max) { revert SafeCastOverflowedUintDowncast(56, value); } return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits */ function toUint48(uint256 value) internal pure returns (uint48) { if (value > type(uint48).max) { revert SafeCastOverflowedUintDowncast(48, value); } return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits */ function toUint40(uint256 value) internal pure returns (uint40) { if (value > type(uint40).max) { revert SafeCastOverflowedUintDowncast(40, value); } return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { if (value > type(uint32).max) { revert SafeCastOverflowedUintDowncast(32, value); } return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits */ function toUint24(uint256 value) internal pure returns (uint24) { if (value > type(uint24).max) { revert SafeCastOverflowedUintDowncast(24, value); } return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { if (value > type(uint16).max) { revert SafeCastOverflowedUintDowncast(16, value); } return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits */ function toUint8(uint256 value) internal pure returns (uint8) { if (value > type(uint8).max) { revert SafeCastOverflowedUintDowncast(8, value); } return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { if (value < 0) { revert SafeCastOverflowedIntToUint(value); } return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(248, value); } } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(240, value); } } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(232, value); } } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(224, value); } } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(216, value); } } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(208, value); } } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(200, value); } } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(192, value); } } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(184, value); } } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(176, value); } } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(168, value); } } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(160, value); } } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(152, value); } } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(144, value); } } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(136, value); } } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(128, value); } } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(120, value); } } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(112, value); } } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(104, value); } } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(96, value); } } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(88, value); } } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(80, value); } } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(72, value); } } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(64, value); } } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(56, value); } } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(48, value); } } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(40, value); } } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(32, value); } } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(24, value); } } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(16, value); } } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(8, value); } } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive if (value > uint256(type(int256).max)) { revert SafeCastOverflowedUintToInt(value); } return int256(value); } /** * @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump. */ function toUint(bool b) internal pure returns (uint256 u) { assembly ("memory-safe") { u := iszero(iszero(b)) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.20; import {SafeCast} from "./SafeCast.sol"; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant. * * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone. * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute * one branch when needed, making this function more expensive. */ function ternary(bool condition, int256 a, int256 b) internal pure returns (int256) { unchecked { // branchless ternary works because: // b ^ (a ^ b) == a // b ^ 0 == b return b ^ ((a ^ b) * int256(SafeCast.toUint(condition))); } } /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return ternary(a > b, a, b); } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return ternary(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 { // Formula from the "Bit Twiddling Hacks" by Sean Eron Anderson. // Since `n` is a signed integer, the generated bytecode will use the SAR opcode to perform the right shift, // taking advantage of the most significant (or "sign" bit) in two's complement representation. // This opcode adds new most significant bits set to the value of the previous most significant bit. As a result, // the mask will either be `bytes32(0)` (if n is positive) or `~bytes32(0)` (if n is negative). int256 mask = n >> 255; // A `bytes32(0)` mask leaves the input unchanged, while a `~bytes32(0)` mask complements it. return uint256((n + mask) ^ mask); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol) pragma solidity ^0.8.20; /** * @dev Helper library for emitting standardized panic codes. * * ```solidity * contract Example { * using Panic for uint256; * * // Use any of the declared internal constants * function foo() { Panic.GENERIC.panic(); } * * // Alternatively * function foo() { Panic.panic(Panic.GENERIC); } * } * ``` * * Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil]. * * _Available since v5.1._ */ // slither-disable-next-line unused-state library Panic { /// @dev generic / unspecified error uint256 internal constant GENERIC = 0x00; /// @dev used by the assert() builtin uint256 internal constant ASSERT = 0x01; /// @dev arithmetic underflow or overflow uint256 internal constant UNDER_OVERFLOW = 0x11; /// @dev division or modulo by zero uint256 internal constant DIVISION_BY_ZERO = 0x12; /// @dev enum conversion error uint256 internal constant ENUM_CONVERSION_ERROR = 0x21; /// @dev invalid encoding in storage uint256 internal constant STORAGE_ENCODING_ERROR = 0x22; /// @dev empty array pop uint256 internal constant EMPTY_ARRAY_POP = 0x31; /// @dev array out of bounds access uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32; /// @dev resource error (too large allocation or too large array) uint256 internal constant RESOURCE_ERROR = 0x41; /// @dev calling invalid internal function uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51; /// @dev Reverts with a panic code. Recommended to use with /// the internal constants with predefined codes. function panic(uint256 code) internal pure { assembly ("memory-safe") { mstore(0x00, 0x4e487b71) mstore(0x20, code) revert(0x1c, 0x24) } } }
{ "remappings": [ "forge-std/=lib/forge-std/src/", "openzeppelin-contracts/=lib/openzeppelin-contracts/", "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/", "halmos-cheatcodes/=lib/halmos-cheatcodes/src/" ], "optimizer": { "enabled": true, "runs": 999999 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "paris", "viaIR": true, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"strikeAmount","type":"uint256"},{"internalType":"uint256","name":"notionalUnderlyingAmount","type":"uint256"},{"internalType":"uint256","name":"notionalUSDAmount","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"timelock","type":"uint256"}],"name":"render","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"notionalUnderlyingAmount","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"renderSvg","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"}]
Contract Creation Code
6080806040523461001657612cd7908161001c8239f35b600080fdfe6080604052600436101561001257600080fd5b60003560e01c8063053d3fc0146100665763354267d61461003257600080fd5b346100615761005d61005161004636610085565b5050509190506101de565b604051918291826100ec565b0390f35b600080fd5b346100615761005d61005161007a36610085565b50509291909161283e565b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc60c091011261006157600435906024359060443590606435906084359060a43590565b60005b8381106100dc5750506000910152565b81810151838201526020016100cc565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f6040936020845261012f81518092816020880152602088880191016100c9565b0116010190565b6040810190811067ffffffffffffffff82111761015257604052565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6020810190811067ffffffffffffffff82111761015257604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff82111761015257604052565b61181e7f6577426f783d223020302032393020353030222066696c6c3d226e6f6e652220926102186102126125d794612663565b9161280a565b907f3c2f7376673e00000000000000000000000000000000000000000000000000006040928351602091828201947f3c7465787420746578742d72656e646572696e673d226f7074696d697a65537086527f656564223e000000000000000000000000000000000000000000000000000000878401527f3c74657874506174682073746172744f66667365743d222d313030252220666960458401527f6c6c3d22626c61636b2220666f6e742d66616d696c793d226d6f6e6f7370616360658401527f652220666f6e742d73697a653d22313070782220786c696e6b3a687265663d2260858401527f23746578742d706174682d61223e00000000000000000000000000000000000060a58401526107f7608b8461038360b382016027907f50726573616c65205354524154206c6f636b656420757020666f722034206d6f81527f6e7468732e2e2e0000000000000000000000000000000000000000000000000060208201520190565b7f203c616e696d6174652061646469746976653d2273756d222061747472696275908181528b61079260f18b7f6f3d22313030252220626567696e3d22307322206475723d22333073220000007f74654e616d653d2273746172744f6666736574222066726f6d3d223025222074948583880152856106798561053760f07f6f3d22313030252220626567696e3d22307322206475723d22333073222072659b8c878201527f70656174436f756e743d22696e646566696e69746522202f3e0000000000000060608201527f3c2f74657874506174683e203c74657874506174682073746172744f6666736560798201527f743d223025222066696c6c3d22626c61636b2220666f6e742d66616d696c793d60998201527f226d6f6e6f73706163652220666f6e742d73697a653d22313070782220786c6960b98201527f6e6b3a687265663d2223746578742d706174682d61223e00000000000000000060d9820152016027907f50726573616c65205354524154206c6f636b656420757020666f722034206d6f81527f6e7468732e2e2e0000000000000000000000000000000000000000000000000060208201520190565b8b815283878201528a858201527f70656174436f756e743d22696e646566696e69746522202f3e203c2f7465787460608201527f506174683e00000000000000000000000000000000000000000000000000000060808201527f3c74657874506174682073746172744f66667365743d22353025222066696c6c60858201527f3d22626c61636b2220666f6e742d66616d696c793d226d6f6e6f73706163652260a58201527f20666f6e742d73697a653d22313070782220786c696e6b3a687265663d22237460c58201527f6578742d706174682d61223e000000000000000000000000000000000000000060e5820152016024907f2e2e2e7468656e207665737473206c696e6561726c79206f7665722032206d6f81527f6e7468730000000000000000000000000000000000000000000000000000000060208201520190565b938985528401528201527f20726570656174436f756e743d22696e646566696e69746522202f3e3c2f7465605d8201527f7874506174683e3c74657874506174682073746172744f66667365743d222d35607d8201527f3025222066696c6c3d22626c61636b2220666f6e742d66616d696c793d226d6f609d8201527f6e6f73706163652220666f6e742d73697a653d22313070782220786c696e6b3a60bd8201527f687265663d2223746578742d706174682d61223e00000000000000000000000060dd820152016024907f2e2e2e7468656e207665737473206c696e6561726c79206f7665722032206d6f81527f6e7468730000000000000000000000000000000000000000000000000000000060208201520190565b928352898301528b8201527f70656174436f756e743d22696e646566696e69746522202f3e3c2f746578745060608201527f6174683e3c2f746578743e000000000000000000000000000000000000000000608082015203606b81018652018461019d565b8651998a977f3c7376672077696474683d2232393022206865696768743d2235303022207669868a01528801527f786d6c6e733d22687474703a2f2f7777772e77332e6f72672f323030302f737660608801527f672220786d6c6e733a786c696e6b3d22687474703a2f2f7777772e77332e6f7260808801527f672f313939392f786c696e6b223e00000000000000000000000000000000000060a08801527f3c646566733e3c706174682069643d22746578742d706174682d612220643d2260ae8801527f4d3430203132204832353020413238203238203020302031203237382034302060ce8801527f563436302041323820323820302030203120323530203438382048343020413260ee8801527f382032382030203020312031322034363020563430204132382032382030203061010e8801527f2031203430203132207a22202f3e3c2f646566733e000000000000000000000061012e8801527f3c7265637420783d22302220793d2230222077696474683d22323930222068656101438801527f696768743d22353030222072783d223432222066696c6c3d22234533453646396101638801527f22207374726f6b653d2223463446354639222f3e0000000000000000000000006101838801527f3c7265637420783d2231362220793d223136222077696474683d2232353822206101978801527f6865696768743d22343638222072783d223236222072793d22323622207374726101b78801527f6f6b653d2223443544414546222f3e00000000000000000000000000000000006101d78801527f3c706174682066696c6c3d22233030302220643d224d36352e352033346131396101e68801527f2e352031392e352030203120312d362e34342033372e39316c312e35352d312e6102068801527f35356131372e35362031372e35362030203120302d31312e342d31302e33336c6102268801527f2d312e3520312e34394131392e352031392e352030203020312036352e3520336102468801527f344d35342e332036372e303261313820313820302030203020342e323820322e6102668801527f36316c2d312e343720312e34386132302032302030203020312d342e31392d326102868801527f2e377a4d35302e312036312e3961313820313820302030203020322e373820336102a68801527f2e37396c2d312e333720312e33386132302032302030203020312d322e38342d6102c68801527f332e37337a222f3e0000000000000000000000000000000000000000000000006102e68801527f3c706174682066696c6c3d22233030302220643d224d37322e31342035382e38806102ee8901527f342036302e362037302e3336712d312e30342d2e332d322e30332d2e37336c318061030e8a01527f322e31382d31322e31377a6d2d332e32322d362e34344c35342e332036372e308061032e8b01527f32712d2e37352d2e36332d312e34342d312e33336c31342e36372d31342e3637918261034e8c01527f7a6d2d332e30322d362e334c35302e30392036312e39712d2e352d2e392d2e38938461036e8d01527f382d312e38376c31352e332d31352e33317a222f3e000000000000000000000061038e8d01527f3c7061746820643d224d313435203230312038342032323920313435203132376103a38d01527f7a222066696c6c3d2223463145324539222f3e000000000000000000000000006103c38d01527f3c7061746820643d224d31343520323031203834203232396c36312033367a226103d68d01527f2066696c6c3d2223463641444334222f3e0000000000000000000000000000006103f68d01527f3c7061746820643d226d313435203230312036312032384c313435203132377a6104078d01527f222066696c6c3d2223464641414333222f3e00000000000000000000000000006104278d01527f3c7061746820643d226d313435203230312036312032382d36312033367a22206104398d01527f66696c6c3d2223463738414138222f3e000000000000000000000000000000006104598d01527f3c7061746820643d226d3834203234302e352036312038362e35762d34357a226104698d01527f2066696c6c3d2223463443314431222f3e0000000000000000000000000000006104898d01527f3c7061746820643d224d323037203234302e352031343520333237762d34357a61049a8d01527f222066696c6c3d2223464541344241222f3e00000000000000000000000000006104ba8d01527f3c7061746820643d224d31343520323737203834203234302e356c36312034326104cc8d01527f2036312d34327a222066696c6c3d2223464543414446222f3e000000000000006104ec8d01527f3c706174682066696c6c3d22233030302220643d224d39342e383220393656386105058d01527f342e3868342e3271312e3432203020322e34342e343620312e30332e343520316105258d01527f2e353720312e33322e35372e38342e353620322e3036203020312e31382d2e356105458d01527f3620322e30352d2e35342e38342d312e353720312e33312d312e30332e34352d6105658d01527f322e34342e3436682d332e35346c2e35332d2e35365639367a6d312e31392d346105858d01527f2d2e35332d2e353868332e3571312e3638203020322e35352d2e37322e38372d6105a58d01527f2e37332e38382d322e303620302d312e33352d2e38382d322e30382d2e38372d6105c58d01527f2e37352d322e35352d2e3734682d332e356c2e35332d2e35367a6d31302e39346105e58d01527f20345638342e3868342e3271312e3432203020322e34342e343620312e30332e6106058d01527f343520312e353720312e33322e35362e38342e353620322e3036203020312e316106258d01527f382d2e353620322e30352d2e35342e38342d312e353720312e33312d312e30326106458d01527f2e34352d322e34352e3435682d332e35336c2e35332d2e35355639367a6d372e6106658d01527f363520302d322e38382d342e3036483131336c322e3920342e30367a6d2d362e6106858d01527f34362d342d2e35332d2e353668332e3571312e3638203020322e35352d2e37346106a58d01527f2e38382d2e37332e38382d322e303620302d312e33352d2e38382d322e30382d6106c58d01527f2e38372d2e37352d322e35352d2e3734682d332e356c2e35332d2e35367a6d316106e58d01527f322e32332d322e3268352e393276312e3032682d352e39327a6d2e313320352e6107058d01527f313868362e3734563936682d372e39325638342e384831323776312e3032682d6107258d01527f362e357a6d31332e3420312e3132712d312e323520302d322e342d2e346135206107458d01527f352030203020312d312e37352d312e30366c2e34362d2e3931712e362e3537206107658d01527f312e35382e39376136203620302030203020332e38332e3133712e36372d2e326107858d01527f372e39372d2e37322e33322d2e34352e33322d2e393920302d2e36362d2e33386107a58d01527f2d312e303661322e3520322e352030203020302d2e39382d2e3632712d2e362d6107c58d01527f2e32342d312e33342d2e3432742d312e34372d2e3336613720372030203020316107e58d01527f2d312e33362d2e3535712d2e362d2e33342d312d2e383861322e3620322e36206108058d01527f30203020312d2e33362d312e343520322e3820322e3820302030203120312e376108258d01527f392d322e3634712e392d2e343420322e33342d2e343461362e3620362e3620306108458d01527f2030203120332e343720316c2d2e342e3934712d2e37322d2e34382d312e35346108658d01527f2d2e37613620362030203020302d312e35352d2e3233712d312e303120302d316108858d01527f2e36362e32372d2e36362e32382d2e39382e37342d2e332e34352d2e3320312e6108a58d01527f30322030202e36362e333620312e30362e33392e342031202e36322e36312e326108c58d01527f3320312e33362e342e37332e313820312e34352e33392e37342e323120312e336108e58d01527f352e35342e36312e33322e39392e38372e33382e35342e333820312e343220306109058d01527f202e38312d2e343520312e35322d2e34352e36392d312e333720312e31322d2e6109258d01527f39322e34322d322e33352e34326d352e37372d2e3120352e31322d31312e32686109458d01527f312e31376c352e31322031312e32682d312e32356c2d342e372d31302e3531686109658d01527f2e34384c3134302e392039367a6d322e30322d33202e33352d2e393568362e356109858d01527f316c2e33352e39367a6d31342e30362033762d342e31366c2e32372e37342d346109a58d01527f2e37352d372e373868312e32366c342e313820362e3833682d2e36386c342e316109c58d01527f382d362e383368312e31386c2d342e373520372e37382e32372d2e37345639366109e58d01527f7a6d382e303520305638342e3868312e31387631302e313868362e3237563936610a058d01527f7a6d31342e392e31712d312e323720302d322e33362d2e343261362036203020610a258d01527f3020312d312e38372d312e32203620362030203020312d312e32332d312e3820610a458d01527f3620362030203020312d2e34332d322e323871302d312e32332e34332d322e32610a658d01527f3661352e3620352e3620302030203120332e312d3371312e30382d2e34342032610a858d01527f2e33352d2e343474322e33342e343461352e3420352e3420302030203120332e610aa58d01527f303920322e3939712e343520312e30352e343520322e323761352e3720352e37610ac58d01527f2030203020312d312e363820342e3038712d2e37392e37372d312e383620312e610ae58d01527f32613620362030203020312d322e33342e34326d302d312e3036613520352030610b058d01527f2030203020312e38352d2e333420342e3520342e3520302030203020322e3438610b258d01527f2d322e3434712e33362d2e38352e33352d312e383661342e3720342e37203020610b458d01527f3020302d312e33342d332e333120342e3820342e382030203020302d332e3334610b658d01527f2d312e3333203520352030203020302d332e333820312e3333712d2e36332e36610b858d01527f312d3120312e3437613520352030203020302d2e333420312e383420342e3820610ba58d01527f342e3820302030203020312e333420332e333320342e3620342e362030203020610bc58d01527f3020332e333820312e33316d392e33322e39365638342e3868342e3271312e34610be58d01527f31203020322e34342e343620312e30322e343520312e353720312e33322e3536610c058d01527f2e38342e353620322e3036203020312e31382d2e353620322e30352d2e35352e610c258d01527f38342d312e353720312e33312d312e30322e34352d322e34352e3435682d332e610c458d01527f35336c2e35332d2e35355639367a6d372e363520302d322e38382d342e303668610c658d01527f312e32386c322e3920342e30367a6d2d362e34362d342d2e35332d2e35366833610c858d01527f2e3571312e3638203020322e35342d2e37342e38392d2e37332e38382d322e30610ca58d01527f3620302d312e33352d2e38372d322e30382d2e38372d2e37352d322e35352d2e610cc58d01527f3734682d332e356c2e35332d2e35367a4d36352e352033346131392e35203139610ce58d01527f2e352030203120312d362e34342033372e39316c312e35352d312e3535613137610d058d01527f2e35362031372e35362030203120302d31312e342d31302e33336c2d312e3520610d258d01527f312e34394131392e352031392e352030203020312036352e352033344d35342e610d458d01527f332036372e303261313820313820302030203020342e323820322e36316c2d31610d658d01527f2e343720312e34386132302032302030203020312d342e31392d322e377a4d35610d858d01527f302e312036312e3961313820313820302030203020322e373820332e37396c2d610da58d01527f312e333720312e33386132302032302030203020312d322e38342d332e37337a610dc58d01527f222f3e0000000000000000000000000000000000000000000000000000000000610de58d0152610de88c0152610e088b0152610e288a0152610e48890152610e688801527f382d312e38376c31352e332d31352e33317a4d3130302e382036342e3432712d610e888801527f322e313520302d342e31312d2e3638613820382030203020312d332e30312d31610ea88801527f2e38316c2e382d312e35366138203820302030203020322e3720312e36377131610ec88801527f2e37332e363620332e36322e36356138203820302030203020322e39332d2e34610ee88801527f3320332e3620332e3620302030203020312e36372d312e3234712e35352d2e37610f088801527f352e35352d312e3761322e3520322e352030203020302d2e36362d312e382034610f288801527f20342030203020302d312e36372d312e3037712d312e30352d2e342d322e332d610f488801527f2e37316c2d322e35322d2e3633712d312e32362d2e33362d322e33332d2e3933610f688801527f613520352030203020312d312e372d312e3520342e3520342e35203020302031610f888801527f2d2e36332d322e3571302d312e34332e37342d322e3661352e3220352e322030610fa88801527f2030203120322e33332d312e39322039203920302030203120342d2e37342031610fc88801527f312e332031312e3320302030203120352e393420312e376c2d2e363820312e36610fe88801527f3161392e383320392e38332030203020302d352e32392d312e353920382038206110088801527f30203020302d322e38352e3437712d312e31312e34362d312e363720312e32366110288801527f2d2e35322e37372d2e353220312e3735203020312e31322e363320312e38312e6110488801527f36362e363920312e3720312e303720312e30372e333820322e33332e363874326110688801527f2e352e363671312e32352e333620322e332e393320312e30362e353520312e366110888801527f3920312e34382e36362e39332e363620322e3434203020312e342d2e373720326110a88801527f2e3661352e3520352e352030203020312d322e333620312e39322031302031306110c88801527f2030203020312d342e30322e37316d31362e342d2e31365634362e3834682d366110e88801527f2e3735762d312e37366831352e3576312e3736682d362e37337631372e34327a6111088801527f6d31332e333620305634352e303868372e313871322e3433203020342e31392e6111288801527f386136203620302030203120322e363820322e3234712e393620312e34352e396111488801527f3620332e353461362e3320362e332030203020312d2e393620332e35203620366111688801527f2030203020312d322e363820322e3235712d312e37352e37372d342e322e37376111888801527f682d362e30346c2e392d2e393476372e30327a6d31332e3120302d342e39342d6111a88801527f362e393668322e326c342e393520362e39367a6d2d31312e30372d362e38352d6111c88801527f2e392d2e3936683671322e3837203020342e33352d312e323620312e352d312e6111e88801527f323620312e352d332e353320302d322e332d312e352d332e35362d312e34382d6112088801527f312e32362d342e33362d312e3236682d366c2e39312d2e39367a6d31362e30376112288801527f20362e383520382e37362d31392e313868326c382e37372031392e3138682d326112488801527f2e31346c2d382e30352d3138682e38326c2d382e30352031387a6d332e34352d6112688801527f352e31332e362d312e36346831312e31356c2e3620312e36347a6d32332e33386112888801527f20352e31335634362e3834682d362e3734762d312e37366831352e3576312e376112a88801527f36682d362e37337631372e34327a6d34302e32342e3136712d322e313820302d6112c88801527f342e30352d2e37316131302031302030203020312d332e322d322e3036712d316112e88801527f2e33352d312e332d322e31312d332e312d2e37352d312e37372d2e37342d332e6113088801527f383820302d322e312e37342d332e383961392e3420392e3420302030203120356113288801527f2e33342d352e313271312e38362d2e373520342e30352d2e373420322e3220306113488801527f2034202e36386138203820302030203120332e313220322e30396c2d312e32366113688801527f20312e3238613720372030203020302d322e36362d312e3732712d312e34342d6113888801527f2e35322d332e31322d2e35322d312e373820302d332e32382e3661372e3720376113a88801527f2e372030203020302d342e393420372e3334713020312e372e3620332e31352e6113c88801527f363420312e343520312e373320322e35356138203820302030203020322e36206113e88801527f312e363771312e35322e353720332e32362e353720312e3635203020332e312d6114088801527f2e356137203720302030203020322e37312d312e36366c312e313520312e35336114288801527f613920392030203020312d332e3220312e3834712d312e38342e362d332e38346114488801527f2e366d352e312d322e3638762d372e303768312e393476372e33317a6d31332e6114688801527f363220322e3532762d372e31336c2e343720312e32362d382e31342d31332e336114888801527f68322e31376c372e31352031312e3639682d312e31366c372e31352d31312e376114a88801527f68322e30336c2d382e31332031332e33312e34362d312e323676372e31337a4d6114c88801527f3138382e382036322e3576312e37366831342e31356c2d312e31382d312e37366114e88801527f7a4d3138382e382035332e373476312e37356831312e3934762d312e37357a4d6115088801527f3138382e382034352e303876312e37366831322e39376c312e31362d312e37366115288801527f7a222f3e000000000000000000000000000000000000000000000000000000006115488801527f3c7465787420783d2233302220793d22333730222066696c6c3d22626c61636b61154c8801527f2220666f6e742d66616d696c793d2273616e732d73657269662220666f6e742d918261156c8901527f73697a653d22313470782220666f6e742d7765696768743d22333030223e546f61158c8901527f6b656e2049443c2f746578743e000000000000000000000000000000000000006115ac8901527f3c7465787420783d2233302220793d22333930222066696c6c3d22626c61636b6115b9890152826115d98901527f73697a653d22313670782220666f6e742d7765696768743d22353030223e00006115f98901528151612331816116179488868d0191016100c9565b88017f3c2f746578743e0000000000000000000000000000000000000000000000000080938201527f3c7465787420783d223236302220793d223337302220746578742d616e63686f61161e8201527f723d22656e64222066696c6c3d22626c61636b2220666f6e742d66616d696c798061163e8301527f3d2273616e732d73657269662220666f6e742d73697a653d223134707822206661165e8301527f6f6e742d7765696768743d22333030223e53545241542050757263686173656461167e8301528361169e8301527f3c7465787420783d223236302220793d223339302220746578742d616e63686f6116a58301526116c58201527f3d2273616e732d73657269662220666f6e742d73697a653d22313670782220666116e58201527f6f6e742d7765696768743d22353030223e00000000000000000000000000000061170582015261248d825180936117169889850191016100c9565b01938401527f3c7465787420783d2233302220793d22343230222066696c6c3d22626c61636b61171d8401528061173d8401527f73697a653d22313470782220666f6e742d7765696768743d22333030223e566561175d8401527f7374696e67205465726d733c2f746578743e000000000000000000000000000061177d8401527f3c7465787420783d2233302220793d22343430222066696c6c3d22626c61636b61178f8401526117af8301527f73697a653d22313270782220666f6e742d7765696768743d22353030223e53546117cf8301527f52415420766573747320666f722036206d6f6e74687320706f73742d6c61756e6117ef8301527f63683c2f746578743e000000000000000000000000000000000000000000000061180f83015251906125c38261181895868401906100c9565b0191820152036117fe81018452018261019d565b90565b67ffffffffffffffff811161015257601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b9061261e826125da565b61262b604051918261019d565b8281527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe061265982946125da565b0190602036910137565b806000917a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000808210156127c3575b506d04ee2d6d415b85acef8100000000808310156127b4575b50662386f26fc10000808310156127a5575b506305f5e10080831015612796575b5061271080831015612787575b506064821015612777575b600a8092101561276d575b6001908160216126fa828701612614565b95860101905b61270c575b5050505090565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019083907f30313233343536373839616263646566000000000000000000000000000000008282061a83530491821561276857919082612700565b612705565b91600101916126e9565b91906064600291049101916126de565b600491939204910191386126d3565b600891939204910191386126c6565b601091939204910191386126b7565b602091939204910191386126a5565b60409350810491503861268c565b604051906127de82610136565b600182527f30000000000000000000000000000000000000000000000000000000000000006020830152565b801561283557601261281b82612663565b51111561283557670de0b6b3a76400006125d79104612663565b506125d76127d1565b9290159081612b14575b5015612aff57612857916101de565b6040908151906060820182811067ffffffffffffffff8211176101525783528282526020918281017f4142434445464748494a4b4c4d4e4f505152535455565758595a61626364656690528381017f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f90526128d191612b1d565b825192828401907f226e616d65223a202200000000000000000000000000000000000000000000008252602985017f4554482053747261746567792050726573616c6500000000000000000000000090527f222c0000000000000000000000000000000000000000000000000000000000009182603d870152601f865261295786610136565b815190858201927f2273796d626f6c223a20220000000000000000000000000000000000000000008452602b83017f6f535452415400000000000000000000000000000000000000000000000000009052846031840152601383526129bb83610136565b80518095888201977f22696d616765223a2022000000000000000000000000000000000000000000008952602a83017f646174613a696d6167652f7376672b786d6c3b6261736536342c0000000000009052805190818b60448601920191612a22926100c9565b820190604482015203602681018652604601612a3e908661019d565b5196879687017f7b00000000000000000000000000000000000000000000000000000000000000905251908160218801612a77926100c9565b85019051918260218301612a8a926100c9565b019051918260218301612a9c926100c9565b01602181017f2261747472696275746573223a205b5d000000000000000000000000000000009052603181017f7d000000000000000000000000000000000000000000000000000000000000009052036012810182526032016125d7908261019d565b5050604051612b0d81610181565b6000815290565b90501538612848565b805115612aff578051600291828201809211612c725760038092047f3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81168103612c7257612b6e908495941b612614565b936020850193829183518401906020820192835194600085525b838110612c21575050505052510680600114612bd257600214612ba9575090565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff603d91015390565b507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe81603d7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81940153015390565b87600491999293949901918251600190603f9082828260121c16880101518453828282600c1c16880101518385015382828260061c1688010151888501531685010151898201530197929190612b88565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fdfea2646970667358221220934046c62ff8416d9982fd80ed9c10f46b0119047f62b93732ea9b7d190d413b64736f6c63430008140033
Deployed Bytecode
0x6080604052600436101561001257600080fd5b60003560e01c8063053d3fc0146100665763354267d61461003257600080fd5b346100615761005d61005161004636610085565b5050509190506101de565b604051918291826100ec565b0390f35b600080fd5b346100615761005d61005161007a36610085565b50509291909161283e565b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc60c091011261006157600435906024359060443590606435906084359060a43590565b60005b8381106100dc5750506000910152565b81810151838201526020016100cc565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f6040936020845261012f81518092816020880152602088880191016100c9565b0116010190565b6040810190811067ffffffffffffffff82111761015257604052565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6020810190811067ffffffffffffffff82111761015257604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff82111761015257604052565b61181e7f6577426f783d223020302032393020353030222066696c6c3d226e6f6e652220926102186102126125d794612663565b9161280a565b907f3c2f7376673e00000000000000000000000000000000000000000000000000006040928351602091828201947f3c7465787420746578742d72656e646572696e673d226f7074696d697a65537086527f656564223e000000000000000000000000000000000000000000000000000000878401527f3c74657874506174682073746172744f66667365743d222d313030252220666960458401527f6c6c3d22626c61636b2220666f6e742d66616d696c793d226d6f6e6f7370616360658401527f652220666f6e742d73697a653d22313070782220786c696e6b3a687265663d2260858401527f23746578742d706174682d61223e00000000000000000000000000000000000060a58401526107f7608b8461038360b382016027907f50726573616c65205354524154206c6f636b656420757020666f722034206d6f81527f6e7468732e2e2e0000000000000000000000000000000000000000000000000060208201520190565b7f203c616e696d6174652061646469746976653d2273756d222061747472696275908181528b61079260f18b7f6f3d22313030252220626567696e3d22307322206475723d22333073220000007f74654e616d653d2273746172744f6666736574222066726f6d3d223025222074948583880152856106798561053760f07f6f3d22313030252220626567696e3d22307322206475723d22333073222072659b8c878201527f70656174436f756e743d22696e646566696e69746522202f3e0000000000000060608201527f3c2f74657874506174683e203c74657874506174682073746172744f6666736560798201527f743d223025222066696c6c3d22626c61636b2220666f6e742d66616d696c793d60998201527f226d6f6e6f73706163652220666f6e742d73697a653d22313070782220786c6960b98201527f6e6b3a687265663d2223746578742d706174682d61223e00000000000000000060d9820152016027907f50726573616c65205354524154206c6f636b656420757020666f722034206d6f81527f6e7468732e2e2e0000000000000000000000000000000000000000000000000060208201520190565b8b815283878201528a858201527f70656174436f756e743d22696e646566696e69746522202f3e203c2f7465787460608201527f506174683e00000000000000000000000000000000000000000000000000000060808201527f3c74657874506174682073746172744f66667365743d22353025222066696c6c60858201527f3d22626c61636b2220666f6e742d66616d696c793d226d6f6e6f73706163652260a58201527f20666f6e742d73697a653d22313070782220786c696e6b3a687265663d22237460c58201527f6578742d706174682d61223e000000000000000000000000000000000000000060e5820152016024907f2e2e2e7468656e207665737473206c696e6561726c79206f7665722032206d6f81527f6e7468730000000000000000000000000000000000000000000000000000000060208201520190565b938985528401528201527f20726570656174436f756e743d22696e646566696e69746522202f3e3c2f7465605d8201527f7874506174683e3c74657874506174682073746172744f66667365743d222d35607d8201527f3025222066696c6c3d22626c61636b2220666f6e742d66616d696c793d226d6f609d8201527f6e6f73706163652220666f6e742d73697a653d22313070782220786c696e6b3a60bd8201527f687265663d2223746578742d706174682d61223e00000000000000000000000060dd820152016024907f2e2e2e7468656e207665737473206c696e6561726c79206f7665722032206d6f81527f6e7468730000000000000000000000000000000000000000000000000000000060208201520190565b928352898301528b8201527f70656174436f756e743d22696e646566696e69746522202f3e3c2f746578745060608201527f6174683e3c2f746578743e000000000000000000000000000000000000000000608082015203606b81018652018461019d565b8651998a977f3c7376672077696474683d2232393022206865696768743d2235303022207669868a01528801527f786d6c6e733d22687474703a2f2f7777772e77332e6f72672f323030302f737660608801527f672220786d6c6e733a786c696e6b3d22687474703a2f2f7777772e77332e6f7260808801527f672f313939392f786c696e6b223e00000000000000000000000000000000000060a08801527f3c646566733e3c706174682069643d22746578742d706174682d612220643d2260ae8801527f4d3430203132204832353020413238203238203020302031203237382034302060ce8801527f563436302041323820323820302030203120323530203438382048343020413260ee8801527f382032382030203020312031322034363020563430204132382032382030203061010e8801527f2031203430203132207a22202f3e3c2f646566733e000000000000000000000061012e8801527f3c7265637420783d22302220793d2230222077696474683d22323930222068656101438801527f696768743d22353030222072783d223432222066696c6c3d22234533453646396101638801527f22207374726f6b653d2223463446354639222f3e0000000000000000000000006101838801527f3c7265637420783d2231362220793d223136222077696474683d2232353822206101978801527f6865696768743d22343638222072783d223236222072793d22323622207374726101b78801527f6f6b653d2223443544414546222f3e00000000000000000000000000000000006101d78801527f3c706174682066696c6c3d22233030302220643d224d36352e352033346131396101e68801527f2e352031392e352030203120312d362e34342033372e39316c312e35352d312e6102068801527f35356131372e35362031372e35362030203120302d31312e342d31302e33336c6102268801527f2d312e3520312e34394131392e352031392e352030203020312036352e3520336102468801527f344d35342e332036372e303261313820313820302030203020342e323820322e6102668801527f36316c2d312e343720312e34386132302032302030203020312d342e31392d326102868801527f2e377a4d35302e312036312e3961313820313820302030203020322e373820336102a68801527f2e37396c2d312e333720312e33386132302032302030203020312d322e38342d6102c68801527f332e37337a222f3e0000000000000000000000000000000000000000000000006102e68801527f3c706174682066696c6c3d22233030302220643d224d37322e31342035382e38806102ee8901527f342036302e362037302e3336712d312e30342d2e332d322e30332d2e37336c318061030e8a01527f322e31382d31322e31377a6d2d332e32322d362e34344c35342e332036372e308061032e8b01527f32712d2e37352d2e36332d312e34342d312e33336c31342e36372d31342e3637918261034e8c01527f7a6d2d332e30322d362e334c35302e30392036312e39712d2e352d2e392d2e38938461036e8d01527f382d312e38376c31352e332d31352e33317a222f3e000000000000000000000061038e8d01527f3c7061746820643d224d313435203230312038342032323920313435203132376103a38d01527f7a222066696c6c3d2223463145324539222f3e000000000000000000000000006103c38d01527f3c7061746820643d224d31343520323031203834203232396c36312033367a226103d68d01527f2066696c6c3d2223463641444334222f3e0000000000000000000000000000006103f68d01527f3c7061746820643d226d313435203230312036312032384c313435203132377a6104078d01527f222066696c6c3d2223464641414333222f3e00000000000000000000000000006104278d01527f3c7061746820643d226d313435203230312036312032382d36312033367a22206104398d01527f66696c6c3d2223463738414138222f3e000000000000000000000000000000006104598d01527f3c7061746820643d226d3834203234302e352036312038362e35762d34357a226104698d01527f2066696c6c3d2223463443314431222f3e0000000000000000000000000000006104898d01527f3c7061746820643d224d323037203234302e352031343520333237762d34357a61049a8d01527f222066696c6c3d2223464541344241222f3e00000000000000000000000000006104ba8d01527f3c7061746820643d224d31343520323737203834203234302e356c36312034326104cc8d01527f2036312d34327a222066696c6c3d2223464543414446222f3e000000000000006104ec8d01527f3c706174682066696c6c3d22233030302220643d224d39342e383220393656386105058d01527f342e3868342e3271312e3432203020322e34342e343620312e30332e343520316105258d01527f2e353720312e33322e35372e38342e353620322e3036203020312e31382d2e356105458d01527f3620322e30352d2e35342e38342d312e353720312e33312d312e30332e34352d6105658d01527f322e34342e3436682d332e35346c2e35332d2e35365639367a6d312e31392d346105858d01527f2d2e35332d2e353868332e3571312e3638203020322e35352d2e37322e38372d6105a58d01527f2e37332e38382d322e303620302d312e33352d2e38382d322e30382d2e38372d6105c58d01527f2e37352d322e35352d2e3734682d332e356c2e35332d2e35367a6d31302e39346105e58d01527f20345638342e3868342e3271312e3432203020322e34342e343620312e30332e6106058d01527f343520312e353720312e33322e35362e38342e353620322e3036203020312e316106258d01527f382d2e353620322e30352d2e35342e38342d312e353720312e33312d312e30326106458d01527f2e34352d322e34352e3435682d332e35336c2e35332d2e35355639367a6d372e6106658d01527f363520302d322e38382d342e3036483131336c322e3920342e30367a6d2d362e6106858d01527f34362d342d2e35332d2e353668332e3571312e3638203020322e35352d2e37346106a58d01527f2e38382d2e37332e38382d322e303620302d312e33352d2e38382d322e30382d6106c58d01527f2e38372d2e37352d322e35352d2e3734682d332e356c2e35332d2e35367a6d316106e58d01527f322e32332d322e3268352e393276312e3032682d352e39327a6d2e313320352e6107058d01527f313868362e3734563936682d372e39325638342e384831323776312e3032682d6107258d01527f362e357a6d31332e3420312e3132712d312e323520302d322e342d2e346135206107458d01527f352030203020312d312e37352d312e30366c2e34362d2e3931712e362e3537206107658d01527f312e35382e39376136203620302030203020332e38332e3133712e36372d2e326107858d01527f372e39372d2e37322e33322d2e34352e33322d2e393920302d2e36362d2e33386107a58d01527f2d312e303661322e3520322e352030203020302d2e39382d2e3632712d2e362d6107c58d01527f2e32342d312e33342d2e3432742d312e34372d2e3336613720372030203020316107e58d01527f2d312e33362d2e3535712d2e362d2e33342d312d2e383861322e3620322e36206108058d01527f30203020312d2e33362d312e343520322e3820322e3820302030203120312e376108258d01527f392d322e3634712e392d2e343420322e33342d2e343461362e3620362e3620306108458d01527f2030203120332e343720316c2d2e342e3934712d2e37322d2e34382d312e35346108658d01527f2d2e37613620362030203020302d312e35352d2e3233712d312e303120302d316108858d01527f2e36362e32372d2e36362e32382d2e39382e37342d2e332e34352d2e3320312e6108a58d01527f30322030202e36362e333620312e30362e33392e342031202e36322e36312e326108c58d01527f3320312e33362e342e37332e313820312e34352e33392e37342e323120312e336108e58d01527f352e35342e36312e33322e39392e38372e33382e35342e333820312e343220306109058d01527f202e38312d2e343520312e35322d2e34352e36392d312e333720312e31322d2e6109258d01527f39322e34322d322e33352e34326d352e37372d2e3120352e31322d31312e32686109458d01527f312e31376c352e31322031312e32682d312e32356c2d342e372d31302e3531686109658d01527f2e34384c3134302e392039367a6d322e30322d33202e33352d2e393568362e356109858d01527f316c2e33352e39367a6d31342e30362033762d342e31366c2e32372e37342d346109a58d01527f2e37352d372e373868312e32366c342e313820362e3833682d2e36386c342e316109c58d01527f382d362e383368312e31386c2d342e373520372e37382e32372d2e37345639366109e58d01527f7a6d382e303520305638342e3868312e31387631302e313868362e3237563936610a058d01527f7a6d31342e392e31712d312e323720302d322e33362d2e343261362036203020610a258d01527f3020312d312e38372d312e32203620362030203020312d312e32332d312e3820610a458d01527f3620362030203020312d2e34332d322e323871302d312e32332e34332d322e32610a658d01527f3661352e3620352e3620302030203120332e312d3371312e30382d2e34342032610a858d01527f2e33352d2e343474322e33342e343461352e3420352e3420302030203120332e610aa58d01527f303920322e3939712e343520312e30352e343520322e323761352e3720352e37610ac58d01527f2030203020312d312e363820342e3038712d2e37392e37372d312e383620312e610ae58d01527f32613620362030203020312d322e33342e34326d302d312e3036613520352030610b058d01527f2030203020312e38352d2e333420342e3520342e3520302030203020322e3438610b258d01527f2d322e3434712e33362d2e38352e33352d312e383661342e3720342e37203020610b458d01527f3020302d312e33342d332e333120342e3820342e382030203020302d332e3334610b658d01527f2d312e3333203520352030203020302d332e333820312e3333712d2e36332e36610b858d01527f312d3120312e3437613520352030203020302d2e333420312e383420342e3820610ba58d01527f342e3820302030203020312e333420332e333320342e3620342e362030203020610bc58d01527f3020332e333820312e33316d392e33322e39365638342e3868342e3271312e34610be58d01527f31203020322e34342e343620312e30322e343520312e353720312e33322e3536610c058d01527f2e38342e353620322e3036203020312e31382d2e353620322e30352d2e35352e610c258d01527f38342d312e353720312e33312d312e30322e34352d322e34352e3435682d332e610c458d01527f35336c2e35332d2e35355639367a6d372e363520302d322e38382d342e303668610c658d01527f312e32386c322e3920342e30367a6d2d362e34362d342d2e35332d2e35366833610c858d01527f2e3571312e3638203020322e35342d2e37342e38392d2e37332e38382d322e30610ca58d01527f3620302d312e33352d2e38372d322e30382d2e38372d2e37352d322e35352d2e610cc58d01527f3734682d332e356c2e35332d2e35367a4d36352e352033346131392e35203139610ce58d01527f2e352030203120312d362e34342033372e39316c312e35352d312e3535613137610d058d01527f2e35362031372e35362030203120302d31312e342d31302e33336c2d312e3520610d258d01527f312e34394131392e352031392e352030203020312036352e352033344d35342e610d458d01527f332036372e303261313820313820302030203020342e323820322e36316c2d31610d658d01527f2e343720312e34386132302032302030203020312d342e31392d322e377a4d35610d858d01527f302e312036312e3961313820313820302030203020322e373820332e37396c2d610da58d01527f312e333720312e33386132302032302030203020312d322e38342d332e37337a610dc58d01527f222f3e0000000000000000000000000000000000000000000000000000000000610de58d0152610de88c0152610e088b0152610e288a0152610e48890152610e688801527f382d312e38376c31352e332d31352e33317a4d3130302e382036342e3432712d610e888801527f322e313520302d342e31312d2e3638613820382030203020312d332e30312d31610ea88801527f2e38316c2e382d312e35366138203820302030203020322e3720312e36377131610ec88801527f2e37332e363620332e36322e36356138203820302030203020322e39332d2e34610ee88801527f3320332e3620332e3620302030203020312e36372d312e3234712e35352d2e37610f088801527f352e35352d312e3761322e3520322e352030203020302d2e36362d312e382034610f288801527f20342030203020302d312e36372d312e3037712d312e30352d2e342d322e332d610f488801527f2e37316c2d322e35322d2e3633712d312e32362d2e33362d322e33332d2e3933610f688801527f613520352030203020312d312e372d312e3520342e3520342e35203020302031610f888801527f2d2e36332d322e3571302d312e34332e37342d322e3661352e3220352e322030610fa88801527f2030203120322e33332d312e39322039203920302030203120342d2e37342031610fc88801527f312e332031312e3320302030203120352e393420312e376c2d2e363820312e36610fe88801527f3161392e383320392e38332030203020302d352e32392d312e353920382038206110088801527f30203020302d322e38352e3437712d312e31312e34362d312e363720312e32366110288801527f2d2e35322e37372d2e353220312e3735203020312e31322e363320312e38312e6110488801527f36362e363920312e3720312e303720312e30372e333820322e33332e363874326110688801527f2e352e363671312e32352e333620322e332e393320312e30362e353520312e366110888801527f3920312e34382e36362e39332e363620322e3434203020312e342d2e373720326110a88801527f2e3661352e3520352e352030203020312d322e333620312e39322031302031306110c88801527f2030203020312d342e30322e37316d31362e342d2e31365634362e3834682d366110e88801527f2e3735762d312e37366831352e3576312e3736682d362e37337631372e34327a6111088801527f6d31332e333620305634352e303868372e313871322e3433203020342e31392e6111288801527f386136203620302030203120322e363820322e3234712e393620312e34352e396111488801527f3620332e353461362e3320362e332030203020312d2e393620332e35203620366111688801527f2030203020312d322e363820322e3235712d312e37352e37372d342e322e37376111888801527f682d362e30346c2e392d2e393476372e30327a6d31332e3120302d342e39342d6111a88801527f362e393668322e326c342e393520362e39367a6d2d31312e30372d362e38352d6111c88801527f2e392d2e3936683671322e3837203020342e33352d312e323620312e352d312e6111e88801527f323620312e352d332e353320302d322e332d312e352d332e35362d312e34382d6112088801527f312e32362d342e33362d312e3236682d366c2e39312d2e39367a6d31362e30376112288801527f20362e383520382e37362d31392e313868326c382e37372031392e3138682d326112488801527f2e31346c2d382e30352d3138682e38326c2d382e30352031387a6d332e34352d6112688801527f352e31332e362d312e36346831312e31356c2e3620312e36347a6d32332e33386112888801527f20352e31335634362e3834682d362e3734762d312e37366831352e3576312e376112a88801527f36682d362e37337631372e34327a6d34302e32342e3136712d322e313820302d6112c88801527f342e30352d2e37316131302031302030203020312d332e322d322e3036712d316112e88801527f2e33352d312e332d322e31312d332e312d2e37352d312e37372d2e37342d332e6113088801527f383820302d322e312e37342d332e383961392e3420392e3420302030203120356113288801527f2e33342d352e313271312e38362d2e373520342e30352d2e373420322e3220306113488801527f2034202e36386138203820302030203120332e313220322e30396c2d312e32366113688801527f20312e3238613720372030203020302d322e36362d312e3732712d312e34342d6113888801527f2e35322d332e31322d2e35322d312e373820302d332e32382e3661372e3720376113a88801527f2e372030203020302d342e393420372e3334713020312e372e3620332e31352e6113c88801527f363420312e343520312e373320322e35356138203820302030203020322e36206113e88801527f312e363771312e35322e353720332e32362e353720312e3635203020332e312d6114088801527f2e356137203720302030203020322e37312d312e36366c312e313520312e35336114288801527f613920392030203020312d332e3220312e3834712d312e38342e362d332e38346114488801527f2e366d352e312d322e3638762d372e303768312e393476372e33317a6d31332e6114688801527f363220322e3532762d372e31336c2e343720312e32362d382e31342d31332e336114888801527f68322e31376c372e31352031312e3639682d312e31366c372e31352d31312e376114a88801527f68322e30336c2d382e31332031332e33312e34362d312e323676372e31337a4d6114c88801527f3138382e382036322e3576312e37366831342e31356c2d312e31382d312e37366114e88801527f7a4d3138382e382035332e373476312e37356831312e3934762d312e37357a4d6115088801527f3138382e382034352e303876312e37366831322e39376c312e31362d312e37366115288801527f7a222f3e000000000000000000000000000000000000000000000000000000006115488801527f3c7465787420783d2233302220793d22333730222066696c6c3d22626c61636b61154c8801527f2220666f6e742d66616d696c793d2273616e732d73657269662220666f6e742d918261156c8901527f73697a653d22313470782220666f6e742d7765696768743d22333030223e546f61158c8901527f6b656e2049443c2f746578743e000000000000000000000000000000000000006115ac8901527f3c7465787420783d2233302220793d22333930222066696c6c3d22626c61636b6115b9890152826115d98901527f73697a653d22313670782220666f6e742d7765696768743d22353030223e00006115f98901528151612331816116179488868d0191016100c9565b88017f3c2f746578743e0000000000000000000000000000000000000000000000000080938201527f3c7465787420783d223236302220793d223337302220746578742d616e63686f61161e8201527f723d22656e64222066696c6c3d22626c61636b2220666f6e742d66616d696c798061163e8301527f3d2273616e732d73657269662220666f6e742d73697a653d223134707822206661165e8301527f6f6e742d7765696768743d22333030223e53545241542050757263686173656461167e8301528361169e8301527f3c7465787420783d223236302220793d223339302220746578742d616e63686f6116a58301526116c58201527f3d2273616e732d73657269662220666f6e742d73697a653d22313670782220666116e58201527f6f6e742d7765696768743d22353030223e00000000000000000000000000000061170582015261248d825180936117169889850191016100c9565b01938401527f3c7465787420783d2233302220793d22343230222066696c6c3d22626c61636b61171d8401528061173d8401527f73697a653d22313470782220666f6e742d7765696768743d22333030223e566561175d8401527f7374696e67205465726d733c2f746578743e000000000000000000000000000061177d8401527f3c7465787420783d2233302220793d22343430222066696c6c3d22626c61636b61178f8401526117af8301527f73697a653d22313270782220666f6e742d7765696768743d22353030223e53546117cf8301527f52415420766573747320666f722036206d6f6e74687320706f73742d6c61756e6117ef8301527f63683c2f746578743e000000000000000000000000000000000000000000000061180f83015251906125c38261181895868401906100c9565b0191820152036117fe81018452018261019d565b90565b67ffffffffffffffff811161015257601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b9061261e826125da565b61262b604051918261019d565b8281527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe061265982946125da565b0190602036910137565b806000917a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000808210156127c3575b506d04ee2d6d415b85acef8100000000808310156127b4575b50662386f26fc10000808310156127a5575b506305f5e10080831015612796575b5061271080831015612787575b506064821015612777575b600a8092101561276d575b6001908160216126fa828701612614565b95860101905b61270c575b5050505090565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019083907f30313233343536373839616263646566000000000000000000000000000000008282061a83530491821561276857919082612700565b612705565b91600101916126e9565b91906064600291049101916126de565b600491939204910191386126d3565b600891939204910191386126c6565b601091939204910191386126b7565b602091939204910191386126a5565b60409350810491503861268c565b604051906127de82610136565b600182527f30000000000000000000000000000000000000000000000000000000000000006020830152565b801561283557601261281b82612663565b51111561283557670de0b6b3a76400006125d79104612663565b506125d76127d1565b9290159081612b14575b5015612aff57612857916101de565b6040908151906060820182811067ffffffffffffffff8211176101525783528282526020918281017f4142434445464748494a4b4c4d4e4f505152535455565758595a61626364656690528381017f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f90526128d191612b1d565b825192828401907f226e616d65223a202200000000000000000000000000000000000000000000008252602985017f4554482053747261746567792050726573616c6500000000000000000000000090527f222c0000000000000000000000000000000000000000000000000000000000009182603d870152601f865261295786610136565b815190858201927f2273796d626f6c223a20220000000000000000000000000000000000000000008452602b83017f6f535452415400000000000000000000000000000000000000000000000000009052846031840152601383526129bb83610136565b80518095888201977f22696d616765223a2022000000000000000000000000000000000000000000008952602a83017f646174613a696d6167652f7376672b786d6c3b6261736536342c0000000000009052805190818b60448601920191612a22926100c9565b820190604482015203602681018652604601612a3e908661019d565b5196879687017f7b00000000000000000000000000000000000000000000000000000000000000905251908160218801612a77926100c9565b85019051918260218301612a8a926100c9565b019051918260218301612a9c926100c9565b01602181017f2261747472696275746573223a205b5d000000000000000000000000000000009052603181017f7d000000000000000000000000000000000000000000000000000000000000009052036012810182526032016125d7908261019d565b5050604051612b0d81610181565b6000815290565b90501538612848565b805115612aff578051600291828201809211612c725760038092047f3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81168103612c7257612b6e908495941b612614565b936020850193829183518401906020820192835194600085525b838110612c21575050505052510680600114612bd257600214612ba9575090565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff603d91015390565b507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe81603d7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81940153015390565b87600491999293949901918251600190603f9082828260121c16880101518453828282600c1c16880101518385015382828260061c1688010151888501531685010151898201530197929190612b88565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fdfea2646970667358221220934046c62ff8416d9982fd80ed9c10f46b0119047f62b93732ea9b7d190d413b64736f6c63430008140033
Loading...
Loading
Loading...
Loading

Multichain Portfolio | 34 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
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.