Overview
ETH Balance
0 ETH
ETH Value
$0.00More Info
Private Name Tags
ContractCreator
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
72818 | 32 days ago | Contract Creation | 0 ETH |
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Source Code Verified (Exact Match)
Contract Name:
SablierV2NFTDescriptor
Compiler Version
v0.8.26+commit.8a97fa7a
ZkSolc Version
v1.5.1
Optimization Enabled:
Yes with Mode z
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-3.0-or-later // solhint-disable max-line-length,quotes pragma solidity >=0.8.22; import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import { IERC721Metadata } from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol"; import { Base64 } from "@openzeppelin/contracts/utils/Base64.sol"; import { Strings } from "@openzeppelin/contracts/utils/Strings.sol"; import { ISablierV2Lockup } from "./interfaces/ISablierV2Lockup.sol"; import { ISablierV2NFTDescriptor } from "./interfaces/ISablierV2NFTDescriptor.sol"; import { Lockup } from "./types/DataTypes.sol"; import { Errors } from "./libraries/Errors.sol"; import { NFTSVG } from "./libraries/NFTSVG.sol"; import { SVGElements } from "./libraries/SVGElements.sol"; /* ███████╗ █████╗ ██████╗ ██╗ ██╗███████╗██████╗ ██╗ ██╗██████╗ ██╔════╝██╔══██╗██╔══██╗██║ ██║██╔════╝██╔══██╗ ██║ ██║╚════██╗ ███████╗███████║██████╔╝██║ ██║█████╗ ██████╔╝ ██║ ██║ █████╔╝ ╚════██║██╔══██║██╔══██╗██║ ██║██╔══╝ ██╔══██╗ ╚██╗ ██╔╝██╔═══╝ ███████║██║ ██║██████╔╝███████╗██║███████╗██║ ██║ ╚████╔╝ ███████╗ ╚══════╝╚═╝ ╚═╝╚═════╝ ╚══════╝╚═╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚══════╝ ███╗ ██╗███████╗████████╗ ██████╗ ███████╗███████╗ ██████╗██████╗ ██╗██████╗ ████████╗ ██████╗ ██████╗ ████╗ ██║██╔════╝╚══██╔══╝ ██╔══██╗██╔════╝██╔════╝██╔════╝██╔══██╗██║██╔══██╗╚══██╔══╝██╔═══██╗██╔══██╗ ██╔██╗ ██║█████╗ ██║ ██║ ██║█████╗ ███████╗██║ ██████╔╝██║██████╔╝ ██║ ██║ ██║██████╔╝ ██║╚██╗██║██╔══╝ ██║ ██║ ██║██╔══╝ ╚════██║██║ ██╔══██╗██║██╔═══╝ ██║ ██║ ██║██╔══██╗ ██║ ╚████║██║ ██║ ██████╔╝███████╗███████║╚██████╗██║ ██║██║██║ ██║ ╚██████╔╝██║ ██║ ╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚══════╝ ╚═════╝╚═╝ ╚═╝╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ */ /// @title SablierV2NFTDescriptor /// @notice See the documentation in {ISablierV2NFTDescriptor}. contract SablierV2NFTDescriptor is ISablierV2NFTDescriptor { using Strings for address; using Strings for string; using Strings for uint256; /*////////////////////////////////////////////////////////////////////////// USER-FACING CONSTANT FUNCTIONS //////////////////////////////////////////////////////////////////////////*/ /// @dev Needed to avoid Stack Too Deep. struct TokenURIVars { address asset; string assetSymbol; uint128 depositedAmount; bool isTransferable; string json; bytes returnData; ISablierV2Lockup sablier; string sablierModel; string sablierStringified; string status; string svg; uint256 streamedPercentage; bool success; } /// @inheritdoc ISablierV2NFTDescriptor function tokenURI(IERC721Metadata sablier, uint256 streamId) external view override returns (string memory uri) { TokenURIVars memory vars; // Load the contracts. vars.sablier = ISablierV2Lockup(address(sablier)); vars.sablierModel = mapSymbol(sablier); vars.sablierStringified = address(sablier).toHexString(); vars.asset = address(vars.sablier.getAsset(streamId)); vars.assetSymbol = safeAssetSymbol(vars.asset); vars.depositedAmount = vars.sablier.getDepositedAmount(streamId); // Load the stream's data. vars.status = stringifyStatus(vars.sablier.statusOf(streamId)); vars.streamedPercentage = calculateStreamedPercentage({ streamedAmount: vars.sablier.streamedAmountOf(streamId), depositedAmount: vars.depositedAmount }); // Generate the SVG. vars.svg = NFTSVG.generateSVG( NFTSVG.SVGParams({ accentColor: generateAccentColor(address(sablier), streamId), amount: abbreviateAmount({ amount: vars.depositedAmount, decimals: safeAssetDecimals(vars.asset) }), assetAddress: vars.asset.toHexString(), assetSymbol: vars.assetSymbol, duration: calculateDurationInDays({ startTime: vars.sablier.getStartTime(streamId), endTime: vars.sablier.getEndTime(streamId) }), sablierAddress: vars.sablierStringified, progress: stringifyPercentage(vars.streamedPercentage), progressNumerical: vars.streamedPercentage, status: vars.status, sablierModel: vars.sablierModel }) ); // Performs a low-level call to handle older deployments that miss the `isTransferable` function. (vars.success, vars.returnData) = address(vars.sablier).staticcall(abi.encodeCall(ISablierV2Lockup.isTransferable, (streamId))); // When the call has failed, the stream NFT is assumed to be transferable. vars.isTransferable = vars.success ? abi.decode(vars.returnData, (bool)) : true; // Generate the JSON metadata. vars.json = string.concat( '{"attributes":', generateAttributes({ assetSymbol: vars.assetSymbol, sender: vars.sablier.getSender(streamId).toHexString(), status: vars.status }), ',"description":"', generateDescription({ sablierModel: vars.sablierModel, assetSymbol: vars.assetSymbol, sablierStringified: vars.sablierStringified, assetAddress: vars.asset.toHexString(), streamId: streamId.toString(), isTransferable: vars.isTransferable }), '","external_url":"https://sablier.com","name":"', generateName({ sablierModel: vars.sablierModel, streamId: streamId.toString() }), '","image":"data:image/svg+xml;base64,', Base64.encode(bytes(vars.svg)), '"}' ); // Encode the JSON metadata in Base64. uri = string.concat("data:application/json;base64,", Base64.encode(bytes(vars.json))); } /*////////////////////////////////////////////////////////////////////////// INTERNAL CONSTANT FUNCTIONS //////////////////////////////////////////////////////////////////////////*/ /// @notice Creates an abbreviated representation of the provided amount, rounded down and prefixed with ">= ". /// @dev The abbreviation uses these suffixes: /// - "K" for thousands /// - "M" for millions /// - "B" for billions /// - "T" for trillions /// For example, if the input is 1,234,567, the output is ">= 1.23M". /// @param amount The amount to abbreviate, denoted in units of `decimals`. /// @param decimals The number of decimals to assume when abbreviating the amount. /// @return abbreviation The abbreviated representation of the provided amount, as a string. function abbreviateAmount(uint256 amount, uint256 decimals) internal pure returns (string memory) { if (amount == 0) { return "0"; } uint256 truncatedAmount; unchecked { truncatedAmount = decimals == 0 ? amount : amount / 10 ** decimals; } // Return dummy values when the truncated amount is either very small or very big. if (truncatedAmount < 1) { return string.concat(SVGElements.SIGN_LT, " 1"); } else if (truncatedAmount >= 1e15) { return string.concat(SVGElements.SIGN_GT, " 999.99T"); } string[5] memory suffixes = ["", "K", "M", "B", "T"]; uint256 fractionalAmount; uint256 suffixIndex = 0; // Truncate repeatedly until the amount is less than 1000. unchecked { while (truncatedAmount >= 1000) { fractionalAmount = (truncatedAmount / 10) % 100; // keep the first two digits after the decimal point truncatedAmount /= 1000; suffixIndex += 1; } } // Concatenate the calculated parts to form the final string. string memory prefix = string.concat(SVGElements.SIGN_GE, " "); string memory wholePart = truncatedAmount.toString(); string memory fractionalPart = stringifyFractionalAmount(fractionalAmount); return string.concat(prefix, wholePart, fractionalPart, suffixes[suffixIndex]); } /// @notice Calculates the stream's duration in days, rounding down. function calculateDurationInDays(uint256 startTime, uint256 endTime) internal pure returns (string memory) { uint256 durationInDays; unchecked { durationInDays = (endTime - startTime) / 1 days; } // Return dummy values when the duration is either very small or very big. if (durationInDays == 0) { return string.concat(SVGElements.SIGN_LT, " 1 Day"); } else if (durationInDays > 9999) { return string.concat(SVGElements.SIGN_GT, " 9999 Days"); } string memory suffix = durationInDays == 1 ? " Day" : " Days"; return string.concat(durationInDays.toString(), suffix); } /// @notice Calculates how much of the deposited amount has been streamed so far, as a percentage with 4 implied /// decimals. function calculateStreamedPercentage( uint128 streamedAmount, uint128 depositedAmount ) internal pure returns (uint256) { // This cannot overflow because both inputs are uint128s, and zero deposit amounts are not allowed in Sablier. unchecked { return streamedAmount * 10_000 / depositedAmount; } } /// @notice Generates a pseudo-random HSL color by hashing together the `chainid`, the `sablier` address, /// and the `streamId`. This will be used as the accent color for the SVG. function generateAccentColor(address sablier, uint256 streamId) internal view returns (string memory) { // The chain ID is part of the hash so that the generated color is different across chains. uint256 chainId = block.chainid; // Hash the parameters to generate a pseudo-random bit field, which will be used as entropy. // | Hue | Saturation | Lightness | -> Roles // | [31:16] | [15:8] | [7:0] | -> Bit positions uint32 bitField = uint32(uint256(keccak256(abi.encodePacked(chainId, sablier, streamId)))); unchecked { // The hue is a degree on a color wheel, so its range is [0, 360). // Shifting 16 bits to the right means using the bits at positions [31:16]. uint256 hue = (bitField >> 16) % 360; // The saturation is a percentage where 0% is grayscale and 100%, but here the range is bounded to [20,100] // to make the colors more lively. // Shifting 8 bits to the right and applying an 8-bit mask means using the bits at positions [15:8]. uint256 saturation = ((bitField >> 8) & 0xFF) % 80 + 20; // The lightness is typically a percentage between 0% (black) and 100% (white), but here the range // is bounded to [30,100] to avoid dark colors. // Applying an 8-bit mask means using the bits at positions [7:0]. uint256 lightness = (bitField & 0xFF) % 70 + 30; // Finally, concatenate the HSL values to form an SVG color string. return string.concat("hsl(", hue.toString(), ",", saturation.toString(), "%,", lightness.toString(), "%)"); } } /// @notice Generates an array of JSON objects that represent the NFT's attributes: /// - Asset symbol /// - Sender address /// - Status /// @dev These attributes are useful for filtering and sorting the NFTs. function generateAttributes( string memory assetSymbol, string memory sender, string memory status ) internal pure returns (string memory) { return string.concat( '[{"trait_type":"Asset","value":"', assetSymbol, '"},{"trait_type":"Sender","value":"', sender, '"},{"trait_type":"Status","value":"', status, '"}]' ); } /// @notice Generates a string with the NFT's JSON metadata description, which provides a high-level overview. function generateDescription( string memory sablierModel, string memory assetSymbol, string memory sablierStringified, string memory assetAddress, string memory streamId, bool isTransferable ) internal pure returns (string memory) { // Depending on the transferability of the NFT, declare the relevant information. string memory info = isTransferable ? unicode"⚠️ WARNING: Transferring the NFT makes the new owner the recipient of the stream. The funds are not automatically withdrawn for the previous recipient." : unicode"❕INFO: This NFT is non-transferable. It cannot be sold or transferred to another account."; return string.concat( "This NFT represents a payment stream in a Sablier V2 ", sablierModel, " contract. The owner of this NFT can withdraw the streamed assets, which are denominated in ", assetSymbol, ".\\n\\n- Stream ID: ", streamId, "\\n- ", sablierModel, " Address: ", sablierStringified, "\\n- ", assetSymbol, " Address: ", assetAddress, "\\n\\n", info ); } /// @notice Generates a string with the NFT's JSON metadata name, which is unique for each stream. /// @dev The `streamId` is equivalent to the ERC-721 `tokenId`. function generateName(string memory sablierModel, string memory streamId) internal pure returns (string memory) { return string.concat("Sablier V2 ", sablierModel, " #", streamId); } /// @notice Checks whether the provided string contains only alphanumeric characters, spaces, and dashes. /// @dev Note that this returns true for empty strings. function isAllowedCharacter(string memory str) internal pure returns (bool) { // Convert the string to bytes to iterate over its characters. bytes memory b = bytes(str); uint256 length = b.length; for (uint256 i = 0; i < length; ++i) { bytes1 char = b[i]; // Check if it's a space, dash, or an alphanumeric character. bool isSpace = char == 0x20; // space bool isDash = char == 0x2D; // dash bool isDigit = char >= 0x30 && char <= 0x39; // 0-9 bool isUppercaseLetter = char >= 0x41 && char <= 0x5A; // A-Z bool isLowercaseLetter = char >= 0x61 && char <= 0x7A; // a-z if (!(isSpace || isDash || isDigit || isUppercaseLetter || isLowercaseLetter)) { return false; } } return true; } /// @notice Maps ERC-721 symbols to human-readable model names. /// @dev Reverts if the symbol is unknown. function mapSymbol(IERC721Metadata sablier) internal view returns (string memory) { string memory symbol = sablier.symbol(); if (symbol.equal("SAB-V2-LOCKUP-LIN")) { return "Lockup Linear"; } else if (symbol.equal("SAB-V2-LOCKUP-DYN")) { return "Lockup Dynamic"; } else if (symbol.equal("SAB-V2-LOCKUP-TRA")) { return "Lockup Tranched"; } else { revert Errors.SablierV2NFTDescriptor_UnknownNFT(sablier, symbol); } } /// @notice Retrieves the asset's decimals safely, defaulting to "0" if an error occurs. /// @dev Performs a low-level call to handle assets in which the decimals are not implemented. function safeAssetDecimals(address asset) internal view returns (uint8) { (bool success, bytes memory returnData) = asset.staticcall(abi.encodeCall(IERC20Metadata.decimals, ())); if (success && returnData.length == 32) { return abi.decode(returnData, (uint8)); } else { return 0; } } /// @notice Retrieves the asset's symbol safely, defaulting to a hard-coded value if an error occurs. /// @dev Performs a low-level call to handle assets in which the symbol is not implemented or it is a bytes32 /// instead of a string. function safeAssetSymbol(address asset) internal view returns (string memory) { (bool success, bytes memory returnData) = asset.staticcall(abi.encodeCall(IERC20Metadata.symbol, ())); // Non-empty strings have a length greater than 64, and bytes32 has length 32. if (!success || returnData.length <= 64) { return "ERC20"; } string memory symbol = abi.decode(returnData, (string)); // Check if the symbol is too long or contains disallowed characters. This measure helps mitigate potential // security threats from malicious assets injecting scripts in the symbol string. if (bytes(symbol).length > 30) { return "Long Symbol"; } else { if (!isAllowedCharacter(symbol)) { return "Unsupported Symbol"; } return symbol; } } /// @notice Converts the provided fractional amount to a string prefixed by a dot. /// @param fractionalAmount A numerical value with 2 implied decimals. function stringifyFractionalAmount(uint256 fractionalAmount) internal pure returns (string memory) { // Return the empty string if the fractional amount is zero. if (fractionalAmount == 0) { return ""; } // Add a leading zero if the fractional part is less than 10, e.g. for "1", this function returns ".01%". else if (fractionalAmount < 10) { return string.concat(".0", fractionalAmount.toString()); } // Otherwise, stringify the fractional amount simply. else { return string.concat(".", fractionalAmount.toString()); } } /// @notice Converts the provided percentage to a string. /// @param percentage A numerical value with 4 implied decimals. function stringifyPercentage(uint256 percentage) internal pure returns (string memory) { // Extract the last two decimals. string memory fractionalPart = stringifyFractionalAmount(percentage % 100); // Remove the last two decimals. string memory wholePart = (percentage / 100).toString(); // Concatenate the whole and fractional parts. return string.concat(wholePart, fractionalPart, "%"); } /// @notice Retrieves the stream's status as a string. function stringifyStatus(Lockup.Status status) internal pure returns (string memory) { if (status == Lockup.Status.DEPLETED) { return "Depleted"; } else if (status == Lockup.Status.CANCELED) { return "Canceled"; } else if (status == Lockup.Status.STREAMING) { return "Streaming"; } else if (status == Lockup.Status.SETTLED) { return "Settled"; } else { return "Pending"; } } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.8.22; import { IERC721Metadata } from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol"; import { UD60x18 } from "@prb/math/src/UD60x18.sol"; /// @title Errors /// @notice Library containing all custom errors the protocol may revert with. library Errors { /*////////////////////////////////////////////////////////////////////////// GENERICS //////////////////////////////////////////////////////////////////////////*/ /// @notice Thrown when `msg.sender` is not the admin. error CallerNotAdmin(address admin, address caller); /// @notice Thrown when trying to delegate call to a function that disallows delegate calls. error DelegateCall(); /*////////////////////////////////////////////////////////////////////////// SABLIER-V2-LOCKUP //////////////////////////////////////////////////////////////////////////*/ /// @notice Thrown when trying to allow to hook a contract that doesn't implement the interface correctly. error SablierV2Lockup_AllowToHookUnsupportedInterface(address recipient); /// @notice Thrown when trying to allow to hook an address with no code. error SablierV2Lockup_AllowToHookZeroCodeSize(address recipient); /// @notice Thrown when the broker fee exceeds the maximum allowed fee. error SablierV2Lockup_BrokerFeeTooHigh(UD60x18 brokerFee, UD60x18 maxBrokerFee); /// @notice Thrown when trying to create a stream with a zero deposit amount. error SablierV2Lockup_DepositAmountZero(); /// @notice Thrown when trying to create a stream with an end time not in the future. error SablierV2Lockup_EndTimeNotInTheFuture(uint40 blockTimestamp, uint40 endTime); /// @notice Thrown when the hook does not return the correct selector. error SablierV2Lockup_InvalidHookSelector(address recipient); /// @notice Thrown when trying to transfer Stream NFT when transferability is disabled. error SablierV2Lockup_NotTransferable(uint256 tokenId); /// @notice Thrown when the ID references a null stream. error SablierV2Lockup_Null(uint256 streamId); /// @notice Thrown when trying to withdraw an amount greater than the withdrawable amount. error SablierV2Lockup_Overdraw(uint256 streamId, uint128 amount, uint128 withdrawableAmount); /// @notice Thrown when trying to create a stream with a zero start time. error SablierV2Lockup_StartTimeZero(); /// @notice Thrown when trying to cancel or renounce a canceled stream. error SablierV2Lockup_StreamCanceled(uint256 streamId); /// @notice Thrown when trying to cancel, renounce, or withdraw from a depleted stream. error SablierV2Lockup_StreamDepleted(uint256 streamId); /// @notice Thrown when trying to cancel or renounce a stream that is not cancelable. error SablierV2Lockup_StreamNotCancelable(uint256 streamId); /// @notice Thrown when trying to burn a stream that is not depleted. error SablierV2Lockup_StreamNotDepleted(uint256 streamId); /// @notice Thrown when trying to cancel or renounce a settled stream. error SablierV2Lockup_StreamSettled(uint256 streamId); /// @notice Thrown when `msg.sender` lacks authorization to perform an action. error SablierV2Lockup_Unauthorized(uint256 streamId, address caller); /// @notice Thrown when trying to withdraw to an address other than the recipient's. error SablierV2Lockup_WithdrawalAddressNotRecipient(uint256 streamId, address caller, address to); /// @notice Thrown when trying to withdraw zero assets from a stream. error SablierV2Lockup_WithdrawAmountZero(uint256 streamId); /// @notice Thrown when trying to withdraw from multiple streams and the number of stream IDs does /// not match the number of withdraw amounts. error SablierV2Lockup_WithdrawArrayCountsNotEqual(uint256 streamIdsCount, uint256 amountsCount); /// @notice Thrown when trying to withdraw to the zero address. error SablierV2Lockup_WithdrawToZeroAddress(uint256 streamId); /*////////////////////////////////////////////////////////////////////////// SABLIER-V2-LOCKUP-DYNAMIC //////////////////////////////////////////////////////////////////////////*/ /// @notice Thrown when trying to create a stream with a deposit amount not equal to the sum of the /// segment amounts. error SablierV2LockupDynamic_DepositAmountNotEqualToSegmentAmountsSum( uint128 depositAmount, uint128 segmentAmountsSum ); /// @notice Thrown when trying to create a stream with more segments than the maximum allowed. error SablierV2LockupDynamic_SegmentCountTooHigh(uint256 count); /// @notice Thrown when trying to create a stream with no segments. error SablierV2LockupDynamic_SegmentCountZero(); /// @notice Thrown when trying to create a stream with unordered segment timestamps. error SablierV2LockupDynamic_SegmentTimestampsNotOrdered( uint256 index, uint40 previousTimestamp, uint40 currentTimestamp ); /// @notice Thrown when trying to create a stream with a start time not strictly less than the first /// segment timestamp. error SablierV2LockupDynamic_StartTimeNotLessThanFirstSegmentTimestamp( uint40 startTime, uint40 firstSegmentTimestamp ); /*////////////////////////////////////////////////////////////////////////// SABLIER-V2-LOCKUP-LINEAR //////////////////////////////////////////////////////////////////////////*/ /// @notice Thrown when trying to create a stream with a cliff time not strictly less than the end time. error SablierV2LockupLinear_CliffTimeNotLessThanEndTime(uint40 cliffTime, uint40 endTime); /// @notice Thrown when trying to create a stream with a start time not strictly less than the cliff time, when the /// cliff time does not have a zero value. error SablierV2LockupLinear_StartTimeNotLessThanCliffTime(uint40 startTime, uint40 cliffTime); /// @notice Thrown when trying to create a stream with a start time not strictly less than the end time. error SablierV2LockupLinear_StartTimeNotLessThanEndTime(uint40 startTime, uint40 endTime); /*////////////////////////////////////////////////////////////////////////// SABLIER-V2-NFT-DESCRIPTOR //////////////////////////////////////////////////////////////////////////*/ /// @notice Thrown when trying to generate the token URI for an unknown ERC-721 NFT contract. error SablierV2NFTDescriptor_UnknownNFT(IERC721Metadata nft, string symbol); /*////////////////////////////////////////////////////////////////////////// SABLIER-V2-LOCKUP-TRANCHE //////////////////////////////////////////////////////////////////////////*/ /// @notice Thrown when trying to create a stream with a deposit amount not equal to the sum of the /// tranche amounts. error SablierV2LockupTranched_DepositAmountNotEqualToTrancheAmountsSum( uint128 depositAmount, uint128 trancheAmountsSum ); /// @notice Thrown when trying to create a stream with a start time not strictly less than the first /// tranche timestamp. error SablierV2LockupTranched_StartTimeNotLessThanFirstTrancheTimestamp( uint40 startTime, uint40 firstTrancheTimestamp ); /// @notice Thrown when trying to create a stream with more tranches than the maximum allowed. error SablierV2LockupTranched_TrancheCountTooHigh(uint256 count); /// @notice Thrown when trying to create a stream with no tranches. error SablierV2LockupTranched_TrancheCountZero(); /// @notice Thrown when trying to create a stream with unordered tranche timestamps. error SablierV2LockupTranched_TrancheTimestampsNotOrdered( uint256 index, uint40 previousTimestamp, uint40 currentTimestamp ); }
// SPDX-License-Identifier: GPL-3.0-or-later // solhint-disable quotes pragma solidity >=0.8.22; import { Strings } from "@openzeppelin/contracts/utils/Strings.sol"; import { SVGElements } from "./SVGElements.sol"; library NFTSVG { using Strings for uint256; uint256 internal constant CARD_MARGIN = 16; struct SVGParams { string accentColor; string amount; string assetAddress; string assetSymbol; string duration; string progress; uint256 progressNumerical; string sablierAddress; string sablierModel; string status; } struct SVGVars { string amountCard; uint256 amountWidth; uint256 amountXPosition; string cards; uint256 cardsWidth; string durationCard; uint256 durationWidth; uint256 durationXPosition; string progressCard; uint256 progressWidth; uint256 progressXPosition; string statusCard; uint256 statusWidth; uint256 statusXPosition; } function generateSVG(SVGParams memory params) internal pure returns (string memory) { SVGVars memory vars; // Generate the progress card. (vars.progressWidth, vars.progressCard) = SVGElements.card({ cardType: SVGElements.CardType.PROGRESS, content: params.progress, circle: SVGElements.progressCircle({ progressNumerical: params.progressNumerical, accentColor: params.accentColor }) }); // Generate the status card. (vars.statusWidth, vars.statusCard) = SVGElements.card({ cardType: SVGElements.CardType.STATUS, content: params.status }); // Generate the deposit amount card. (vars.amountWidth, vars.amountCard) = SVGElements.card({ cardType: SVGElements.CardType.AMOUNT, content: params.amount }); // Generate the duration card. (vars.durationWidth, vars.durationCard) = SVGElements.card({ cardType: SVGElements.CardType.DURATION, content: params.duration }); unchecked { // Calculate the width of the row containing the cards and the margins between them. vars.cardsWidth = vars.amountWidth + vars.durationWidth + vars.progressWidth + vars.statusWidth + CARD_MARGIN * 3; // Calculate the positions on the X axis based on the following layout: // // ___________________________ SVG Width (1000px) ___________________________ // | | | | | | | | | | // | <-> | Progress | 16px | Status | 16px | Amount | 16px | Duration | <-> | vars.progressXPosition = (1000 - vars.cardsWidth) / 2; vars.statusXPosition = vars.progressXPosition + vars.progressWidth + CARD_MARGIN; vars.amountXPosition = vars.statusXPosition + vars.statusWidth + CARD_MARGIN; vars.durationXPosition = vars.amountXPosition + vars.amountWidth + CARD_MARGIN; } // Concatenate all cards. vars.cards = string.concat(vars.progressCard, vars.statusCard, vars.amountCard, vars.durationCard); return string.concat( '<svg xmlns="http://www.w3.org/2000/svg" width="1000" height="1000" viewBox="0 0 1000 1000">', SVGElements.BACKGROUND, generateDefs(params.accentColor, params.status, vars.cards), generateFloatingText(params.sablierAddress, params.sablierModel, params.assetAddress, params.assetSymbol), generateHrefs(vars.progressXPosition, vars.statusXPosition, vars.amountXPosition, vars.durationXPosition), "</svg>" ); } function generateDefs( string memory accentColor, string memory status, string memory cards ) internal pure returns (string memory) { return string.concat( "<defs>", SVGElements.GLOW, SVGElements.NOISE, SVGElements.LOGO, SVGElements.FLOATING_TEXT, SVGElements.gradients(accentColor), SVGElements.hourglass(status), cards, "</defs>" ); } function generateFloatingText( string memory sablierAddress, string memory sablierModel, string memory assetAddress, string memory assetSymbol ) internal pure returns (string memory) { return string.concat( '<text text-rendering="optimizeSpeed">', SVGElements.floatingText({ offset: "-100%", text: string.concat(sablierAddress, unicode" • ", "Sablier V2 ", sablierModel) }), SVGElements.floatingText({ offset: "0%", text: string.concat(sablierAddress, unicode" • ", "Sablier V2 ", sablierModel) }), SVGElements.floatingText({ offset: "-50%", text: string.concat(assetAddress, unicode" • ", assetSymbol) }), SVGElements.floatingText({ offset: "50%", text: string.concat(assetAddress, unicode" • ", assetSymbol) }), "</text>" ); } function generateHrefs( uint256 progressXPosition, uint256 statusXPosition, uint256 amountXPosition, uint256 durationXPosition ) internal pure returns (string memory) { return string.concat( '<use href="#Glow" fill-opacity=".9"/>', '<use href="#Glow" x="1000" y="1000" fill-opacity=".9"/>', '<use href="#Logo" x="170" y="170" transform="scale(.6)"/>' '<use href="#Hourglass" x="150" y="90" transform="rotate(10)" transform-origin="500 500"/>', '<use href="#Progress" x="', progressXPosition.toString(), '" y="790"/>', '<use href="#Status" x="', statusXPosition.toString(), '" y="790"/>', '<use href="#Amount" x="', amountXPosition.toString(), '" y="790"/>', '<use href="#Duration" x="', durationXPosition.toString(), '" y="790"/>' ); } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.8.22; import { IERC4906 } from "@openzeppelin/contracts/interfaces/IERC4906.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { IERC721Metadata } from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol"; import { UD60x18 } from "@prb/math/src/UD60x18.sol"; import { Lockup } from "../types/DataTypes.sol"; import { IAdminable } from "./IAdminable.sol"; import { ISablierV2NFTDescriptor } from "./ISablierV2NFTDescriptor.sol"; /// @title ISablierV2Lockup /// @notice Common logic between all Sablier V2 Lockup contracts. interface ISablierV2Lockup is IAdminable, // 0 inherited components IERC4906, // 2 inherited components IERC721Metadata // 2 inherited components { /*////////////////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////////////////*/ /// @notice Emitted when the admin allows a new recipient contract to hook to Sablier. /// @param admin The address of the current contract admin. /// @param recipient The address of the recipient contract put on the allowlist. event AllowToHook(address indexed admin, address recipient); /// @notice Emitted when a stream is canceled. /// @param streamId The ID of the stream. /// @param sender The address of the stream's sender. /// @param recipient The address of the stream's recipient. /// @param asset The contract address of the ERC-20 asset to be distributed. /// @param senderAmount The amount of assets refunded to the stream's sender, denoted in units of the asset's /// decimals. /// @param recipientAmount The amount of assets left for the stream's recipient to withdraw, denoted in units of the /// asset's decimals. event CancelLockupStream( uint256 streamId, address indexed sender, address indexed recipient, IERC20 indexed asset, uint128 senderAmount, uint128 recipientAmount ); /// @notice Emitted when a sender gives up the right to cancel a stream. /// @param streamId The ID of the stream. event RenounceLockupStream(uint256 indexed streamId); /// @notice Emitted when the admin sets a new NFT descriptor contract. /// @param admin The address of the current contract admin. /// @param oldNFTDescriptor The address of the old NFT descriptor contract. /// @param newNFTDescriptor The address of the new NFT descriptor contract. event SetNFTDescriptor( address indexed admin, ISablierV2NFTDescriptor oldNFTDescriptor, ISablierV2NFTDescriptor newNFTDescriptor ); /// @notice Emitted when assets are withdrawn from a stream. /// @param streamId The ID of the stream. /// @param to The address that has received the withdrawn assets. /// @param asset The contract address of the ERC-20 asset to be distributed. /// @param amount The amount of assets withdrawn, denoted in units of the asset's decimals. event WithdrawFromLockupStream(uint256 indexed streamId, address indexed to, IERC20 indexed asset, uint128 amount); /*////////////////////////////////////////////////////////////////////////// CONSTANT FUNCTIONS //////////////////////////////////////////////////////////////////////////*/ /// @notice Retrieves the address of the ERC-20 asset to be distributed. /// @dev Reverts if `streamId` references a null stream. /// @param streamId The stream ID for the query. function getAsset(uint256 streamId) external view returns (IERC20 asset); /// @notice Retrieves the amount deposited in the stream, denoted in units of the asset's decimals. /// @dev Reverts if `streamId` references a null stream. /// @param streamId The stream ID for the query. function getDepositedAmount(uint256 streamId) external view returns (uint128 depositedAmount); /// @notice Retrieves the stream's end time, which is a Unix timestamp. /// @dev Reverts if `streamId` references a null stream. /// @param streamId The stream ID for the query. function getEndTime(uint256 streamId) external view returns (uint40 endTime); /// @notice Retrieves the stream's recipient. /// @dev Reverts if the NFT has been burned. /// @param streamId The stream ID for the query. function getRecipient(uint256 streamId) external view returns (address recipient); /// @notice Retrieves the amount refunded to the sender after a cancellation, denoted in units of the asset's /// decimals. This amount is always zero unless the stream was canceled. /// @dev Reverts if `streamId` references a null stream. /// @param streamId The stream ID for the query. function getRefundedAmount(uint256 streamId) external view returns (uint128 refundedAmount); /// @notice Retrieves the stream's sender. /// @dev Reverts if `streamId` references a null stream. /// @param streamId The stream ID for the query. function getSender(uint256 streamId) external view returns (address sender); /// @notice Retrieves the stream's start time, which is a Unix timestamp. /// @dev Reverts if `streamId` references a null stream. /// @param streamId The stream ID for the query. function getStartTime(uint256 streamId) external view returns (uint40 startTime); /// @notice Retrieves the amount withdrawn from the stream, denoted in units of the asset's decimals. /// @dev Reverts if `streamId` references a null stream. /// @param streamId The stream ID for the query. function getWithdrawnAmount(uint256 streamId) external view returns (uint128 withdrawnAmount); /// @notice Retrieves a flag indicating whether the provided address is a contract allowed to hook to Sablier /// when a stream is canceled or when assets are withdrawn. /// @dev See {ISablierLockupRecipient} for more information. function isAllowedToHook(address recipient) external view returns (bool result); /// @notice Retrieves a flag indicating whether the stream can be canceled. When the stream is cold, this /// flag is always `false`. /// @dev Reverts if `streamId` references a null stream. /// @param streamId The stream ID for the query. function isCancelable(uint256 streamId) external view returns (bool result); /// @notice Retrieves a flag indicating whether the stream is cold, i.e. settled, canceled, or depleted. /// @dev Reverts if `streamId` references a null stream. /// @param streamId The stream ID for the query. function isCold(uint256 streamId) external view returns (bool result); /// @notice Retrieves a flag indicating whether the stream is depleted. /// @dev Reverts if `streamId` references a null stream. /// @param streamId The stream ID for the query. function isDepleted(uint256 streamId) external view returns (bool result); /// @notice Retrieves a flag indicating whether the stream exists. /// @dev Does not revert if `streamId` references a null stream. /// @param streamId The stream ID for the query. function isStream(uint256 streamId) external view returns (bool result); /// @notice Retrieves a flag indicating whether the stream NFT can be transferred. /// @dev Reverts if `streamId` references a null stream. /// @param streamId The stream ID for the query. function isTransferable(uint256 streamId) external view returns (bool result); /// @notice Retrieves a flag indicating whether the stream is warm, i.e. either pending or streaming. /// @dev Reverts if `streamId` references a null stream. /// @param streamId The stream ID for the query. function isWarm(uint256 streamId) external view returns (bool result); /// @notice Retrieves the maximum broker fee that can be charged by the broker, denoted as a fixed-point /// number where 1e18 is 100%. /// @dev This value is hard coded as a constant. function MAX_BROKER_FEE() external view returns (UD60x18); /// @notice Counter for stream IDs, used in the create functions. function nextStreamId() external view returns (uint256); /// @notice Contract that generates the non-fungible token URI. function nftDescriptor() external view returns (ISablierV2NFTDescriptor); /// @notice Calculates the amount that the sender would be refunded if the stream were canceled, denoted in units /// of the asset's decimals. /// @dev Reverts if `streamId` references a null stream. /// @param streamId The stream ID for the query. function refundableAmountOf(uint256 streamId) external view returns (uint128 refundableAmount); /// @notice Retrieves the stream's status. /// @dev Reverts if `streamId` references a null stream. /// @param streamId The stream ID for the query. function statusOf(uint256 streamId) external view returns (Lockup.Status status); /// @notice Calculates the amount streamed to the recipient, denoted in units of the asset's decimals. /// @dev Reverts if `streamId` references a null stream. /// /// Notes: /// - Upon cancellation of the stream, the amount streamed is calculated as the difference between the deposited /// amount and the refunded amount. Ultimately, when the stream becomes depleted, the streamed amount is equivalent /// to the total amount withdrawn. /// /// @param streamId The stream ID for the query. function streamedAmountOf(uint256 streamId) external view returns (uint128 streamedAmount); /// @notice Retrieves a flag indicating whether the stream was canceled. /// @dev Reverts if `streamId` references a null stream. /// @param streamId The stream ID for the query. function wasCanceled(uint256 streamId) external view returns (bool result); /// @notice Calculates the amount that the recipient can withdraw from the stream, denoted in units of the asset's /// decimals. /// @dev Reverts if `streamId` references a null stream. /// @param streamId The stream ID for the query. function withdrawableAmountOf(uint256 streamId) external view returns (uint128 withdrawableAmount); /*////////////////////////////////////////////////////////////////////////// NON-CONSTANT FUNCTIONS //////////////////////////////////////////////////////////////////////////*/ /// @notice Allows a recipient contract to hook to Sablier when a stream is canceled or when assets are withdrawn. /// Useful for implementing contracts that hold streams on behalf of users, such as vaults or staking contracts. /// /// @dev Emits an {AllowToHook} event. /// /// Notes: /// - Does not revert if the contract is already on the allowlist. /// - This is an irreversible operation. The contract cannot be removed from the allowlist. /// /// Requirements: /// - `msg.sender` must be the contract admin. /// - `recipient` must have a non-zero code size. /// - `recipient` must implement {ISablierLockupRecipient}. /// /// @param recipient The address of the contract to allow for hooks. function allowToHook(address recipient) external; /// @notice Burns the NFT associated with the stream. /// /// @dev Emits a {Transfer} event. /// /// Requirements: /// - Must not be delegate called. /// - `streamId` must reference a depleted stream. /// - The NFT must exist. /// - `msg.sender` must be either the NFT owner or an approved third party. /// /// @param streamId The ID of the stream NFT to burn. function burn(uint256 streamId) external; /// @notice Cancels the stream and refunds any remaining assets to the sender. /// /// @dev Emits a {Transfer}, {CancelLockupStream}, and {MetadataUpdate} event. /// /// Notes: /// - If there any assets left for the recipient to withdraw, the stream is marked as canceled. Otherwise, the /// stream is marked as depleted. /// - This function attempts to invoke a hook on the recipient, if the resolved address is a contract. /// /// Requirements: /// - Must not be delegate called. /// - The stream must be warm and cancelable. /// - `msg.sender` must be the stream's sender. /// /// @param streamId The ID of the stream to cancel. function cancel(uint256 streamId) external; /// @notice Cancels multiple streams and refunds any remaining assets to the sender. /// /// @dev Emits multiple {Transfer}, {CancelLockupStream}, and {MetadataUpdate} events. /// /// Notes: /// - Refer to the notes in {cancel}. /// /// Requirements: /// - All requirements from {cancel} must be met for each stream. /// /// @param streamIds The IDs of the streams to cancel. function cancelMultiple(uint256[] calldata streamIds) external; /// @notice Removes the right of the stream's sender to cancel the stream. /// /// @dev Emits a {RenounceLockupStream} and {MetadataUpdate} event. /// /// Notes: /// - This is an irreversible operation. /// /// Requirements: /// - Must not be delegate called. /// - `streamId` must reference a warm stream. /// - `msg.sender` must be the stream's sender. /// - The stream must be cancelable. /// /// @param streamId The ID of the stream to renounce. function renounce(uint256 streamId) external; /// @notice Sets a new NFT descriptor contract, which produces the URI describing the Sablier stream NFTs. /// /// @dev Emits a {SetNFTDescriptor} and {BatchMetadataUpdate} event. /// /// Notes: /// - Does not revert if the NFT descriptor is the same. /// /// Requirements: /// - `msg.sender` must be the contract admin. /// /// @param newNFTDescriptor The address of the new NFT descriptor contract. function setNFTDescriptor(ISablierV2NFTDescriptor newNFTDescriptor) external; /// @notice Withdraws the provided amount of assets from the stream to the `to` address. /// /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event. /// /// Notes: /// - This function attempts to call a hook on the recipient of the stream, unless `msg.sender` is the recipient. /// /// Requirements: /// - Must not be delegate called. /// - `streamId` must not reference a null or depleted stream. /// - `to` must not be the zero address. /// - `amount` must be greater than zero and must not exceed the withdrawable amount. /// - `to` must be the recipient if `msg.sender` is not the stream's recipient or an approved third party. /// /// @param streamId The ID of the stream to withdraw from. /// @param to The address receiving the withdrawn assets. /// @param amount The amount to withdraw, denoted in units of the asset's decimals. function withdraw(uint256 streamId, address to, uint128 amount) external; /// @notice Withdraws the maximum withdrawable amount from the stream to the provided address `to`. /// /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event. /// /// Notes: /// - Refer to the notes in {withdraw}. /// /// Requirements: /// - Refer to the requirements in {withdraw}. /// /// @param streamId The ID of the stream to withdraw from. /// @param to The address receiving the withdrawn assets. /// @return withdrawnAmount The amount withdrawn, denoted in units of the asset's decimals. function withdrawMax(uint256 streamId, address to) external returns (uint128 withdrawnAmount); /// @notice Withdraws the maximum withdrawable amount from the stream to the current recipient, and transfers the /// NFT to `newRecipient`. /// /// @dev Emits a {WithdrawFromLockupStream} and a {Transfer} event. /// /// Notes: /// - If the withdrawable amount is zero, the withdrawal is skipped. /// - Refer to the notes in {withdraw}. /// /// Requirements: /// - `msg.sender` must be the stream's recipient. /// - Refer to the requirements in {withdraw}. /// - Refer to the requirements in {IERC721.transferFrom}. /// /// @param streamId The ID of the stream NFT to transfer. /// @param newRecipient The address of the new owner of the stream NFT. /// @return withdrawnAmount The amount withdrawn, denoted in units of the asset's decimals. function withdrawMaxAndTransfer( uint256 streamId, address newRecipient ) external returns (uint128 withdrawnAmount); /// @notice Withdraws assets from streams to the recipient of each stream. /// /// @dev Emits multiple {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} events. /// /// Notes: /// - This function attempts to call a hook on the recipient of each stream, unless `msg.sender` is the recipient. /// /// Requirements: /// - Must not be delegate called. /// - There must be an equal number of `streamIds` and `amounts`. /// - Each stream ID in the array must not reference a null or depleted stream. /// - Each amount in the array must be greater than zero and must not exceed the withdrawable amount. /// /// @param streamIds The IDs of the streams to withdraw from. /// @param amounts The amounts to withdraw, denoted in units of the asset's decimals. function withdrawMultiple(uint256[] calldata streamIds, uint128[] calldata amounts) external; }
// SPDX-License-Identifier: GPL-3.0-or-later // solhint-disable max-line-length,quotes pragma solidity >=0.8.22; import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; import { Strings } from "@openzeppelin/contracts/utils/Strings.sol"; library SVGElements { using Strings for string; using Strings for uint256; /*////////////////////////////////////////////////////////////////////////// CONSTANTS //////////////////////////////////////////////////////////////////////////*/ string internal constant BACKGROUND = '<rect width="100%" height="100%" filter="url(#Noise)"/><rect x="70" y="70" width="860" height="860" fill="#fff" fill-opacity=".03" rx="45" ry="45" stroke="#fff" stroke-opacity=".1" stroke-width="4"/>'; string internal constant BACKGROUND_COLOR = "hsl(230,21%,11%)"; string internal constant FLOATING_TEXT = '<path id="FloatingText" fill="none" d="M125 45h750s80 0 80 80v750s0 80 -80 80h-750s-80 0 -80 -80v-750s0 -80 80 -80"/>'; string internal constant GLOW = '<circle id="Glow" r="500" fill="url(#RadialGlow)"/>'; string internal constant LOGO = '<path id="Logo" fill="#fff" fill-opacity=".1" d="m133.559,124.034c-.013,2.412-1.059,4.848-2.923,6.402-2.558,1.819-5.168,3.439-7.888,4.996-14.44,8.262-31.047,12.565-47.674,12.569-8.858.036-17.838-1.272-26.328-3.663-9.806-2.766-19.087-7.113-27.562-12.778-13.842-8.025,9.468-28.606,16.153-35.265h0c2.035-1.838,4.252-3.546,6.463-5.224h0c6.429-5.655,16.218-2.835,20.358,4.17,4.143,5.057,8.816,9.649,13.92,13.734h.037c5.736,6.461,15.357-2.253,9.38-8.48,0,0-3.515-3.515-3.515-3.515-11.49-11.478-52.656-52.664-64.837-64.837l.049-.037c-1.725-1.606-2.719-3.847-2.751-6.204h0c-.046-2.375,1.062-4.582,2.726-6.229h0l.185-.148h0c.099-.062,.222-.148,.37-.259h0c2.06-1.362,3.951-2.621,6.044-3.842C57.763-3.473,97.76-2.341,128.637,18.332c16.671,9.946-26.344,54.813-38.651,40.199-6.299-6.096-18.063-17.743-19.668-18.811-6.016-4.047-13.061,4.776-7.752,9.751l68.254,68.371c1.724,1.601,2.714,3.84,2.738,6.192Z"/>'; string internal constant HOURGLASS_BACKGROUND_CIRCLE = '<path d="M 50,360 a 300,300 0 1,1 600,0 a 300,300 0 1,1 -600,0" fill="#fff" fill-opacity=".02" stroke="url(#HourglassStroke)" stroke-width="4"/>'; string internal constant HOURGLASS_FILL = '<path d="m566,161.201v-53.924c0-19.382-22.513-37.563-63.398-51.198-40.756-13.592-94.946-21.079-152.587-21.079s-111.838,7.487-152.602,21.079c-40.893,13.636-63.413,31.816-63.413,51.198v53.924c0,17.181,17.704,33.427,50.223,46.394v284.809c-32.519,12.96-50.223,29.206-50.223,46.394v53.924c0,19.382,22.52,37.563,63.413,51.198,40.763,13.592,94.954,21.079,152.602,21.079s111.831-7.487,152.587-21.079c40.886-13.636,63.398-31.816,63.398-51.198v-53.924c0-17.196-17.704-33.435-50.223-46.401V207.603c32.519-12.967,50.223-29.206,50.223-46.401Zm-347.462,57.793l130.959,131.027-130.959,131.013V218.994Zm262.924.022v262.018l-130.937-131.006,130.937-131.013Z" fill="#161822"></path>'; string internal constant HOURGLASS_STROKE = '<g fill="none" stroke="url(#HourglassStroke)" stroke-linecap="round" stroke-miterlimit="10" stroke-width="4"><path d="m565.641,107.28c0,9.537-5.56,18.629-15.676,26.973h-.023c-9.204,7.596-22.194,14.562-38.197,20.592-39.504,14.936-97.325,24.355-161.733,24.355-90.48,0-167.948-18.582-199.953-44.948h-.023c-10.115-8.344-15.676-17.437-15.676-26.973,0-39.735,96.554-71.921,215.652-71.921s215.629,32.185,215.629,71.921Z"/><path d="m134.36,161.203c0,39.735,96.554,71.921,215.652,71.921s215.629-32.186,215.629-71.921"/><line x1="134.36" y1="161.203" x2="134.36" y2="107.28"/><line x1="565.64" y1="161.203" x2="565.64" y2="107.28"/><line x1="184.584" y1="206.823" x2="184.585" y2="537.579"/><line x1="218.181" y1="218.118" x2="218.181" y2="562.537"/><line x1="481.818" y1="218.142" x2="481.819" y2="562.428"/><line x1="515.415" y1="207.352" x2="515.416" y2="537.579"/><path d="m184.58,537.58c0,5.45,4.27,10.65,12.03,15.42h.02c5.51,3.39,12.79,6.55,21.55,9.42,30.21,9.9,78.02,16.28,131.83,16.28,49.41,0,93.76-5.38,124.06-13.92,2.7-.76,5.29-1.54,7.75-2.35,8.77-2.87,16.05-6.04,21.56-9.43h0c7.76-4.77,12.04-9.97,12.04-15.42"/><path d="m184.582,492.656c-31.354,12.485-50.223,28.58-50.223,46.142,0,9.536,5.564,18.627,15.677,26.969h.022c8.503,7.005,20.213,13.463,34.524,19.159,9.999,3.991,21.269,7.609,33.597,10.788,36.45,9.407,82.181,15.002,131.835,15.002s95.363-5.595,131.807-15.002c10.847-2.79,20.867-5.926,29.924-9.349,1.244-.467,2.473-.942,3.673-1.424,14.326-5.696,26.035-12.161,34.524-19.173h.022c10.114-8.342,15.677-17.433,15.677-26.969,0-17.562-18.869-33.665-50.223-46.15"/><path d="m134.36,592.72c0,39.735,96.554,71.921,215.652,71.921s215.629-32.186,215.629-71.921"/><line x1="134.36" y1="592.72" x2="134.36" y2="538.797"/><line x1="565.64" y1="592.72" x2="565.64" y2="538.797"/><polyline points="481.822 481.901 481.798 481.877 481.775 481.854 350.015 350.026 218.185 218.129"/><polyline points="218.185 481.901 218.231 481.854 350.015 350.026 481.822 218.152"/></g>'; string internal constant HOURGLASS_LOWER_BULB_LARGE = '<path d="m481.46,481.54v81.01c-2.35.77-4.82,1.51-7.39,2.23-30.3,8.54-74.65,13.92-124.06,13.92-53.6,0-101.24-6.33-131.47-16.16v-81l46.3-46.31h170.33l46.29,46.31Z" fill="url(#SandBottom)"/><path d="m435.17,435.23c0,1.17-.46,2.32-1.33,3.44-7.11,9.08-41.93,15.98-83.81,15.98s-76.7-6.9-83.82-15.98c-.87-1.12-1.33-2.27-1.33-3.44v-.04l8.34-8.35.01-.01c13.72-6.51,42.95-11.02,76.8-11.02s62.97,4.49,76.72,11l8.42,8.42Z" fill="url(#SandTop)"/>'; string internal constant HOURGLASS_LOWER_BULB_SMALL = '<path d="m481.46,504.101v58.449c-2.35.77-4.82,1.51-7.39,2.23-30.3,8.54-74.65,13.92-124.06,13.92-53.6,0-101.24-6.33-131.47-16.16v-58.439h262.92Z" fill="url(#SandBottom)"/><ellipse cx="350" cy="504.101" rx="131.462" ry="28.108" fill="url(#SandTop)"/>'; string internal constant HOURGLASS_UPPER_BULB = '<polygon points="350 350.026 415.03 284.978 285 284.978 350 350.026" fill="url(#SandBottom)"/><path d="m416.341,281.975c0,.914-.354,1.809-1.035,2.68-5.542,7.076-32.661,12.45-65.28,12.45-32.624,0-59.738-5.374-65.28-12.45-.681-.872-1.035-1.767-1.035-2.68,0-.914.354-1.808,1.035-2.676,5.542-7.076,32.656-12.45,65.28-12.45,32.619,0,59.738,5.374,65.28,12.45.681.867,1.035,1.762,1.035,2.676Z" fill="url(#SandTop)"/>'; string internal constant NOISE = '<filter id="Noise"><feFlood x="0" y="0" width="100%" height="100%" flood-color="hsl(230,21%,11%)" flood-opacity="1" result="floodFill"/><feTurbulence baseFrequency=".4" numOctaves="3" result="Noise" type="fractalNoise"/><feBlend in="Noise" in2="floodFill" mode="soft-light"/></filter>'; /// @dev Escape character for "≥". string internal constant SIGN_GE = "≥"; /// @dev Escape character for ">". string internal constant SIGN_GT = ">"; /// @dev Escape character for "<". string internal constant SIGN_LT = "<"; /*////////////////////////////////////////////////////////////////////////// DATA TYPES //////////////////////////////////////////////////////////////////////////*/ enum CardType { PROGRESS, STATUS, AMOUNT, DURATION } /*////////////////////////////////////////////////////////////////////////// COMPONENTS //////////////////////////////////////////////////////////////////////////*/ function card(CardType cardType, string memory content) internal pure returns (uint256, string memory) { return card({ cardType: cardType, content: content, circle: "" }); } function card( CardType cardType, string memory content, string memory circle ) internal pure returns (uint256 width, string memory card_) { string memory caption = stringifyCardType(cardType); // The progress card can have a fixed width because the content is never longer than the caption. The former // has 6 characters (at most, e.g. "42.09%"), whereas the latter has 8 characters ("Progress"). if (cardType == CardType.PROGRESS) { // The progress can be 0%, in which case the circle is not rendered. if (circle.equal("")) { width = 144; // 2 * 20 (margins) + 8 * 13 (charWidth) } else { width = 208; // 3 * 20 (margins) + 8 * 13 (charWidth) + 44 (diameter) } } // For the other cards, the width is calculated dynamically based on the number of characters. else { uint256 captionWidth = calculatePixelWidth({ text: caption, largeFont: false }); uint256 contentWidth = calculatePixelWidth({ text: content, largeFont: true }); // Use the greater of the two widths, and add the left and the right margin. unchecked { width = Math.max(captionWidth, contentWidth) + 40; } } card_ = string.concat( '<g id="', caption, '" fill="#fff">', '<rect width="', width.toString(), '" height="100" fill-opacity=".03" rx="15" ry="15" stroke="#fff" stroke-opacity=".1" stroke-width="4"/>', '<text x="20" y="34" font-family="\'Courier New\',Arial,monospace" font-size="22px">', caption, "</text>", '<text x="20" y="72" font-family="\'Courier New\',Arial,monospace" font-size="26px">', content, "</text>", circle, "</g>" ); } function floatingText(string memory offset, string memory text) internal pure returns (string memory) { return string.concat( '<textPath startOffset="', offset, '" href="#FloatingText" fill="#fff" font-family="\'Courier New\',Arial,monospace" fill-opacity=".8" font-size="26px">', '<animate additive="sum" attributeName="startOffset" begin="0s" dur="50s" from="0%" repeatCount="indefinite" to="100%"/>', text, "</textPath>" ); } function gradients(string memory accentColor) internal pure returns (string memory) { string memory radialGlow = string.concat( '<radialGradient id="RadialGlow">', '<stop offset="0%" stop-color="', accentColor, '" stop-opacity=".6"/>', '<stop offset="100%" stop-color="', BACKGROUND_COLOR, '" stop-opacity="0"/>', "</radialGradient>" ); string memory sandTop = string.concat( '<linearGradient id="SandTop" x1="0%" y1="0%">', '<stop offset="0%" stop-color="', accentColor, '"/>', '<stop offset="100%" stop-color="', BACKGROUND_COLOR, '"/>', "</linearGradient>" ); string memory sandBottom = string.concat( '<linearGradient id="SandBottom" x1="100%" y1="100%">', '<stop offset="10%" stop-color="', BACKGROUND_COLOR, '"/>', '<stop offset="100%" stop-color="', accentColor, '"/>', '<animate attributeName="x1" dur="6s" repeatCount="indefinite" values="30%;60%;120%;60%;30%;"/>', "</linearGradient>" ); // Needs to be declared last so that the stroke is painted on top of the sand. string memory hourglassStroke = string.concat( '<linearGradient id="HourglassStroke" gradientTransform="rotate(90)" gradientUnits="userSpaceOnUse">', '<stop offset="50%" stop-color="', accentColor, '"/>', '<stop offset="80%" stop-color="', BACKGROUND_COLOR, '"/>', "</linearGradient>" ); return string.concat(radialGlow, sandTop, sandBottom, hourglassStroke); } function hourglass(string memory status) internal pure returns (string memory) { bool settledOrDepleted = status.equal("Settled") || status.equal("Depleted"); return string.concat( '<g id="Hourglass">', HOURGLASS_BACKGROUND_CIRCLE, HOURGLASS_FILL, settledOrDepleted ? "" : HOURGLASS_UPPER_BULB, // empty or filled settledOrDepleted ? HOURGLASS_LOWER_BULB_LARGE : HOURGLASS_LOWER_BULB_SMALL, HOURGLASS_STROKE, // needs to be declared last so that the stroke is painted on top of the sand "</g>" ); } function progressCircle( uint256 progressNumerical, string memory accentColor ) internal pure returns (string memory) { if (progressNumerical == 0) { return ""; } return string.concat( '<g fill="none">', '<circle cx="166" cy="50" r="22" stroke="', BACKGROUND_COLOR, '" stroke-width="10"/>', '<circle cx="166" cy="50" pathLength="10000" r="22" stroke="', accentColor, '" stroke-dasharray="10000" stroke-dashoffset="', (10_000 - progressNumerical).toString(), '" stroke-linecap="round" stroke-width="5" transform="rotate(-90)" transform-origin="166 50"/>', "</g>" ); } /*////////////////////////////////////////////////////////////////////////// HELPERS //////////////////////////////////////////////////////////////////////////*/ /// @notice Calculates the pixel width of the provided string. /// @dev Notes: /// - A factor of ~0.6 is applied to the two font sizes used in the SVG (26px and 22px) to approximate the average /// character width. /// - It is assumed that escaped characters are placed at the beginning of `text`. /// - It is further assumed that there is no other semicolon in `text`. function calculatePixelWidth(string memory text, bool largeFont) internal pure returns (uint256 width) { uint256 length = bytes(text).length; if (length == 0) { return 0; } unchecked { uint256 charWidth = largeFont ? 16 : 13; uint256 semicolonIndex; for (uint256 i = 0; i < length; ++i) { if (bytes(text)[i] == ";") { semicolonIndex = i; } width += charWidth; } // Account for escaped characters (such as ≥). width -= charWidth * semicolonIndex; } } /// @notice Retrieves the card type as a string. function stringifyCardType(CardType cardType) internal pure returns (string memory) { if (cardType == CardType.PROGRESS) { return "Progress"; } else if (cardType == CardType.STATUS) { return "Status"; } else if (cardType == CardType.AMOUNT) { return "Amount"; } else { return "Duration"; } } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.8.22; import { IERC721Metadata } from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol"; /// @title ISablierV2NFTDescriptor /// @notice This contract generates the URI describing the Sablier V2 stream NFTs. /// @dev Inspired by Uniswap V3 Positions NFTs. interface ISablierV2NFTDescriptor { /// @notice Produces the URI describing a particular stream NFT. /// @dev This is a data URI with the JSON contents directly inlined. /// @param sablier The address of the Sablier contract the stream was created in. /// @param streamId The ID of the stream for which to produce a description. /// @return uri The URI of the ERC721-compliant metadata. function tokenURI(IERC721Metadata sablier, uint256 streamId) external view returns (string memory uri); }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.8.22; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { UD2x18 } from "@prb/math/src/UD2x18.sol"; import { UD60x18 } from "@prb/math/src/UD60x18.sol"; // DataTypes.sol // // This file defines all structs used in V2 Core, most of which are organized under three namespaces: // // - Lockup // - LockupDynamic // - LockupLinear // - LockupTranched // // You will notice that some structs contain "slot" annotations - they are used to indicate the // storage layout of the struct. It is more gas efficient to group small data types together so // that they fit in a single 32-byte slot. /// @notice Struct encapsulating the broker parameters passed to the create functions. Both can be set to zero. /// @param account The address receiving the broker's fee. /// @param fee The broker's percentage fee from the total amount, denoted as a fixed-point number where 1e18 is 100%. struct Broker { address account; UD60x18 fee; } /// @notice Namespace for the structs used in both {SablierV2LockupLinear} and {SablierV2LockupDynamic}. library Lockup { /// @notice Struct encapsulating the deposit, withdrawn, and refunded amounts, both denoted in units of the asset's /// decimals. /// @dev Because the deposited and the withdrawn amount are often read together, declaring them in the same slot /// saves gas. /// @param deposited The initial amount deposited in the stream, net of broker fee. /// @param withdrawn The cumulative amount withdrawn from the stream. /// @param refunded The amount refunded to the sender. Unless the stream was canceled, this is always zero. struct Amounts { // slot 0 uint128 deposited; uint128 withdrawn; // slot 1 uint128 refunded; } /// @notice Struct encapsulating the deposit amount and the broker fee amount, both denoted in units of the asset's /// decimals. /// @param deposit The amount to deposit in the stream. /// @param brokerFee The broker fee amount. struct CreateAmounts { uint128 deposit; uint128 brokerFee; } /// @notice Enum representing the different statuses of a stream. /// @custom:value0 PENDING Stream created but not started; assets are in a pending state. /// @custom:value1 STREAMING Active stream where assets are currently being streamed. /// @custom:value2 SETTLED All assets have been streamed; recipient is due to withdraw them. /// @custom:value3 CANCELED Canceled stream; remaining assets await recipient's withdrawal. /// @custom:value4 DEPLETED Depleted stream; all assets have been withdrawn and/or refunded. enum Status { PENDING, STREAMING, SETTLED, CANCELED, DEPLETED } /// @notice A common data structure to be stored in all {SablierV2Lockup} models. /// @dev The fields are arranged like this to save gas via tight variable packing. /// @param sender The address distributing the assets, with the ability to cancel the stream. /// @param startTime The Unix timestamp indicating the stream's start. /// @param endTime The Unix timestamp indicating the stream's end. /// @param isCancelable Boolean indicating if the stream is cancelable. /// @param wasCanceled Boolean indicating if the stream was canceled. /// @param asset The contract address of the ERC-20 asset to be distributed. /// @param isDepleted Boolean indicating if the stream is depleted. /// @param isStream Boolean indicating if the struct entity exists. /// @param isTransferable Boolean indicating if the stream NFT is transferable. /// @param amounts Struct containing the deposit, withdrawn, and refunded amounts, both denoted in units of the /// asset's decimals. struct Stream { // slot 0 address sender; uint40 startTime; uint40 endTime; bool isCancelable; bool wasCanceled; // slot 1 IERC20 asset; bool isDepleted; bool isStream; bool isTransferable; // slot 2 and 3 Lockup.Amounts amounts; } } /// @notice Namespace for the structs used in {SablierV2LockupDynamic}. library LockupDynamic { /// @notice Struct encapsulating the parameters of the {SablierV2LockupDynamic.createWithDurations} function. /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be /// the same as `msg.sender`. /// @param recipient The address receiving the assets. /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any /// broker fee, both denoted in units of the asset's decimals. /// @param asset The contract address of the ERC-20 asset to be distributed. /// @param cancelable Indicates if the stream is cancelable. /// @param transferable Indicates if the stream NFT is transferable. /// @param segments Segments with durations used to compose the dynamic distribution function. Timestamps are /// calculated by starting from `block.timestamp` and adding each duration to the previous timestamp. /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero. struct CreateWithDurations { address sender; address recipient; uint128 totalAmount; IERC20 asset; bool cancelable; bool transferable; SegmentWithDuration[] segments; Broker broker; } /// @notice Struct encapsulating the parameters of the {SablierV2LockupDynamic.createWithTimestamps} function. /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be /// the same as `msg.sender`. /// @param recipient The address receiving the assets. /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any /// broker fee, both denoted in units of the asset's decimals. /// @param asset The contract address of the ERC-20 asset to be distributed. /// @param cancelable Indicates if the stream is cancelable. /// @param transferable Indicates if the stream NFT is transferable. /// @param startTime The Unix timestamp indicating the stream's start. /// @param segments Segments used to compose the dynamic distribution function. /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero. struct CreateWithTimestamps { address sender; address recipient; uint128 totalAmount; IERC20 asset; bool cancelable; bool transferable; uint40 startTime; Segment[] segments; Broker broker; } /// @notice Segment struct used in the Lockup Dynamic stream. /// @param amount The amount of assets to be streamed in the segment, denoted in units of the asset's decimals. /// @param exponent The exponent of the segment, denoted as a fixed-point number. /// @param timestamp The Unix timestamp indicating the segment's end. struct Segment { // slot 0 uint128 amount; UD2x18 exponent; uint40 timestamp; } /// @notice Segment struct used at runtime in {SablierV2LockupDynamic.createWithDurations}. /// @param amount The amount of assets to be streamed in the segment, denoted in units of the asset's decimals. /// @param exponent The exponent of the segment, denoted as a fixed-point number. /// @param duration The time difference in seconds between the segment and the previous one. struct SegmentWithDuration { uint128 amount; UD2x18 exponent; uint40 duration; } /// @notice Struct encapsulating the full details of a stream. /// @dev Extends `Lockup.Stream` by including the recipient and the segments. struct StreamLD { address sender; address recipient; uint40 startTime; uint40 endTime; bool isCancelable; bool wasCanceled; IERC20 asset; bool isDepleted; bool isStream; bool isTransferable; Lockup.Amounts amounts; Segment[] segments; } /// @notice Struct encapsulating the LockupDynamic timestamps. /// @param start The Unix timestamp indicating the stream's start. /// @param end The Unix timestamp indicating the stream's end. struct Timestamps { uint40 start; uint40 end; } } /// @notice Namespace for the structs used in {SablierV2LockupLinear}. library LockupLinear { /// @notice Struct encapsulating the parameters of the {SablierV2LockupLinear.createWithDurations} function. /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be /// the same as `msg.sender`. /// @param recipient The address receiving the assets. /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any /// broker fee, both denoted in units of the asset's decimals. /// @param asset The contract address of the ERC-20 asset to be distributed. /// @param cancelable Indicates if the stream is cancelable. /// @param transferable Indicates if the stream NFT is transferable. /// @param durations Struct containing (i) cliff period duration and (ii) total stream duration, both in seconds. /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero. struct CreateWithDurations { address sender; address recipient; uint128 totalAmount; IERC20 asset; bool cancelable; bool transferable; Durations durations; Broker broker; } /// @notice Struct encapsulating the parameters of the {SablierV2LockupLinear.createWithTimestamps} function. /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be /// the same as `msg.sender`. /// @param recipient The address receiving the assets. /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any /// broker fee, both denoted in units of the asset's decimals. /// @param asset The contract address of the ERC-20 asset to be distributed. /// @param cancelable Indicates if the stream is cancelable. /// @param transferable Indicates if the stream NFT is transferable. /// @param timestamps Struct containing (i) the stream's start time, (ii) cliff time, and (iii) end time, all as /// Unix timestamps. /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero. struct CreateWithTimestamps { address sender; address recipient; uint128 totalAmount; IERC20 asset; bool cancelable; bool transferable; Timestamps timestamps; Broker broker; } /// @notice Struct encapsulating the cliff duration and the total duration. /// @param cliff The cliff duration in seconds. /// @param total The total duration in seconds. struct Durations { uint40 cliff; uint40 total; } /// @notice Struct encapsulating the full details of a stream. /// @dev Extends `Lockup.Stream` by including the recipient and the cliff time. struct StreamLL { address sender; address recipient; uint40 startTime; bool isCancelable; bool wasCanceled; IERC20 asset; uint40 endTime; bool isDepleted; bool isStream; bool isTransferable; Lockup.Amounts amounts; uint40 cliffTime; } /// @notice Struct encapsulating the LockupLinear timestamps. /// @param start The Unix timestamp for the stream's start. /// @param cliff The Unix timestamp for the cliff period's end. A value of zero means there is no cliff. /// @param end The Unix timestamp for the stream's end. struct Timestamps { uint40 start; uint40 cliff; uint40 end; } } /// @notice Namespace for the structs used in {SablierV2LockupTranched}. library LockupTranched { /// @notice Struct encapsulating the parameters of the {SablierV2LockupTranched.createWithDurations} function. /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be /// the same as `msg.sender`. /// @param recipient The address receiving the assets. /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any /// broker fee, both denoted in units of the asset's decimals. /// @param asset The contract address of the ERC-20 asset to be distributed. /// @param cancelable Indicates if the stream is cancelable. /// @param transferable Indicates if the stream NFT is transferable. /// @param tranches Tranches with durations used to compose the tranched distribution function. Timestamps are /// calculated by starting from `block.timestamp` and adding each duration to the previous timestamp. /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero. struct CreateWithDurations { address sender; address recipient; uint128 totalAmount; IERC20 asset; bool cancelable; bool transferable; TrancheWithDuration[] tranches; Broker broker; } /// @notice Struct encapsulating the parameters of the {SablierV2LockupTranched.createWithTimestamps} function. /// @param sender The address distributing the assets, with the ability to cancel the stream. It doesn't have to be /// the same as `msg.sender`. /// @param recipient The address receiving the assets. /// @param totalAmount The total amount of ERC-20 assets to be distributed, including the stream deposit and any /// broker fee, both denoted in units of the asset's decimals. /// @param asset The contract address of the ERC-20 asset to be distributed. /// @param cancelable Indicates if the stream is cancelable. /// @param transferable Indicates if the stream NFT is transferable. /// @param startTime The Unix timestamp indicating the stream's start. /// @param tranches Tranches used to compose the tranched distribution function. /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero. struct CreateWithTimestamps { address sender; address recipient; uint128 totalAmount; IERC20 asset; bool cancelable; bool transferable; uint40 startTime; Tranche[] tranches; Broker broker; } /// @notice Struct encapsulating the full details of a stream. /// @dev Extends `Lockup.Stream` by including the recipient and the tranches. struct StreamLT { address sender; address recipient; uint40 startTime; uint40 endTime; bool isCancelable; bool wasCanceled; IERC20 asset; bool isDepleted; bool isStream; bool isTransferable; Lockup.Amounts amounts; Tranche[] tranches; } /// @notice Struct encapsulating the LockupTranched timestamps. /// @param start The Unix timestamp indicating the stream's start. /// @param end The Unix timestamp indicating the stream's end. struct Timestamps { uint40 start; uint40 end; } /// @notice Tranche struct used in the Lockup Tranched stream. /// @param amount The amount of assets to be unlocked in the tranche, denoted in units of the asset's decimals. /// @param timestamp The Unix timestamp indicating the tranche's end. struct Tranche { // slot 0 uint128 amount; uint40 timestamp; } /// @notice Tranche struct used at runtime in {SablierV2LockupTranched.createWithDurations}. /// @param amount The amount of assets to be unlocked in the tranche, denoted in units of the asset's decimals. /// @param duration The time difference in seconds between the tranche and the previous one. struct TrancheWithDuration { uint128 amount; uint40 duration; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.20; import {IERC721} from "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.2) (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 */ string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /** * @dev Converts a `bytes` to its Bytes64 `string` representation. */ function encode(bytes memory data) internal 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 ""; // Loads the table into memory string memory table = _TABLE; // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter // and split into 4 numbers of 6 bits. // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up // - `data.length + 2` -> Round up // - `/ 3` -> Number of 3-bytes chunks // - `4 *` -> 4 characters for each chunk string memory result = new string(4 * ((data.length + 2) / 3)); /// @solidity memory-safe-assembly assembly { // 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) // 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.0.0) (utils/Strings.sol) pragma solidity ^0.8.20; import {Math} from "./math/Math.sol"; import {SignedMath} from "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant HEX_DIGITS = "0123456789abcdef"; uint8 private constant ADDRESS_LENGTH = 20; /** * @dev The `value` string doesn't fit in the specified `length`. */ error StringsInsufficientHexLength(uint256 value, uint256 length); /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), HEX_DIGITS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toStringSigned(int256 value) internal pure returns (string memory) { return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { uint256 localValue = value; bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = HEX_DIGITS[localValue & 0xf]; localValue >>= 4; } if (localValue != 0) { revert StringsInsufficientHexLength(value, length); } return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal * representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.8.22; /// @title IAdminable /// @notice Contract module that provides a basic access control mechanism, with an admin that can be /// granted exclusive access to specific functions. The inheriting contract must set the initial admin /// in the constructor. interface IAdminable { /*////////////////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////////////////*/ /// @notice Emitted when the admin is transferred. /// @param oldAdmin The address of the old admin. /// @param newAdmin The address of the new admin. event TransferAdmin(address indexed oldAdmin, address indexed newAdmin); /*////////////////////////////////////////////////////////////////////////// CONSTANT FUNCTIONS //////////////////////////////////////////////////////////////////////////*/ /// @notice The address of the admin account or contract. function admin() external view returns (address); /*////////////////////////////////////////////////////////////////////////// NON-CONSTANT FUNCTIONS //////////////////////////////////////////////////////////////////////////*/ /// @notice Transfers the contract admin to a new address. /// /// @dev Notes: /// - Does not revert if the admin is the same. /// - This function can potentially leave the contract without an admin, thereby removing any /// functionality that is only available to the admin. /// /// Requirements: /// - `msg.sender` must be the contract admin. /// /// @param newAdmin The address of the new admin. function transferAdmin(address newAdmin) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC4906.sol) pragma solidity ^0.8.20; import {IERC165} from "./IERC165.sol"; import {IERC721} from "./IERC721.sol"; /// @title EIP-721 Metadata Update Extension interface IERC4906 is IERC165, IERC721 { /// @dev This event emits when the metadata of a token is changed. /// So that the third-party platforms such as NFT market could /// timely update the images and related attributes of the NFT. event MetadataUpdate(uint256 _tokenId); /// @dev This event emits when the metadata of a range of tokens is changed. /// So that the third-party platforms such as NFT market could /// timely update the images and related attributes of the NFTs. event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId); }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.19; /* ██████╗ ██████╗ ██████╗ ███╗ ███╗ █████╗ ████████╗██╗ ██╗ ██╔══██╗██╔══██╗██╔══██╗████╗ ████║██╔══██╗╚══██╔══╝██║ ██║ ██████╔╝██████╔╝██████╔╝██╔████╔██║███████║ ██║ ███████║ ██╔═══╝ ██╔══██╗██╔══██╗██║╚██╔╝██║██╔══██║ ██║ ██╔══██║ ██║ ██║ ██║██████╔╝██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║ ╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ██╗ ██╗██████╗ ██████╗ ██████╗ ██╗ ██╗ ██╗ █████╗ ██║ ██║██╔══██╗██╔════╝ ██╔═████╗╚██╗██╔╝███║██╔══██╗ ██║ ██║██║ ██║███████╗ ██║██╔██║ ╚███╔╝ ╚██║╚█████╔╝ ██║ ██║██║ ██║██╔═══██╗████╔╝██║ ██╔██╗ ██║██╔══██╗ ╚██████╔╝██████╔╝╚██████╔╝╚██████╔╝██╔╝ ██╗ ██║╚█████╔╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚════╝ */ import "./ud60x18/Casting.sol"; import "./ud60x18/Constants.sol"; import "./ud60x18/Conversions.sol"; import "./ud60x18/Errors.sol"; import "./ud60x18/Helpers.sol"; import "./ud60x18/Math.sol"; import "./ud60x18/ValueType.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 value) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol) pragma solidity ^0.8.20; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Muldiv operation overflow. */ error MathOverflowedMulDiv(); enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an overflow flag. */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. return a / b; } // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by * Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. if (denominator <= prod1) { revert MathOverflowedMulDiv(); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. // Always >= 1. See https://cs.stackexchange.com/q/138556/92363. uint256 twos = denominator & (0 - denominator); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also // works in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.19; /* ██████╗ ██████╗ ██████╗ ███╗ ███╗ █████╗ ████████╗██╗ ██╗ ██╔══██╗██╔══██╗██╔══██╗████╗ ████║██╔══██╗╚══██╔══╝██║ ██║ ██████╔╝██████╔╝██████╔╝██╔████╔██║███████║ ██║ ███████║ ██╔═══╝ ██╔══██╗██╔══██╗██║╚██╔╝██║██╔══██║ ██║ ██╔══██║ ██║ ██║ ██║██████╔╝██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║ ╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ██╗ ██╗██████╗ ██████╗ ██╗ ██╗ ██╗ █████╗ ██║ ██║██╔══██╗╚════██╗╚██╗██╔╝███║██╔══██╗ ██║ ██║██║ ██║ █████╔╝ ╚███╔╝ ╚██║╚█████╔╝ ██║ ██║██║ ██║██╔═══╝ ██╔██╗ ██║██╔══██╗ ╚██████╔╝██████╔╝███████╗██╔╝ ██╗ ██║╚█████╔╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚════╝ */ import "./ud2x18/Casting.sol"; import "./ud2x18/Constants.sol"; import "./ud2x18/Errors.sol"; import "./ud2x18/ValueType.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon * a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or * {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon * a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the address zero. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.20; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "../utils/introspection/IERC165.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC721.sol) pragma solidity ^0.8.20; import {IERC721} from "../token/ERC721/IERC721.sol";
// SPDX-License-Identifier: MIT pragma solidity >=0.8.19; import "./Errors.sol" as CastingErrors; import { MAX_UINT128, MAX_UINT40 } from "../Common.sol"; import { uMAX_SD1x18 } from "../sd1x18/Constants.sol"; import { SD1x18 } from "../sd1x18/ValueType.sol"; import { uMAX_SD59x18 } from "../sd59x18/Constants.sol"; import { SD59x18 } from "../sd59x18/ValueType.sol"; import { uMAX_UD2x18 } from "../ud2x18/Constants.sol"; import { UD2x18 } from "../ud2x18/ValueType.sol"; import { UD60x18 } from "./ValueType.sol"; /// @notice Casts a UD60x18 number into SD1x18. /// @dev Requirements: /// - x must be less than or equal to `uMAX_SD1x18`. function intoSD1x18(UD60x18 x) pure returns (SD1x18 result) { uint256 xUint = UD60x18.unwrap(x); if (xUint > uint256(int256(uMAX_SD1x18))) { revert CastingErrors.PRBMath_UD60x18_IntoSD1x18_Overflow(x); } result = SD1x18.wrap(int64(uint64(xUint))); } /// @notice Casts a UD60x18 number into UD2x18. /// @dev Requirements: /// - x must be less than or equal to `uMAX_UD2x18`. function intoUD2x18(UD60x18 x) pure returns (UD2x18 result) { uint256 xUint = UD60x18.unwrap(x); if (xUint > uMAX_UD2x18) { revert CastingErrors.PRBMath_UD60x18_IntoUD2x18_Overflow(x); } result = UD2x18.wrap(uint64(xUint)); } /// @notice Casts a UD60x18 number into SD59x18. /// @dev Requirements: /// - x must be less than or equal to `uMAX_SD59x18`. function intoSD59x18(UD60x18 x) pure returns (SD59x18 result) { uint256 xUint = UD60x18.unwrap(x); if (xUint > uint256(uMAX_SD59x18)) { revert CastingErrors.PRBMath_UD60x18_IntoSD59x18_Overflow(x); } result = SD59x18.wrap(int256(xUint)); } /// @notice Casts a UD60x18 number into uint128. /// @dev This is basically an alias for {unwrap}. function intoUint256(UD60x18 x) pure returns (uint256 result) { result = UD60x18.unwrap(x); } /// @notice Casts a UD60x18 number into uint128. /// @dev Requirements: /// - x must be less than or equal to `MAX_UINT128`. function intoUint128(UD60x18 x) pure returns (uint128 result) { uint256 xUint = UD60x18.unwrap(x); if (xUint > MAX_UINT128) { revert CastingErrors.PRBMath_UD60x18_IntoUint128_Overflow(x); } result = uint128(xUint); } /// @notice Casts a UD60x18 number into uint40. /// @dev Requirements: /// - x must be less than or equal to `MAX_UINT40`. function intoUint40(UD60x18 x) pure returns (uint40 result) { uint256 xUint = UD60x18.unwrap(x); if (xUint > MAX_UINT40) { revert CastingErrors.PRBMath_UD60x18_IntoUint40_Overflow(x); } result = uint40(xUint); } /// @notice Alias for {wrap}. function ud(uint256 x) pure returns (UD60x18 result) { result = UD60x18.wrap(x); } /// @notice Alias for {wrap}. function ud60x18(uint256 x) pure returns (UD60x18 result) { result = UD60x18.wrap(x); } /// @notice Unwraps a UD60x18 number into uint256. function unwrap(UD60x18 x) pure returns (uint256 result) { result = UD60x18.unwrap(x); } /// @notice Wraps a uint256 number into the UD60x18 value type. function wrap(uint256 x) pure returns (UD60x18 result) { result = UD60x18.wrap(x); }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.19; import { uMAX_UD60x18, uUNIT } from "./Constants.sol"; import { PRBMath_UD60x18_Convert_Overflow } from "./Errors.sol"; import { UD60x18 } from "./ValueType.sol"; /// @notice Converts a UD60x18 number to a simple integer by dividing it by `UNIT`. /// @dev The result is rounded toward zero. /// @param x The UD60x18 number to convert. /// @return result The same number in basic integer form. function convert(UD60x18 x) pure returns (uint256 result) { result = UD60x18.unwrap(x) / uUNIT; } /// @notice Converts a simple integer to UD60x18 by multiplying it by `UNIT`. /// /// @dev Requirements: /// - x must be less than or equal to `MAX_UD60x18 / UNIT`. /// /// @param x The basic integer to convert. /// @param result The same number converted to UD60x18. function convert(uint256 x) pure returns (UD60x18 result) { if (x > uMAX_UD60x18 / uUNIT) { revert PRBMath_UD60x18_Convert_Overflow(x); } unchecked { result = UD60x18.wrap(x * uUNIT); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.19; import { UD60x18 } from "./ValueType.sol"; // NOTICE: the "u" prefix stands for "unwrapped". /// @dev Euler's number as a UD60x18 number. UD60x18 constant E = UD60x18.wrap(2_718281828459045235); /// @dev The maximum input permitted in {exp}. uint256 constant uEXP_MAX_INPUT = 133_084258667509499440; UD60x18 constant EXP_MAX_INPUT = UD60x18.wrap(uEXP_MAX_INPUT); /// @dev The maximum input permitted in {exp2}. uint256 constant uEXP2_MAX_INPUT = 192e18 - 1; UD60x18 constant EXP2_MAX_INPUT = UD60x18.wrap(uEXP2_MAX_INPUT); /// @dev Half the UNIT number. uint256 constant uHALF_UNIT = 0.5e18; UD60x18 constant HALF_UNIT = UD60x18.wrap(uHALF_UNIT); /// @dev $log_2(10)$ as a UD60x18 number. uint256 constant uLOG2_10 = 3_321928094887362347; UD60x18 constant LOG2_10 = UD60x18.wrap(uLOG2_10); /// @dev $log_2(e)$ as a UD60x18 number. uint256 constant uLOG2_E = 1_442695040888963407; UD60x18 constant LOG2_E = UD60x18.wrap(uLOG2_E); /// @dev The maximum value a UD60x18 number can have. uint256 constant uMAX_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_584007913129639935; UD60x18 constant MAX_UD60x18 = UD60x18.wrap(uMAX_UD60x18); /// @dev The maximum whole value a UD60x18 number can have. uint256 constant uMAX_WHOLE_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_000000000000000000; UD60x18 constant MAX_WHOLE_UD60x18 = UD60x18.wrap(uMAX_WHOLE_UD60x18); /// @dev PI as a UD60x18 number. UD60x18 constant PI = UD60x18.wrap(3_141592653589793238); /// @dev The unit number, which gives the decimal precision of UD60x18. uint256 constant uUNIT = 1e18; UD60x18 constant UNIT = UD60x18.wrap(uUNIT); /// @dev The unit number squared. uint256 constant uUNIT_SQUARED = 1e36; UD60x18 constant UNIT_SQUARED = UD60x18.wrap(uUNIT_SQUARED); /// @dev Zero as a UD60x18 number. UD60x18 constant ZERO = UD60x18.wrap(0);
// SPDX-License-Identifier: MIT pragma solidity >=0.8.19; import { UD60x18 } from "./ValueType.sol"; /// @notice Thrown when ceiling a number overflows UD60x18. error PRBMath_UD60x18_Ceil_Overflow(UD60x18 x); /// @notice Thrown when converting a basic integer to the fixed-point format overflows UD60x18. error PRBMath_UD60x18_Convert_Overflow(uint256 x); /// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441. error PRBMath_UD60x18_Exp_InputTooBig(UD60x18 x); /// @notice Thrown when taking the binary exponent of a base greater than 192e18. error PRBMath_UD60x18_Exp2_InputTooBig(UD60x18 x); /// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows UD60x18. error PRBMath_UD60x18_Gm_Overflow(UD60x18 x, UD60x18 y); /// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18. error PRBMath_UD60x18_IntoSD1x18_Overflow(UD60x18 x); /// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD59x18. error PRBMath_UD60x18_IntoSD59x18_Overflow(UD60x18 x); /// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18. error PRBMath_UD60x18_IntoUD2x18_Overflow(UD60x18 x); /// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128. error PRBMath_UD60x18_IntoUint128_Overflow(UD60x18 x); /// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40. error PRBMath_UD60x18_IntoUint40_Overflow(UD60x18 x); /// @notice Thrown when taking the logarithm of a number less than 1. error PRBMath_UD60x18_Log_InputTooSmall(UD60x18 x); /// @notice Thrown when calculating the square root overflows UD60x18. error PRBMath_UD60x18_Sqrt_Overflow(UD60x18 x);
// SPDX-License-Identifier: MIT pragma solidity >=0.8.19; import "../Common.sol" as Common; import "./Errors.sol" as Errors; import { wrap } from "./Casting.sol"; import { uEXP_MAX_INPUT, uEXP2_MAX_INPUT, uHALF_UNIT, uLOG2_10, uLOG2_E, uMAX_UD60x18, uMAX_WHOLE_UD60x18, UNIT, uUNIT, uUNIT_SQUARED, ZERO } from "./Constants.sol"; import { UD60x18 } from "./ValueType.sol"; /*////////////////////////////////////////////////////////////////////////// MATHEMATICAL FUNCTIONS //////////////////////////////////////////////////////////////////////////*/ /// @notice Calculates the arithmetic average of x and y using the following formula: /// /// $$ /// avg(x, y) = (x & y) + ((xUint ^ yUint) / 2) /// $$ /// /// In English, this is what this formula does: /// /// 1. AND x and y. /// 2. Calculate half of XOR x and y. /// 3. Add the two results together. /// /// This technique is known as SWAR, which stands for "SIMD within a register". You can read more about it here: /// https://devblogs.microsoft.com/oldnewthing/20220207-00/?p=106223 /// /// @dev Notes: /// - The result is rounded toward zero. /// /// @param x The first operand as a UD60x18 number. /// @param y The second operand as a UD60x18 number. /// @return result The arithmetic average as a UD60x18 number. /// @custom:smtchecker abstract-function-nondet function avg(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) { uint256 xUint = x.unwrap(); uint256 yUint = y.unwrap(); unchecked { result = wrap((xUint & yUint) + ((xUint ^ yUint) >> 1)); } } /// @notice Yields the smallest whole number greater than or equal to x. /// /// @dev This is optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional /// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions. /// /// Requirements: /// - x must be less than or equal to `MAX_WHOLE_UD60x18`. /// /// @param x The UD60x18 number to ceil. /// @param result The smallest whole number greater than or equal to x, as a UD60x18 number. /// @custom:smtchecker abstract-function-nondet function ceil(UD60x18 x) pure returns (UD60x18 result) { uint256 xUint = x.unwrap(); if (xUint > uMAX_WHOLE_UD60x18) { revert Errors.PRBMath_UD60x18_Ceil_Overflow(x); } assembly ("memory-safe") { // Equivalent to `x % UNIT`. let remainder := mod(x, uUNIT) // Equivalent to `UNIT - remainder`. let delta := sub(uUNIT, remainder) // Equivalent to `x + remainder > 0 ? delta : 0`. result := add(x, mul(delta, gt(remainder, 0))) } } /// @notice Divides two UD60x18 numbers, returning a new UD60x18 number. /// /// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division. /// /// Notes: /// - Refer to the notes in {Common.mulDiv}. /// /// Requirements: /// - Refer to the requirements in {Common.mulDiv}. /// /// @param x The numerator as a UD60x18 number. /// @param y The denominator as a UD60x18 number. /// @param result The quotient as a UD60x18 number. /// @custom:smtchecker abstract-function-nondet function div(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) { result = wrap(Common.mulDiv(x.unwrap(), uUNIT, y.unwrap())); } /// @notice Calculates the natural exponent of x using the following formula: /// /// $$ /// e^x = 2^{x * log_2{e}} /// $$ /// /// @dev Requirements: /// - x must be less than 133_084258667509499441. /// /// @param x The exponent as a UD60x18 number. /// @return result The result as a UD60x18 number. /// @custom:smtchecker abstract-function-nondet function exp(UD60x18 x) pure returns (UD60x18 result) { uint256 xUint = x.unwrap(); // This check prevents values greater than 192e18 from being passed to {exp2}. if (xUint > uEXP_MAX_INPUT) { revert Errors.PRBMath_UD60x18_Exp_InputTooBig(x); } unchecked { // Inline the fixed-point multiplication to save gas. uint256 doubleUnitProduct = xUint * uLOG2_E; result = exp2(wrap(doubleUnitProduct / uUNIT)); } } /// @notice Calculates the binary exponent of x using the binary fraction method. /// /// @dev See https://ethereum.stackexchange.com/q/79903/24693 /// /// Requirements: /// - x must be less than 192e18. /// - The result must fit in UD60x18. /// /// @param x The exponent as a UD60x18 number. /// @return result The result as a UD60x18 number. /// @custom:smtchecker abstract-function-nondet function exp2(UD60x18 x) pure returns (UD60x18 result) { uint256 xUint = x.unwrap(); // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format. if (xUint > uEXP2_MAX_INPUT) { revert Errors.PRBMath_UD60x18_Exp2_InputTooBig(x); } // Convert x to the 192.64-bit fixed-point format. uint256 x_192x64 = (xUint << 64) / uUNIT; // Pass x to the {Common.exp2} function, which uses the 192.64-bit fixed-point number representation. result = wrap(Common.exp2(x_192x64)); } /// @notice Yields the greatest whole number less than or equal to x. /// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts. /// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions. /// @param x The UD60x18 number to floor. /// @param result The greatest whole number less than or equal to x, as a UD60x18 number. /// @custom:smtchecker abstract-function-nondet function floor(UD60x18 x) pure returns (UD60x18 result) { assembly ("memory-safe") { // Equivalent to `x % UNIT`. let remainder := mod(x, uUNIT) // Equivalent to `x - remainder > 0 ? remainder : 0)`. result := sub(x, mul(remainder, gt(remainder, 0))) } } /// @notice Yields the excess beyond the floor of x using the odd function definition. /// @dev See https://en.wikipedia.org/wiki/Fractional_part. /// @param x The UD60x18 number to get the fractional part of. /// @param result The fractional part of x as a UD60x18 number. /// @custom:smtchecker abstract-function-nondet function frac(UD60x18 x) pure returns (UD60x18 result) { assembly ("memory-safe") { result := mod(x, uUNIT) } } /// @notice Calculates the geometric mean of x and y, i.e. $\sqrt{x * y}$, rounding down. /// /// @dev Requirements: /// - x * y must fit in UD60x18. /// /// @param x The first operand as a UD60x18 number. /// @param y The second operand as a UD60x18 number. /// @return result The result as a UD60x18 number. /// @custom:smtchecker abstract-function-nondet function gm(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) { uint256 xUint = x.unwrap(); uint256 yUint = y.unwrap(); if (xUint == 0 || yUint == 0) { return ZERO; } unchecked { // Checking for overflow this way is faster than letting Solidity do it. uint256 xyUint = xUint * yUint; if (xyUint / xUint != yUint) { revert Errors.PRBMath_UD60x18_Gm_Overflow(x, y); } // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT` // during multiplication. See the comments in {Common.sqrt}. result = wrap(Common.sqrt(xyUint)); } } /// @notice Calculates the inverse of x. /// /// @dev Notes: /// - The result is rounded toward zero. /// /// Requirements: /// - x must not be zero. /// /// @param x The UD60x18 number for which to calculate the inverse. /// @return result The inverse as a UD60x18 number. /// @custom:smtchecker abstract-function-nondet function inv(UD60x18 x) pure returns (UD60x18 result) { unchecked { result = wrap(uUNIT_SQUARED / x.unwrap()); } } /// @notice Calculates the natural logarithm of x using the following formula: /// /// $$ /// ln{x} = log_2{x} / log_2{e} /// $$ /// /// @dev Notes: /// - Refer to the notes in {log2}. /// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`. /// /// Requirements: /// - Refer to the requirements in {log2}. /// /// @param x The UD60x18 number for which to calculate the natural logarithm. /// @return result The natural logarithm as a UD60x18 number. /// @custom:smtchecker abstract-function-nondet function ln(UD60x18 x) pure returns (UD60x18 result) { unchecked { // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that // {log2} can return is ~196_205294292027477728. result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E); } } /// @notice Calculates the common logarithm of x using the following formula: /// /// $$ /// log_{10}{x} = log_2{x} / log_2{10} /// $$ /// /// However, if x is an exact power of ten, a hard coded value is returned. /// /// @dev Notes: /// - Refer to the notes in {log2}. /// /// Requirements: /// - Refer to the requirements in {log2}. /// /// @param x The UD60x18 number for which to calculate the common logarithm. /// @return result The common logarithm as a UD60x18 number. /// @custom:smtchecker abstract-function-nondet function log10(UD60x18 x) pure returns (UD60x18 result) { uint256 xUint = x.unwrap(); if (xUint < uUNIT) { revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x); } // Note that the `mul` in this assembly block is the standard multiplication operation, not {UD60x18.mul}. // prettier-ignore assembly ("memory-safe") { switch x case 1 { result := mul(uUNIT, sub(0, 18)) } case 10 { result := mul(uUNIT, sub(1, 18)) } case 100 { result := mul(uUNIT, sub(2, 18)) } case 1000 { result := mul(uUNIT, sub(3, 18)) } case 10000 { result := mul(uUNIT, sub(4, 18)) } case 100000 { result := mul(uUNIT, sub(5, 18)) } case 1000000 { result := mul(uUNIT, sub(6, 18)) } case 10000000 { result := mul(uUNIT, sub(7, 18)) } case 100000000 { result := mul(uUNIT, sub(8, 18)) } case 1000000000 { result := mul(uUNIT, sub(9, 18)) } case 10000000000 { result := mul(uUNIT, sub(10, 18)) } case 100000000000 { result := mul(uUNIT, sub(11, 18)) } case 1000000000000 { result := mul(uUNIT, sub(12, 18)) } case 10000000000000 { result := mul(uUNIT, sub(13, 18)) } case 100000000000000 { result := mul(uUNIT, sub(14, 18)) } case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) } case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) } case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) } case 1000000000000000000 { result := 0 } case 10000000000000000000 { result := uUNIT } case 100000000000000000000 { result := mul(uUNIT, 2) } case 1000000000000000000000 { result := mul(uUNIT, 3) } case 10000000000000000000000 { result := mul(uUNIT, 4) } case 100000000000000000000000 { result := mul(uUNIT, 5) } case 1000000000000000000000000 { result := mul(uUNIT, 6) } case 10000000000000000000000000 { result := mul(uUNIT, 7) } case 100000000000000000000000000 { result := mul(uUNIT, 8) } case 1000000000000000000000000000 { result := mul(uUNIT, 9) } case 10000000000000000000000000000 { result := mul(uUNIT, 10) } case 100000000000000000000000000000 { result := mul(uUNIT, 11) } case 1000000000000000000000000000000 { result := mul(uUNIT, 12) } case 10000000000000000000000000000000 { result := mul(uUNIT, 13) } case 100000000000000000000000000000000 { result := mul(uUNIT, 14) } case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) } case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) } case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) } case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) } case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) } case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) } case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) } case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) } case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) } case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) } case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) } case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) } case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) } case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) } case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) } case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) } case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) } case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) } case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) } case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) } case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) } case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) } case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) } case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) } case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) } case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) } case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) } case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) } case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) } case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) } case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) } case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) } case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) } case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) } case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) } case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) } case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) } case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) } case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) } case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) } case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) } case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) } case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) } case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) } case 100000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 59) } default { result := uMAX_UD60x18 } } if (result.unwrap() == uMAX_UD60x18) { unchecked { // Inline the fixed-point division to save gas. result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10); } } } /// @notice Calculates the binary logarithm of x using the iterative approximation algorithm: /// /// $$ /// log_2{x} = n + log_2{y}, \text{ where } y = x*2^{-n}, \ y \in [1, 2) /// $$ /// /// For $0 \leq x \lt 1$, the input is inverted: /// /// $$ /// log_2{x} = -log_2{\frac{1}{x}} /// $$ /// /// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation /// /// Notes: /// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal. /// /// Requirements: /// - x must be greater than zero. /// /// @param x The UD60x18 number for which to calculate the binary logarithm. /// @return result The binary logarithm as a UD60x18 number. /// @custom:smtchecker abstract-function-nondet function log2(UD60x18 x) pure returns (UD60x18 result) { uint256 xUint = x.unwrap(); if (xUint < uUNIT) { revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x); } unchecked { // Calculate the integer part of the logarithm. uint256 n = Common.msb(xUint / uUNIT); // This is the integer part of the logarithm as a UD60x18 number. The operation can't overflow because n // n is at most 255 and UNIT is 1e18. uint256 resultUint = n * uUNIT; // Calculate $y = x * 2^{-n}$. uint256 y = xUint >> n; // If y is the unit number, the fractional part is zero. if (y == uUNIT) { return wrap(resultUint); } // Calculate the fractional part via the iterative approximation. // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient. uint256 DOUBLE_UNIT = 2e18; for (uint256 delta = uHALF_UNIT; delta > 0; delta >>= 1) { y = (y * y) / uUNIT; // Is y^2 >= 2e18 and so in the range [2e18, 4e18)? if (y >= DOUBLE_UNIT) { // Add the 2^{-m} factor to the logarithm. resultUint += delta; // Halve y, which corresponds to z/2 in the Wikipedia article. y >>= 1; } } result = wrap(resultUint); } } /// @notice Multiplies two UD60x18 numbers together, returning a new UD60x18 number. /// /// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division. /// /// Notes: /// - Refer to the notes in {Common.mulDiv}. /// /// Requirements: /// - Refer to the requirements in {Common.mulDiv}. /// /// @dev See the documentation in {Common.mulDiv18}. /// @param x The multiplicand as a UD60x18 number. /// @param y The multiplier as a UD60x18 number. /// @return result The product as a UD60x18 number. /// @custom:smtchecker abstract-function-nondet function mul(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) { result = wrap(Common.mulDiv18(x.unwrap(), y.unwrap())); } /// @notice Raises x to the power of y. /// /// For $1 \leq x \leq \infty$, the following standard formula is used: /// /// $$ /// x^y = 2^{log_2{x} * y} /// $$ /// /// For $0 \leq x \lt 1$, since the unsigned {log2} is undefined, an equivalent formula is used: /// /// $$ /// i = \frac{1}{x} /// w = 2^{log_2{i} * y} /// x^y = \frac{1}{w} /// $$ /// /// @dev Notes: /// - Refer to the notes in {log2} and {mul}. /// - Returns `UNIT` for 0^0. /// - It may not perform well with very small values of x. Consider using SD59x18 as an alternative. /// /// Requirements: /// - Refer to the requirements in {exp2}, {log2}, and {mul}. /// /// @param x The base as a UD60x18 number. /// @param y The exponent as a UD60x18 number. /// @return result The result as a UD60x18 number. /// @custom:smtchecker abstract-function-nondet function pow(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) { uint256 xUint = x.unwrap(); uint256 yUint = y.unwrap(); // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero. if (xUint == 0) { return yUint == 0 ? UNIT : ZERO; } // If x is `UNIT`, the result is always `UNIT`. else if (xUint == uUNIT) { return UNIT; } // If y is zero, the result is always `UNIT`. if (yUint == 0) { return UNIT; } // If y is `UNIT`, the result is always x. else if (yUint == uUNIT) { return x; } // If x is greater than `UNIT`, use the standard formula. if (xUint > uUNIT) { result = exp2(mul(log2(x), y)); } // Conversely, if x is less than `UNIT`, use the equivalent formula. else { UD60x18 i = wrap(uUNIT_SQUARED / xUint); UD60x18 w = exp2(mul(log2(i), y)); result = wrap(uUNIT_SQUARED / w.unwrap()); } } /// @notice Raises x (a UD60x18 number) to the power y (an unsigned basic integer) using the well-known /// algorithm "exponentiation by squaring". /// /// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring. /// /// Notes: /// - Refer to the notes in {Common.mulDiv18}. /// - Returns `UNIT` for 0^0. /// /// Requirements: /// - The result must fit in UD60x18. /// /// @param x The base as a UD60x18 number. /// @param y The exponent as a uint256. /// @return result The result as a UD60x18 number. /// @custom:smtchecker abstract-function-nondet function powu(UD60x18 x, uint256 y) pure returns (UD60x18 result) { // Calculate the first iteration of the loop in advance. uint256 xUint = x.unwrap(); uint256 resultUint = y & 1 > 0 ? xUint : uUNIT; // Equivalent to `for(y /= 2; y > 0; y /= 2)`. for (y >>= 1; y > 0; y >>= 1) { xUint = Common.mulDiv18(xUint, xUint); // Equivalent to `y % 2 == 1`. if (y & 1 > 0) { resultUint = Common.mulDiv18(resultUint, xUint); } } result = wrap(resultUint); } /// @notice Calculates the square root of x using the Babylonian method. /// /// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method. /// /// Notes: /// - The result is rounded toward zero. /// /// Requirements: /// - x must be less than `MAX_UD60x18 / UNIT`. /// /// @param x The UD60x18 number for which to calculate the square root. /// @return result The result as a UD60x18 number. /// @custom:smtchecker abstract-function-nondet function sqrt(UD60x18 x) pure returns (UD60x18 result) { uint256 xUint = x.unwrap(); unchecked { if (xUint > uMAX_UD60x18 / uUNIT) { revert Errors.PRBMath_UD60x18_Sqrt_Overflow(x); } // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two UD60x18 numbers. // In this case, the two numbers are both the square root. result = wrap(Common.sqrt(xUint * uUNIT)); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.19; import "./Casting.sol" as Casting; import "./Helpers.sol" as Helpers; import "./Math.sol" as Math; /// @notice The unsigned 60.18-decimal fixed-point number representation, which can have up to 60 digits and up to 18 /// decimals. The values of this are bound by the minimum and the maximum values permitted by the Solidity type uint256. /// @dev The value type is defined here so it can be imported in all other files. type UD60x18 is uint256; /*////////////////////////////////////////////////////////////////////////// CASTING //////////////////////////////////////////////////////////////////////////*/ using { Casting.intoSD1x18, Casting.intoUD2x18, Casting.intoSD59x18, Casting.intoUint128, Casting.intoUint256, Casting.intoUint40, Casting.unwrap } for UD60x18 global; /*////////////////////////////////////////////////////////////////////////// MATHEMATICAL FUNCTIONS //////////////////////////////////////////////////////////////////////////*/ // The global "using for" directive makes the functions in this library callable on the UD60x18 type. using { Math.avg, Math.ceil, Math.div, Math.exp, Math.exp2, Math.floor, Math.frac, Math.gm, Math.inv, Math.ln, Math.log10, Math.log2, Math.mul, Math.pow, Math.powu, Math.sqrt } for UD60x18 global; /*////////////////////////////////////////////////////////////////////////// HELPER FUNCTIONS //////////////////////////////////////////////////////////////////////////*/ // The global "using for" directive makes the functions in this library callable on the UD60x18 type. using { Helpers.add, Helpers.and, Helpers.eq, Helpers.gt, Helpers.gte, Helpers.isZero, Helpers.lshift, Helpers.lt, Helpers.lte, Helpers.mod, Helpers.neq, Helpers.not, Helpers.or, Helpers.rshift, Helpers.sub, Helpers.uncheckedAdd, Helpers.uncheckedSub, Helpers.xor } for UD60x18 global; /*////////////////////////////////////////////////////////////////////////// OPERATORS //////////////////////////////////////////////////////////////////////////*/ // The global "using for" directive makes it possible to use these operators on the UD60x18 type. using { Helpers.add as +, Helpers.and2 as &, Math.div as /, Helpers.eq as ==, Helpers.gt as >, Helpers.gte as >=, Helpers.lt as <, Helpers.lte as <=, Helpers.or as |, Helpers.mod as %, Math.mul as *, Helpers.neq as !=, Helpers.not as ~, Helpers.sub as -, Helpers.xor as ^ } for UD60x18 global;
// SPDX-License-Identifier: MIT pragma solidity >=0.8.19; import { wrap } from "./Casting.sol"; import { UD60x18 } from "./ValueType.sol"; /// @notice Implements the checked addition operation (+) in the UD60x18 type. function add(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) { result = wrap(x.unwrap() + y.unwrap()); } /// @notice Implements the AND (&) bitwise operation in the UD60x18 type. function and(UD60x18 x, uint256 bits) pure returns (UD60x18 result) { result = wrap(x.unwrap() & bits); } /// @notice Implements the AND (&) bitwise operation in the UD60x18 type. function and2(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) { result = wrap(x.unwrap() & y.unwrap()); } /// @notice Implements the equal operation (==) in the UD60x18 type. function eq(UD60x18 x, UD60x18 y) pure returns (bool result) { result = x.unwrap() == y.unwrap(); } /// @notice Implements the greater than operation (>) in the UD60x18 type. function gt(UD60x18 x, UD60x18 y) pure returns (bool result) { result = x.unwrap() > y.unwrap(); } /// @notice Implements the greater than or equal to operation (>=) in the UD60x18 type. function gte(UD60x18 x, UD60x18 y) pure returns (bool result) { result = x.unwrap() >= y.unwrap(); } /// @notice Implements a zero comparison check function in the UD60x18 type. function isZero(UD60x18 x) pure returns (bool result) { // This wouldn't work if x could be negative. result = x.unwrap() == 0; } /// @notice Implements the left shift operation (<<) in the UD60x18 type. function lshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) { result = wrap(x.unwrap() << bits); } /// @notice Implements the lower than operation (<) in the UD60x18 type. function lt(UD60x18 x, UD60x18 y) pure returns (bool result) { result = x.unwrap() < y.unwrap(); } /// @notice Implements the lower than or equal to operation (<=) in the UD60x18 type. function lte(UD60x18 x, UD60x18 y) pure returns (bool result) { result = x.unwrap() <= y.unwrap(); } /// @notice Implements the checked modulo operation (%) in the UD60x18 type. function mod(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) { result = wrap(x.unwrap() % y.unwrap()); } /// @notice Implements the not equal operation (!=) in the UD60x18 type. function neq(UD60x18 x, UD60x18 y) pure returns (bool result) { result = x.unwrap() != y.unwrap(); } /// @notice Implements the NOT (~) bitwise operation in the UD60x18 type. function not(UD60x18 x) pure returns (UD60x18 result) { result = wrap(~x.unwrap()); } /// @notice Implements the OR (|) bitwise operation in the UD60x18 type. function or(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) { result = wrap(x.unwrap() | y.unwrap()); } /// @notice Implements the right shift operation (>>) in the UD60x18 type. function rshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) { result = wrap(x.unwrap() >> bits); } /// @notice Implements the checked subtraction operation (-) in the UD60x18 type. function sub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) { result = wrap(x.unwrap() - y.unwrap()); } /// @notice Implements the unchecked addition operation (+) in the UD60x18 type. function uncheckedAdd(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) { unchecked { result = wrap(x.unwrap() + y.unwrap()); } } /// @notice Implements the unchecked subtraction operation (-) in the UD60x18 type. function uncheckedSub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) { unchecked { result = wrap(x.unwrap() - y.unwrap()); } } /// @notice Implements the XOR (^) bitwise operation in the UD60x18 type. function xor(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) { result = wrap(x.unwrap() ^ y.unwrap()); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.19; import "../Common.sol" as Common; import "./Errors.sol" as Errors; import { uMAX_SD1x18 } from "../sd1x18/Constants.sol"; import { SD1x18 } from "../sd1x18/ValueType.sol"; import { SD59x18 } from "../sd59x18/ValueType.sol"; import { UD60x18 } from "../ud60x18/ValueType.sol"; import { UD2x18 } from "./ValueType.sol"; /// @notice Casts a UD2x18 number into SD1x18. /// - x must be less than or equal to `uMAX_SD1x18`. function intoSD1x18(UD2x18 x) pure returns (SD1x18 result) { uint64 xUint = UD2x18.unwrap(x); if (xUint > uint64(uMAX_SD1x18)) { revert Errors.PRBMath_UD2x18_IntoSD1x18_Overflow(x); } result = SD1x18.wrap(int64(xUint)); } /// @notice Casts a UD2x18 number into SD59x18. /// @dev There is no overflow check because the domain of UD2x18 is a subset of SD59x18. function intoSD59x18(UD2x18 x) pure returns (SD59x18 result) { result = SD59x18.wrap(int256(uint256(UD2x18.unwrap(x)))); } /// @notice Casts a UD2x18 number into UD60x18. /// @dev There is no overflow check because the domain of UD2x18 is a subset of UD60x18. function intoUD60x18(UD2x18 x) pure returns (UD60x18 result) { result = UD60x18.wrap(UD2x18.unwrap(x)); } /// @notice Casts a UD2x18 number into uint128. /// @dev There is no overflow check because the domain of UD2x18 is a subset of uint128. function intoUint128(UD2x18 x) pure returns (uint128 result) { result = uint128(UD2x18.unwrap(x)); } /// @notice Casts a UD2x18 number into uint256. /// @dev There is no overflow check because the domain of UD2x18 is a subset of uint256. function intoUint256(UD2x18 x) pure returns (uint256 result) { result = uint256(UD2x18.unwrap(x)); } /// @notice Casts a UD2x18 number into uint40. /// @dev Requirements: /// - x must be less than or equal to `MAX_UINT40`. function intoUint40(UD2x18 x) pure returns (uint40 result) { uint64 xUint = UD2x18.unwrap(x); if (xUint > uint64(Common.MAX_UINT40)) { revert Errors.PRBMath_UD2x18_IntoUint40_Overflow(x); } result = uint40(xUint); } /// @notice Alias for {wrap}. function ud2x18(uint64 x) pure returns (UD2x18 result) { result = UD2x18.wrap(x); } /// @notice Unwrap a UD2x18 number into uint64. function unwrap(UD2x18 x) pure returns (uint64 result) { result = UD2x18.unwrap(x); } /// @notice Wraps a uint64 number into UD2x18. function wrap(uint64 x) pure returns (UD2x18 result) { result = UD2x18.wrap(x); }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.19; import { UD2x18 } from "./ValueType.sol"; /// @dev Euler's number as a UD2x18 number. UD2x18 constant E = UD2x18.wrap(2_718281828459045235); /// @dev The maximum value a UD2x18 number can have. uint64 constant uMAX_UD2x18 = 18_446744073709551615; UD2x18 constant MAX_UD2x18 = UD2x18.wrap(uMAX_UD2x18); /// @dev PI as a UD2x18 number. UD2x18 constant PI = UD2x18.wrap(3_141592653589793238); /// @dev The unit number, which gives the decimal precision of UD2x18. UD2x18 constant UNIT = UD2x18.wrap(1e18); uint64 constant uUNIT = 1e18;
// SPDX-License-Identifier: MIT pragma solidity >=0.8.19; import "./Casting.sol" as Casting; /// @notice The unsigned 2.18-decimal fixed-point number representation, which can have up to 2 digits and up to 18 /// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity /// type uint64. This is useful when end users want to use uint64 to save gas, e.g. with tight variable packing in contract /// storage. type UD2x18 is uint64; /*////////////////////////////////////////////////////////////////////////// CASTING //////////////////////////////////////////////////////////////////////////*/ using { Casting.intoSD1x18, Casting.intoSD59x18, Casting.intoUD60x18, Casting.intoUint256, Casting.intoUint128, Casting.intoUint40, Casting.unwrap } for UD2x18 global;
// SPDX-License-Identifier: MIT pragma solidity >=0.8.19; import { UD2x18 } from "./ValueType.sol"; /// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in SD1x18. error PRBMath_UD2x18_IntoSD1x18_Overflow(UD2x18 x); /// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in uint40. error PRBMath_UD2x18_IntoUint40_Overflow(UD2x18 x);
// SPDX-License-Identifier: MIT pragma solidity >=0.8.19; // Common.sol // // Common mathematical functions used in both SD59x18 and UD60x18. Note that these global functions do not // always operate with SD59x18 and UD60x18 numbers. /*////////////////////////////////////////////////////////////////////////// CUSTOM ERRORS //////////////////////////////////////////////////////////////////////////*/ /// @notice Thrown when the resultant value in {mulDiv} overflows uint256. error PRBMath_MulDiv_Overflow(uint256 x, uint256 y, uint256 denominator); /// @notice Thrown when the resultant value in {mulDiv18} overflows uint256. error PRBMath_MulDiv18_Overflow(uint256 x, uint256 y); /// @notice Thrown when one of the inputs passed to {mulDivSigned} is `type(int256).min`. error PRBMath_MulDivSigned_InputTooSmall(); /// @notice Thrown when the resultant value in {mulDivSigned} overflows int256. error PRBMath_MulDivSigned_Overflow(int256 x, int256 y); /*////////////////////////////////////////////////////////////////////////// CONSTANTS //////////////////////////////////////////////////////////////////////////*/ /// @dev The maximum value a uint128 number can have. uint128 constant MAX_UINT128 = type(uint128).max; /// @dev The maximum value a uint40 number can have. uint40 constant MAX_UINT40 = type(uint40).max; /// @dev The unit number, which the decimal precision of the fixed-point types. uint256 constant UNIT = 1e18; /// @dev The unit number inverted mod 2^256. uint256 constant UNIT_INVERSE = 78156646155174841979727994598816262306175212592076161876661_508869554232690281; /// @dev The the largest power of two that divides the decimal value of `UNIT`. The logarithm of this value is the least significant /// bit in the binary representation of `UNIT`. uint256 constant UNIT_LPOTD = 262144; /*////////////////////////////////////////////////////////////////////////// FUNCTIONS //////////////////////////////////////////////////////////////////////////*/ /// @notice Calculates the binary exponent of x using the binary fraction method. /// @dev Has to use 192.64-bit fixed-point numbers. See https://ethereum.stackexchange.com/a/96594/24693. /// @param x The exponent as an unsigned 192.64-bit fixed-point number. /// @return result The result as an unsigned 60.18-decimal fixed-point number. /// @custom:smtchecker abstract-function-nondet function exp2(uint256 x) pure returns (uint256 result) { unchecked { // Start from 0.5 in the 192.64-bit fixed-point format. result = 0x800000000000000000000000000000000000000000000000; // The following logic multiplies the result by $\sqrt{2^{-i}}$ when the bit at position i is 1. Key points: // // 1. Intermediate results will not overflow, as the starting point is 2^191 and all magic factors are under 2^65. // 2. The rationale for organizing the if statements into groups of 8 is gas savings. If the result of performing // a bitwise AND operation between x and any value in the array [0x80; 0x40; 0x20; 0x10; 0x08; 0x04; 0x02; 0x01] is 1, // we know that `x & 0xFF` is also 1. if (x & 0xFF00000000000000 > 0) { if (x & 0x8000000000000000 > 0) { result = (result * 0x16A09E667F3BCC909) >> 64; } if (x & 0x4000000000000000 > 0) { result = (result * 0x1306FE0A31B7152DF) >> 64; } if (x & 0x2000000000000000 > 0) { result = (result * 0x1172B83C7D517ADCE) >> 64; } if (x & 0x1000000000000000 > 0) { result = (result * 0x10B5586CF9890F62A) >> 64; } if (x & 0x800000000000000 > 0) { result = (result * 0x1059B0D31585743AE) >> 64; } if (x & 0x400000000000000 > 0) { result = (result * 0x102C9A3E778060EE7) >> 64; } if (x & 0x200000000000000 > 0) { result = (result * 0x10163DA9FB33356D8) >> 64; } if (x & 0x100000000000000 > 0) { result = (result * 0x100B1AFA5ABCBED61) >> 64; } } if (x & 0xFF000000000000 > 0) { if (x & 0x80000000000000 > 0) { result = (result * 0x10058C86DA1C09EA2) >> 64; } if (x & 0x40000000000000 > 0) { result = (result * 0x1002C605E2E8CEC50) >> 64; } if (x & 0x20000000000000 > 0) { result = (result * 0x100162F3904051FA1) >> 64; } if (x & 0x10000000000000 > 0) { result = (result * 0x1000B175EFFDC76BA) >> 64; } if (x & 0x8000000000000 > 0) { result = (result * 0x100058BA01FB9F96D) >> 64; } if (x & 0x4000000000000 > 0) { result = (result * 0x10002C5CC37DA9492) >> 64; } if (x & 0x2000000000000 > 0) { result = (result * 0x1000162E525EE0547) >> 64; } if (x & 0x1000000000000 > 0) { result = (result * 0x10000B17255775C04) >> 64; } } if (x & 0xFF0000000000 > 0) { if (x & 0x800000000000 > 0) { result = (result * 0x1000058B91B5BC9AE) >> 64; } if (x & 0x400000000000 > 0) { result = (result * 0x100002C5C89D5EC6D) >> 64; } if (x & 0x200000000000 > 0) { result = (result * 0x10000162E43F4F831) >> 64; } if (x & 0x100000000000 > 0) { result = (result * 0x100000B1721BCFC9A) >> 64; } if (x & 0x80000000000 > 0) { result = (result * 0x10000058B90CF1E6E) >> 64; } if (x & 0x40000000000 > 0) { result = (result * 0x1000002C5C863B73F) >> 64; } if (x & 0x20000000000 > 0) { result = (result * 0x100000162E430E5A2) >> 64; } if (x & 0x10000000000 > 0) { result = (result * 0x1000000B172183551) >> 64; } } if (x & 0xFF00000000 > 0) { if (x & 0x8000000000 > 0) { result = (result * 0x100000058B90C0B49) >> 64; } if (x & 0x4000000000 > 0) { result = (result * 0x10000002C5C8601CC) >> 64; } if (x & 0x2000000000 > 0) { result = (result * 0x1000000162E42FFF0) >> 64; } if (x & 0x1000000000 > 0) { result = (result * 0x10000000B17217FBB) >> 64; } if (x & 0x800000000 > 0) { result = (result * 0x1000000058B90BFCE) >> 64; } if (x & 0x400000000 > 0) { result = (result * 0x100000002C5C85FE3) >> 64; } if (x & 0x200000000 > 0) { result = (result * 0x10000000162E42FF1) >> 64; } if (x & 0x100000000 > 0) { result = (result * 0x100000000B17217F8) >> 64; } } if (x & 0xFF000000 > 0) { if (x & 0x80000000 > 0) { result = (result * 0x10000000058B90BFC) >> 64; } if (x & 0x40000000 > 0) { result = (result * 0x1000000002C5C85FE) >> 64; } if (x & 0x20000000 > 0) { result = (result * 0x100000000162E42FF) >> 64; } if (x & 0x10000000 > 0) { result = (result * 0x1000000000B17217F) >> 64; } if (x & 0x8000000 > 0) { result = (result * 0x100000000058B90C0) >> 64; } if (x & 0x4000000 > 0) { result = (result * 0x10000000002C5C860) >> 64; } if (x & 0x2000000 > 0) { result = (result * 0x1000000000162E430) >> 64; } if (x & 0x1000000 > 0) { result = (result * 0x10000000000B17218) >> 64; } } if (x & 0xFF0000 > 0) { if (x & 0x800000 > 0) { result = (result * 0x1000000000058B90C) >> 64; } if (x & 0x400000 > 0) { result = (result * 0x100000000002C5C86) >> 64; } if (x & 0x200000 > 0) { result = (result * 0x10000000000162E43) >> 64; } if (x & 0x100000 > 0) { result = (result * 0x100000000000B1721) >> 64; } if (x & 0x80000 > 0) { result = (result * 0x10000000000058B91) >> 64; } if (x & 0x40000 > 0) { result = (result * 0x1000000000002C5C8) >> 64; } if (x & 0x20000 > 0) { result = (result * 0x100000000000162E4) >> 64; } if (x & 0x10000 > 0) { result = (result * 0x1000000000000B172) >> 64; } } if (x & 0xFF00 > 0) { if (x & 0x8000 > 0) { result = (result * 0x100000000000058B9) >> 64; } if (x & 0x4000 > 0) { result = (result * 0x10000000000002C5D) >> 64; } if (x & 0x2000 > 0) { result = (result * 0x1000000000000162E) >> 64; } if (x & 0x1000 > 0) { result = (result * 0x10000000000000B17) >> 64; } if (x & 0x800 > 0) { result = (result * 0x1000000000000058C) >> 64; } if (x & 0x400 > 0) { result = (result * 0x100000000000002C6) >> 64; } if (x & 0x200 > 0) { result = (result * 0x10000000000000163) >> 64; } if (x & 0x100 > 0) { result = (result * 0x100000000000000B1) >> 64; } } if (x & 0xFF > 0) { if (x & 0x80 > 0) { result = (result * 0x10000000000000059) >> 64; } if (x & 0x40 > 0) { result = (result * 0x1000000000000002C) >> 64; } if (x & 0x20 > 0) { result = (result * 0x10000000000000016) >> 64; } if (x & 0x10 > 0) { result = (result * 0x1000000000000000B) >> 64; } if (x & 0x8 > 0) { result = (result * 0x10000000000000006) >> 64; } if (x & 0x4 > 0) { result = (result * 0x10000000000000003) >> 64; } if (x & 0x2 > 0) { result = (result * 0x10000000000000001) >> 64; } if (x & 0x1 > 0) { result = (result * 0x10000000000000001) >> 64; } } // In the code snippet below, two operations are executed simultaneously: // // 1. The result is multiplied by $(2^n + 1)$, where $2^n$ represents the integer part, and the additional 1 // accounts for the initial guess of 0.5. This is achieved by subtracting from 191 instead of 192. // 2. The result is then converted to an unsigned 60.18-decimal fixed-point format. // // The underlying logic is based on the relationship $2^{191-ip} = 2^{ip} / 2^{191}$, where $ip$ denotes the, // integer part, $2^n$. result *= UNIT; result >>= (191 - (x >> 64)); } } /// @notice Finds the zero-based index of the first 1 in the binary representation of x. /// /// @dev See the note on "msb" in this Wikipedia article: https://en.wikipedia.org/wiki/Find_first_set /// /// Each step in this implementation is equivalent to this high-level code: /// /// ```solidity /// if (x >= 2 ** 128) { /// x >>= 128; /// result += 128; /// } /// ``` /// /// Where 128 is replaced with each respective power of two factor. See the full high-level implementation here: /// https://gist.github.com/PaulRBerg/f932f8693f2733e30c4d479e8e980948 /// /// The Yul instructions used below are: /// /// - "gt" is "greater than" /// - "or" is the OR bitwise operator /// - "shl" is "shift left" /// - "shr" is "shift right" /// /// @param x The uint256 number for which to find the index of the most significant bit. /// @return result The index of the most significant bit as a uint256. /// @custom:smtchecker abstract-function-nondet function msb(uint256 x) pure returns (uint256 result) { // 2^128 assembly ("memory-safe") { let factor := shl(7, gt(x, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) x := shr(factor, x) result := or(result, factor) } // 2^64 assembly ("memory-safe") { let factor := shl(6, gt(x, 0xFFFFFFFFFFFFFFFF)) x := shr(factor, x) result := or(result, factor) } // 2^32 assembly ("memory-safe") { let factor := shl(5, gt(x, 0xFFFFFFFF)) x := shr(factor, x) result := or(result, factor) } // 2^16 assembly ("memory-safe") { let factor := shl(4, gt(x, 0xFFFF)) x := shr(factor, x) result := or(result, factor) } // 2^8 assembly ("memory-safe") { let factor := shl(3, gt(x, 0xFF)) x := shr(factor, x) result := or(result, factor) } // 2^4 assembly ("memory-safe") { let factor := shl(2, gt(x, 0xF)) x := shr(factor, x) result := or(result, factor) } // 2^2 assembly ("memory-safe") { let factor := shl(1, gt(x, 0x3)) x := shr(factor, x) result := or(result, factor) } // 2^1 // No need to shift x any more. assembly ("memory-safe") { let factor := gt(x, 0x1) result := or(result, factor) } } /// @notice Calculates x*y÷denominator with 512-bit precision. /// /// @dev Credits to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv. /// /// Notes: /// - The result is rounded toward zero. /// /// Requirements: /// - The denominator must not be zero. /// - The result must fit in uint256. /// /// @param x The multiplicand as a uint256. /// @param y The multiplier as a uint256. /// @param denominator The divisor as a uint256. /// @return result The result as a uint256. /// @custom:smtchecker abstract-function-nondet function mulDiv(uint256 x, uint256 y, uint256 denominator) pure returns (uint256 result) { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512-bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly ("memory-safe") { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { unchecked { return prod0 / denominator; } } // Make sure the result is less than 2^256. Also prevents denominator == 0. if (prod1 >= denominator) { revert PRBMath_MulDiv_Overflow(x, y, denominator); } //////////////////////////////////////////////////////////////////////////// // 512 by 256 division //////////////////////////////////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly ("memory-safe") { // Compute remainder using the mulmod Yul instruction. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512-bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } unchecked { // Calculate the largest power of two divisor of the denominator using the unary operator ~. This operation cannot overflow // because the denominator cannot be zero at this point in the function execution. The result is always >= 1. // For more detail, see https://cs.stackexchange.com/q/138556/92363. uint256 lpotdod = denominator & (~denominator + 1); uint256 flippedLpotdod; assembly ("memory-safe") { // Factor powers of two out of denominator. denominator := div(denominator, lpotdod) // Divide [prod1 prod0] by lpotdod. prod0 := div(prod0, lpotdod) // Get the flipped value `2^256 / lpotdod`. If the `lpotdod` is zero, the flipped value is one. // `sub(0, lpotdod)` produces the two's complement version of `lpotdod`, which is equivalent to flipping all the bits. // However, `div` interprets this value as an unsigned value: https://ethereum.stackexchange.com/q/147168/24693 flippedLpotdod := add(div(sub(0, lpotdod), lpotdod), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * flippedLpotdod; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; } } /// @notice Calculates x*y÷1e18 with 512-bit precision. /// /// @dev A variant of {mulDiv} with constant folding, i.e. in which the denominator is hard coded to 1e18. /// /// Notes: /// - The body is purposely left uncommented; to understand how this works, see the documentation in {mulDiv}. /// - The result is rounded toward zero. /// - We take as an axiom that the result cannot be `MAX_UINT256` when x and y solve the following system of equations: /// /// $$ /// \begin{cases} /// x * y = MAX\_UINT256 * UNIT \\ /// (x * y) \% UNIT \geq \frac{UNIT}{2} /// \end{cases} /// $$ /// /// Requirements: /// - Refer to the requirements in {mulDiv}. /// - The result must fit in uint256. /// /// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number. /// @param y The multiplier as an unsigned 60.18-decimal fixed-point number. /// @return result The result as an unsigned 60.18-decimal fixed-point number. /// @custom:smtchecker abstract-function-nondet function mulDiv18(uint256 x, uint256 y) pure returns (uint256 result) { uint256 prod0; uint256 prod1; assembly ("memory-safe") { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } if (prod1 == 0) { unchecked { return prod0 / UNIT; } } if (prod1 >= UNIT) { revert PRBMath_MulDiv18_Overflow(x, y); } uint256 remainder; assembly ("memory-safe") { remainder := mulmod(x, y, UNIT) result := mul( or( div(sub(prod0, remainder), UNIT_LPOTD), mul(sub(prod1, gt(remainder, prod0)), add(div(sub(0, UNIT_LPOTD), UNIT_LPOTD), 1)) ), UNIT_INVERSE ) } } /// @notice Calculates x*y÷denominator with 512-bit precision. /// /// @dev This is an extension of {mulDiv} for signed numbers, which works by computing the signs and the absolute values separately. /// /// Notes: /// - The result is rounded toward zero. /// /// Requirements: /// - Refer to the requirements in {mulDiv}. /// - None of the inputs can be `type(int256).min`. /// - The result must fit in int256. /// /// @param x The multiplicand as an int256. /// @param y The multiplier as an int256. /// @param denominator The divisor as an int256. /// @return result The result as an int256. /// @custom:smtchecker abstract-function-nondet function mulDivSigned(int256 x, int256 y, int256 denominator) pure returns (int256 result) { if (x == type(int256).min || y == type(int256).min || denominator == type(int256).min) { revert PRBMath_MulDivSigned_InputTooSmall(); } // Get hold of the absolute values of x, y and the denominator. uint256 xAbs; uint256 yAbs; uint256 dAbs; unchecked { xAbs = x < 0 ? uint256(-x) : uint256(x); yAbs = y < 0 ? uint256(-y) : uint256(y); dAbs = denominator < 0 ? uint256(-denominator) : uint256(denominator); } // Compute the absolute value of x*y÷denominator. The result must fit in int256. uint256 resultAbs = mulDiv(xAbs, yAbs, dAbs); if (resultAbs > uint256(type(int256).max)) { revert PRBMath_MulDivSigned_Overflow(x, y); } // Get the signs of x, y and the denominator. uint256 sx; uint256 sy; uint256 sd; assembly ("memory-safe") { // "sgt" is the "signed greater than" assembly instruction and "sub(0,1)" is -1 in two's complement. sx := sgt(x, sub(0, 1)) sy := sgt(y, sub(0, 1)) sd := sgt(denominator, sub(0, 1)) } // XOR over sx, sy and sd. What this does is to check whether there are 1 or 3 negative signs in the inputs. // If there are, the result should be negative. Otherwise, it should be positive. unchecked { result = sx ^ sy ^ sd == 0 ? -int256(resultAbs) : int256(resultAbs); } } /// @notice Calculates the square root of x using the Babylonian method. /// /// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method. /// /// Notes: /// - If x is not a perfect square, the result is rounded down. /// - Credits to OpenZeppelin for the explanations in comments below. /// /// @param x The uint256 number for which to calculate the square root. /// @return result The result as a uint256. /// @custom:smtchecker abstract-function-nondet function sqrt(uint256 x) pure returns (uint256 result) { if (x == 0) { return 0; } // For our first guess, we calculate the biggest power of 2 which is smaller than the square root of x. // // We know that the "msb" (most significant bit) of x is a power of 2 such that we have: // // $$ // msb(x) <= x <= 2*msb(x)$ // $$ // // We write $msb(x)$ as $2^k$, and we get: // // $$ // k = log_2(x) // $$ // // Thus, we can write the initial inequality as: // // $$ // 2^{log_2(x)} <= x <= 2*2^{log_2(x)+1} \\ // sqrt(2^k) <= sqrt(x) < sqrt(2^{k+1}) \\ // 2^{k/2} <= sqrt(x) < 2^{(k+1)/2} <= 2^{(k/2)+1} // $$ // // Consequently, $2^{log_2(x) /2} is a good first approximation of sqrt(x) with at least one correct bit. uint256 xAux = uint256(x); result = 1; if (xAux >= 2 ** 128) { xAux >>= 128; result <<= 64; } if (xAux >= 2 ** 64) { xAux >>= 64; result <<= 32; } if (xAux >= 2 ** 32) { xAux >>= 32; result <<= 16; } if (xAux >= 2 ** 16) { xAux >>= 16; result <<= 8; } if (xAux >= 2 ** 8) { xAux >>= 8; result <<= 4; } if (xAux >= 2 ** 4) { xAux >>= 4; result <<= 2; } if (xAux >= 2 ** 2) { result <<= 1; } // At this point, `result` is an estimation with at least one bit of precision. We know the true value has at // most 128 bits, since it is the square root of a uint256. Newton's method converges quadratically (precision // doubles at every iteration). We thus need at most 7 iteration to turn our partial result with one bit of // precision into the expected uint128 result. unchecked { result = (result + x / result) >> 1; result = (result + x / result) >> 1; result = (result + x / result) >> 1; result = (result + x / result) >> 1; result = (result + x / result) >> 1; result = (result + x / result) >> 1; result = (result + x / result) >> 1; // If x is not a perfect square, round the result toward zero. uint256 roundedResult = x / result; if (result >= roundedResult) { result = roundedResult; } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.19; import "./Casting.sol" as Casting; /// @notice The signed 1.18-decimal fixed-point number representation, which can have up to 1 digit and up to 18 /// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity /// type int64. This is useful when end users want to use int64 to save gas, e.g. with tight variable packing in contract /// storage. type SD1x18 is int64; /*////////////////////////////////////////////////////////////////////////// CASTING //////////////////////////////////////////////////////////////////////////*/ using { Casting.intoSD59x18, Casting.intoUD2x18, Casting.intoUD60x18, Casting.intoUint256, Casting.intoUint128, Casting.intoUint40, Casting.unwrap } for SD1x18 global;
// SPDX-License-Identifier: MIT pragma solidity >=0.8.19; import { SD1x18 } from "./ValueType.sol"; /// @dev Euler's number as an SD1x18 number. SD1x18 constant E = SD1x18.wrap(2_718281828459045235); /// @dev The maximum value an SD1x18 number can have. int64 constant uMAX_SD1x18 = 9_223372036854775807; SD1x18 constant MAX_SD1x18 = SD1x18.wrap(uMAX_SD1x18); /// @dev The maximum value an SD1x18 number can have. int64 constant uMIN_SD1x18 = -9_223372036854775808; SD1x18 constant MIN_SD1x18 = SD1x18.wrap(uMIN_SD1x18); /// @dev PI as an SD1x18 number. SD1x18 constant PI = SD1x18.wrap(3_141592653589793238); /// @dev The unit number, which gives the decimal precision of SD1x18. SD1x18 constant UNIT = SD1x18.wrap(1e18); int64 constant uUNIT = 1e18;
// SPDX-License-Identifier: MIT pragma solidity >=0.8.19; import { SD59x18 } from "./ValueType.sol"; // NOTICE: the "u" prefix stands for "unwrapped". /// @dev Euler's number as an SD59x18 number. SD59x18 constant E = SD59x18.wrap(2_718281828459045235); /// @dev The maximum input permitted in {exp}. int256 constant uEXP_MAX_INPUT = 133_084258667509499440; SD59x18 constant EXP_MAX_INPUT = SD59x18.wrap(uEXP_MAX_INPUT); /// @dev Any value less than this returns 0 in {exp}. int256 constant uEXP_MIN_THRESHOLD = -41_446531673892822322; SD59x18 constant EXP_MIN_THRESHOLD = SD59x18.wrap(uEXP_MIN_THRESHOLD); /// @dev The maximum input permitted in {exp2}. int256 constant uEXP2_MAX_INPUT = 192e18 - 1; SD59x18 constant EXP2_MAX_INPUT = SD59x18.wrap(uEXP2_MAX_INPUT); /// @dev Any value less than this returns 0 in {exp2}. int256 constant uEXP2_MIN_THRESHOLD = -59_794705707972522261; SD59x18 constant EXP2_MIN_THRESHOLD = SD59x18.wrap(uEXP2_MIN_THRESHOLD); /// @dev Half the UNIT number. int256 constant uHALF_UNIT = 0.5e18; SD59x18 constant HALF_UNIT = SD59x18.wrap(uHALF_UNIT); /// @dev $log_2(10)$ as an SD59x18 number. int256 constant uLOG2_10 = 3_321928094887362347; SD59x18 constant LOG2_10 = SD59x18.wrap(uLOG2_10); /// @dev $log_2(e)$ as an SD59x18 number. int256 constant uLOG2_E = 1_442695040888963407; SD59x18 constant LOG2_E = SD59x18.wrap(uLOG2_E); /// @dev The maximum value an SD59x18 number can have. int256 constant uMAX_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_792003956564819967; SD59x18 constant MAX_SD59x18 = SD59x18.wrap(uMAX_SD59x18); /// @dev The maximum whole value an SD59x18 number can have. int256 constant uMAX_WHOLE_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_000000000000000000; SD59x18 constant MAX_WHOLE_SD59x18 = SD59x18.wrap(uMAX_WHOLE_SD59x18); /// @dev The minimum value an SD59x18 number can have. int256 constant uMIN_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_792003956564819968; SD59x18 constant MIN_SD59x18 = SD59x18.wrap(uMIN_SD59x18); /// @dev The minimum whole value an SD59x18 number can have. int256 constant uMIN_WHOLE_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_000000000000000000; SD59x18 constant MIN_WHOLE_SD59x18 = SD59x18.wrap(uMIN_WHOLE_SD59x18); /// @dev PI as an SD59x18 number. SD59x18 constant PI = SD59x18.wrap(3_141592653589793238); /// @dev The unit number, which gives the decimal precision of SD59x18. int256 constant uUNIT = 1e18; SD59x18 constant UNIT = SD59x18.wrap(1e18); /// @dev The unit number squared. int256 constant uUNIT_SQUARED = 1e36; SD59x18 constant UNIT_SQUARED = SD59x18.wrap(uUNIT_SQUARED); /// @dev Zero as an SD59x18 number. SD59x18 constant ZERO = SD59x18.wrap(0);
// SPDX-License-Identifier: MIT pragma solidity >=0.8.19; import "./Casting.sol" as Casting; import "./Helpers.sol" as Helpers; import "./Math.sol" as Math; /// @notice The signed 59.18-decimal fixed-point number representation, which can have up to 59 digits and up to 18 /// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity /// type int256. type SD59x18 is int256; /*////////////////////////////////////////////////////////////////////////// CASTING //////////////////////////////////////////////////////////////////////////*/ using { Casting.intoInt256, Casting.intoSD1x18, Casting.intoUD2x18, Casting.intoUD60x18, Casting.intoUint256, Casting.intoUint128, Casting.intoUint40, Casting.unwrap } for SD59x18 global; /*////////////////////////////////////////////////////////////////////////// MATHEMATICAL FUNCTIONS //////////////////////////////////////////////////////////////////////////*/ using { Math.abs, Math.avg, Math.ceil, Math.div, Math.exp, Math.exp2, Math.floor, Math.frac, Math.gm, Math.inv, Math.log10, Math.log2, Math.ln, Math.mul, Math.pow, Math.powu, Math.sqrt } for SD59x18 global; /*////////////////////////////////////////////////////////////////////////// HELPER FUNCTIONS //////////////////////////////////////////////////////////////////////////*/ using { Helpers.add, Helpers.and, Helpers.eq, Helpers.gt, Helpers.gte, Helpers.isZero, Helpers.lshift, Helpers.lt, Helpers.lte, Helpers.mod, Helpers.neq, Helpers.not, Helpers.or, Helpers.rshift, Helpers.sub, Helpers.uncheckedAdd, Helpers.uncheckedSub, Helpers.uncheckedUnary, Helpers.xor } for SD59x18 global; /*////////////////////////////////////////////////////////////////////////// OPERATORS //////////////////////////////////////////////////////////////////////////*/ // The global "using for" directive makes it possible to use these operators on the SD59x18 type. using { Helpers.add as +, Helpers.and2 as &, Math.div as /, Helpers.eq as ==, Helpers.gt as >, Helpers.gte as >=, Helpers.lt as <, Helpers.lte as <=, Helpers.mod as %, Math.mul as *, Helpers.neq as !=, Helpers.not as ~, Helpers.or as |, Helpers.sub as -, Helpers.unary as -, Helpers.xor as ^ } for SD59x18 global;
// SPDX-License-Identifier: MIT pragma solidity >=0.8.19; import "../Common.sol" as Common; import "./Errors.sol" as CastingErrors; import { SD59x18 } from "../sd59x18/ValueType.sol"; import { UD2x18 } from "../ud2x18/ValueType.sol"; import { UD60x18 } from "../ud60x18/ValueType.sol"; import { SD1x18 } from "./ValueType.sol"; /// @notice Casts an SD1x18 number into SD59x18. /// @dev There is no overflow check because the domain of SD1x18 is a subset of SD59x18. function intoSD59x18(SD1x18 x) pure returns (SD59x18 result) { result = SD59x18.wrap(int256(SD1x18.unwrap(x))); } /// @notice Casts an SD1x18 number into UD2x18. /// - x must be positive. function intoUD2x18(SD1x18 x) pure returns (UD2x18 result) { int64 xInt = SD1x18.unwrap(x); if (xInt < 0) { revert CastingErrors.PRBMath_SD1x18_ToUD2x18_Underflow(x); } result = UD2x18.wrap(uint64(xInt)); } /// @notice Casts an SD1x18 number into UD60x18. /// @dev Requirements: /// - x must be positive. function intoUD60x18(SD1x18 x) pure returns (UD60x18 result) { int64 xInt = SD1x18.unwrap(x); if (xInt < 0) { revert CastingErrors.PRBMath_SD1x18_ToUD60x18_Underflow(x); } result = UD60x18.wrap(uint64(xInt)); } /// @notice Casts an SD1x18 number into uint256. /// @dev Requirements: /// - x must be positive. function intoUint256(SD1x18 x) pure returns (uint256 result) { int64 xInt = SD1x18.unwrap(x); if (xInt < 0) { revert CastingErrors.PRBMath_SD1x18_ToUint256_Underflow(x); } result = uint256(uint64(xInt)); } /// @notice Casts an SD1x18 number into uint128. /// @dev Requirements: /// - x must be positive. function intoUint128(SD1x18 x) pure returns (uint128 result) { int64 xInt = SD1x18.unwrap(x); if (xInt < 0) { revert CastingErrors.PRBMath_SD1x18_ToUint128_Underflow(x); } result = uint128(uint64(xInt)); } /// @notice Casts an SD1x18 number into uint40. /// @dev Requirements: /// - x must be positive. /// - x must be less than or equal to `MAX_UINT40`. function intoUint40(SD1x18 x) pure returns (uint40 result) { int64 xInt = SD1x18.unwrap(x); if (xInt < 0) { revert CastingErrors.PRBMath_SD1x18_ToUint40_Underflow(x); } if (xInt > int64(uint64(Common.MAX_UINT40))) { revert CastingErrors.PRBMath_SD1x18_ToUint40_Overflow(x); } result = uint40(uint64(xInt)); } /// @notice Alias for {wrap}. function sd1x18(int64 x) pure returns (SD1x18 result) { result = SD1x18.wrap(x); } /// @notice Unwraps an SD1x18 number into int64. function unwrap(SD1x18 x) pure returns (int64 result) { result = SD1x18.unwrap(x); } /// @notice Wraps an int64 number into SD1x18. function wrap(int64 x) pure returns (SD1x18 result) { result = SD1x18.wrap(x); }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.19; import "./Errors.sol" as CastingErrors; import { MAX_UINT128, MAX_UINT40 } from "../Common.sol"; import { uMAX_SD1x18, uMIN_SD1x18 } from "../sd1x18/Constants.sol"; import { SD1x18 } from "../sd1x18/ValueType.sol"; import { uMAX_UD2x18 } from "../ud2x18/Constants.sol"; import { UD2x18 } from "../ud2x18/ValueType.sol"; import { UD60x18 } from "../ud60x18/ValueType.sol"; import { SD59x18 } from "./ValueType.sol"; /// @notice Casts an SD59x18 number into int256. /// @dev This is basically a functional alias for {unwrap}. function intoInt256(SD59x18 x) pure returns (int256 result) { result = SD59x18.unwrap(x); } /// @notice Casts an SD59x18 number into SD1x18. /// @dev Requirements: /// - x must be greater than or equal to `uMIN_SD1x18`. /// - x must be less than or equal to `uMAX_SD1x18`. function intoSD1x18(SD59x18 x) pure returns (SD1x18 result) { int256 xInt = SD59x18.unwrap(x); if (xInt < uMIN_SD1x18) { revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Underflow(x); } if (xInt > uMAX_SD1x18) { revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Overflow(x); } result = SD1x18.wrap(int64(xInt)); } /// @notice Casts an SD59x18 number into UD2x18. /// @dev Requirements: /// - x must be positive. /// - x must be less than or equal to `uMAX_UD2x18`. function intoUD2x18(SD59x18 x) pure returns (UD2x18 result) { int256 xInt = SD59x18.unwrap(x); if (xInt < 0) { revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Underflow(x); } if (xInt > int256(uint256(uMAX_UD2x18))) { revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Overflow(x); } result = UD2x18.wrap(uint64(uint256(xInt))); } /// @notice Casts an SD59x18 number into UD60x18. /// @dev Requirements: /// - x must be positive. function intoUD60x18(SD59x18 x) pure returns (UD60x18 result) { int256 xInt = SD59x18.unwrap(x); if (xInt < 0) { revert CastingErrors.PRBMath_SD59x18_IntoUD60x18_Underflow(x); } result = UD60x18.wrap(uint256(xInt)); } /// @notice Casts an SD59x18 number into uint256. /// @dev Requirements: /// - x must be positive. function intoUint256(SD59x18 x) pure returns (uint256 result) { int256 xInt = SD59x18.unwrap(x); if (xInt < 0) { revert CastingErrors.PRBMath_SD59x18_IntoUint256_Underflow(x); } result = uint256(xInt); } /// @notice Casts an SD59x18 number into uint128. /// @dev Requirements: /// - x must be positive. /// - x must be less than or equal to `uMAX_UINT128`. function intoUint128(SD59x18 x) pure returns (uint128 result) { int256 xInt = SD59x18.unwrap(x); if (xInt < 0) { revert CastingErrors.PRBMath_SD59x18_IntoUint128_Underflow(x); } if (xInt > int256(uint256(MAX_UINT128))) { revert CastingErrors.PRBMath_SD59x18_IntoUint128_Overflow(x); } result = uint128(uint256(xInt)); } /// @notice Casts an SD59x18 number into uint40. /// @dev Requirements: /// - x must be positive. /// - x must be less than or equal to `MAX_UINT40`. function intoUint40(SD59x18 x) pure returns (uint40 result) { int256 xInt = SD59x18.unwrap(x); if (xInt < 0) { revert CastingErrors.PRBMath_SD59x18_IntoUint40_Underflow(x); } if (xInt > int256(uint256(MAX_UINT40))) { revert CastingErrors.PRBMath_SD59x18_IntoUint40_Overflow(x); } result = uint40(uint256(xInt)); } /// @notice Alias for {wrap}. function sd(int256 x) pure returns (SD59x18 result) { result = SD59x18.wrap(x); } /// @notice Alias for {wrap}. function sd59x18(int256 x) pure returns (SD59x18 result) { result = SD59x18.wrap(x); } /// @notice Unwraps an SD59x18 number into int256. function unwrap(SD59x18 x) pure returns (int256 result) { result = SD59x18.unwrap(x); } /// @notice Wraps an int256 number into SD59x18. function wrap(int256 x) pure returns (SD59x18 result) { result = SD59x18.wrap(x); }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.19; import { wrap } from "./Casting.sol"; import { SD59x18 } from "./ValueType.sol"; /// @notice Implements the checked addition operation (+) in the SD59x18 type. function add(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) { return wrap(x.unwrap() + y.unwrap()); } /// @notice Implements the AND (&) bitwise operation in the SD59x18 type. function and(SD59x18 x, int256 bits) pure returns (SD59x18 result) { return wrap(x.unwrap() & bits); } /// @notice Implements the AND (&) bitwise operation in the SD59x18 type. function and2(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) { return wrap(x.unwrap() & y.unwrap()); } /// @notice Implements the equal (=) operation in the SD59x18 type. function eq(SD59x18 x, SD59x18 y) pure returns (bool result) { result = x.unwrap() == y.unwrap(); } /// @notice Implements the greater than operation (>) in the SD59x18 type. function gt(SD59x18 x, SD59x18 y) pure returns (bool result) { result = x.unwrap() > y.unwrap(); } /// @notice Implements the greater than or equal to operation (>=) in the SD59x18 type. function gte(SD59x18 x, SD59x18 y) pure returns (bool result) { result = x.unwrap() >= y.unwrap(); } /// @notice Implements a zero comparison check function in the SD59x18 type. function isZero(SD59x18 x) pure returns (bool result) { result = x.unwrap() == 0; } /// @notice Implements the left shift operation (<<) in the SD59x18 type. function lshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) { result = wrap(x.unwrap() << bits); } /// @notice Implements the lower than operation (<) in the SD59x18 type. function lt(SD59x18 x, SD59x18 y) pure returns (bool result) { result = x.unwrap() < y.unwrap(); } /// @notice Implements the lower than or equal to operation (<=) in the SD59x18 type. function lte(SD59x18 x, SD59x18 y) pure returns (bool result) { result = x.unwrap() <= y.unwrap(); } /// @notice Implements the unchecked modulo operation (%) in the SD59x18 type. function mod(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) { result = wrap(x.unwrap() % y.unwrap()); } /// @notice Implements the not equal operation (!=) in the SD59x18 type. function neq(SD59x18 x, SD59x18 y) pure returns (bool result) { result = x.unwrap() != y.unwrap(); } /// @notice Implements the NOT (~) bitwise operation in the SD59x18 type. function not(SD59x18 x) pure returns (SD59x18 result) { result = wrap(~x.unwrap()); } /// @notice Implements the OR (|) bitwise operation in the SD59x18 type. function or(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) { result = wrap(x.unwrap() | y.unwrap()); } /// @notice Implements the right shift operation (>>) in the SD59x18 type. function rshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) { result = wrap(x.unwrap() >> bits); } /// @notice Implements the checked subtraction operation (-) in the SD59x18 type. function sub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) { result = wrap(x.unwrap() - y.unwrap()); } /// @notice Implements the checked unary minus operation (-) in the SD59x18 type. function unary(SD59x18 x) pure returns (SD59x18 result) { result = wrap(-x.unwrap()); } /// @notice Implements the unchecked addition operation (+) in the SD59x18 type. function uncheckedAdd(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) { unchecked { result = wrap(x.unwrap() + y.unwrap()); } } /// @notice Implements the unchecked subtraction operation (-) in the SD59x18 type. function uncheckedSub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) { unchecked { result = wrap(x.unwrap() - y.unwrap()); } } /// @notice Implements the unchecked unary minus operation (-) in the SD59x18 type. function uncheckedUnary(SD59x18 x) pure returns (SD59x18 result) { unchecked { result = wrap(-x.unwrap()); } } /// @notice Implements the XOR (^) bitwise operation in the SD59x18 type. function xor(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) { result = wrap(x.unwrap() ^ y.unwrap()); }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.19; import "../Common.sol" as Common; import "./Errors.sol" as Errors; import { uEXP_MAX_INPUT, uEXP2_MAX_INPUT, uEXP_MIN_THRESHOLD, uEXP2_MIN_THRESHOLD, uHALF_UNIT, uLOG2_10, uLOG2_E, uMAX_SD59x18, uMAX_WHOLE_SD59x18, uMIN_SD59x18, uMIN_WHOLE_SD59x18, UNIT, uUNIT, uUNIT_SQUARED, ZERO } from "./Constants.sol"; import { wrap } from "./Helpers.sol"; import { SD59x18 } from "./ValueType.sol"; /// @notice Calculates the absolute value of x. /// /// @dev Requirements: /// - x must be greater than `MIN_SD59x18`. /// /// @param x The SD59x18 number for which to calculate the absolute value. /// @param result The absolute value of x as an SD59x18 number. /// @custom:smtchecker abstract-function-nondet function abs(SD59x18 x) pure returns (SD59x18 result) { int256 xInt = x.unwrap(); if (xInt == uMIN_SD59x18) { revert Errors.PRBMath_SD59x18_Abs_MinSD59x18(); } result = xInt < 0 ? wrap(-xInt) : x; } /// @notice Calculates the arithmetic average of x and y. /// /// @dev Notes: /// - The result is rounded toward zero. /// /// @param x The first operand as an SD59x18 number. /// @param y The second operand as an SD59x18 number. /// @return result The arithmetic average as an SD59x18 number. /// @custom:smtchecker abstract-function-nondet function avg(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) { int256 xInt = x.unwrap(); int256 yInt = y.unwrap(); unchecked { // This operation is equivalent to `x / 2 + y / 2`, and it can never overflow. int256 sum = (xInt >> 1) + (yInt >> 1); if (sum < 0) { // If at least one of x and y is odd, add 1 to the result, because shifting negative numbers to the right // rounds toward negative infinity. The right part is equivalent to `sum + (x % 2 == 1 || y % 2 == 1)`. assembly ("memory-safe") { result := add(sum, and(or(xInt, yInt), 1)) } } else { // Add 1 if both x and y are odd to account for the double 0.5 remainder truncated after shifting. result = wrap(sum + (xInt & yInt & 1)); } } } /// @notice Yields the smallest whole number greater than or equal to x. /// /// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts. /// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions. /// /// Requirements: /// - x must be less than or equal to `MAX_WHOLE_SD59x18`. /// /// @param x The SD59x18 number to ceil. /// @param result The smallest whole number greater than or equal to x, as an SD59x18 number. /// @custom:smtchecker abstract-function-nondet function ceil(SD59x18 x) pure returns (SD59x18 result) { int256 xInt = x.unwrap(); if (xInt > uMAX_WHOLE_SD59x18) { revert Errors.PRBMath_SD59x18_Ceil_Overflow(x); } int256 remainder = xInt % uUNIT; if (remainder == 0) { result = x; } else { unchecked { // Solidity uses C fmod style, which returns a modulus with the same sign as x. int256 resultInt = xInt - remainder; if (xInt > 0) { resultInt += uUNIT; } result = wrap(resultInt); } } } /// @notice Divides two SD59x18 numbers, returning a new SD59x18 number. /// /// @dev This is an extension of {Common.mulDiv} for signed numbers, which works by computing the signs and the absolute /// values separately. /// /// Notes: /// - Refer to the notes in {Common.mulDiv}. /// - The result is rounded toward zero. /// /// Requirements: /// - Refer to the requirements in {Common.mulDiv}. /// - None of the inputs can be `MIN_SD59x18`. /// - The denominator must not be zero. /// - The result must fit in SD59x18. /// /// @param x The numerator as an SD59x18 number. /// @param y The denominator as an SD59x18 number. /// @param result The quotient as an SD59x18 number. /// @custom:smtchecker abstract-function-nondet function div(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) { int256 xInt = x.unwrap(); int256 yInt = y.unwrap(); if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) { revert Errors.PRBMath_SD59x18_Div_InputTooSmall(); } // Get hold of the absolute values of x and y. uint256 xAbs; uint256 yAbs; unchecked { xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt); yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt); } // Compute the absolute value (x*UNIT÷y). The resulting value must fit in SD59x18. uint256 resultAbs = Common.mulDiv(xAbs, uint256(uUNIT), yAbs); if (resultAbs > uint256(uMAX_SD59x18)) { revert Errors.PRBMath_SD59x18_Div_Overflow(x, y); } // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for // negative, 0 for positive or zero). bool sameSign = (xInt ^ yInt) > -1; // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative. unchecked { result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs)); } } /// @notice Calculates the natural exponent of x using the following formula: /// /// $$ /// e^x = 2^{x * log_2{e}} /// $$ /// /// @dev Notes: /// - Refer to the notes in {exp2}. /// /// Requirements: /// - Refer to the requirements in {exp2}. /// - x must be less than 133_084258667509499441. /// /// @param x The exponent as an SD59x18 number. /// @return result The result as an SD59x18 number. /// @custom:smtchecker abstract-function-nondet function exp(SD59x18 x) pure returns (SD59x18 result) { int256 xInt = x.unwrap(); // Any input less than the threshold returns zero. // This check also prevents an overflow for very small numbers. if (xInt < uEXP_MIN_THRESHOLD) { return ZERO; } // This check prevents values greater than 192e18 from being passed to {exp2}. if (xInt > uEXP_MAX_INPUT) { revert Errors.PRBMath_SD59x18_Exp_InputTooBig(x); } unchecked { // Inline the fixed-point multiplication to save gas. int256 doubleUnitProduct = xInt * uLOG2_E; result = exp2(wrap(doubleUnitProduct / uUNIT)); } } /// @notice Calculates the binary exponent of x using the binary fraction method using the following formula: /// /// $$ /// 2^{-x} = \frac{1}{2^x} /// $$ /// /// @dev See https://ethereum.stackexchange.com/q/79903/24693. /// /// Notes: /// - If x is less than -59_794705707972522261, the result is zero. /// /// Requirements: /// - x must be less than 192e18. /// - The result must fit in SD59x18. /// /// @param x The exponent as an SD59x18 number. /// @return result The result as an SD59x18 number. /// @custom:smtchecker abstract-function-nondet function exp2(SD59x18 x) pure returns (SD59x18 result) { int256 xInt = x.unwrap(); if (xInt < 0) { // The inverse of any number less than the threshold is truncated to zero. if (xInt < uEXP2_MIN_THRESHOLD) { return ZERO; } unchecked { // Inline the fixed-point inversion to save gas. result = wrap(uUNIT_SQUARED / exp2(wrap(-xInt)).unwrap()); } } else { // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format. if (xInt > uEXP2_MAX_INPUT) { revert Errors.PRBMath_SD59x18_Exp2_InputTooBig(x); } unchecked { // Convert x to the 192.64-bit fixed-point format. uint256 x_192x64 = uint256((xInt << 64) / uUNIT); // It is safe to cast the result to int256 due to the checks above. result = wrap(int256(Common.exp2(x_192x64))); } } } /// @notice Yields the greatest whole number less than or equal to x. /// /// @dev Optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional /// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions. /// /// Requirements: /// - x must be greater than or equal to `MIN_WHOLE_SD59x18`. /// /// @param x The SD59x18 number to floor. /// @param result The greatest whole number less than or equal to x, as an SD59x18 number. /// @custom:smtchecker abstract-function-nondet function floor(SD59x18 x) pure returns (SD59x18 result) { int256 xInt = x.unwrap(); if (xInt < uMIN_WHOLE_SD59x18) { revert Errors.PRBMath_SD59x18_Floor_Underflow(x); } int256 remainder = xInt % uUNIT; if (remainder == 0) { result = x; } else { unchecked { // Solidity uses C fmod style, which returns a modulus with the same sign as x. int256 resultInt = xInt - remainder; if (xInt < 0) { resultInt -= uUNIT; } result = wrap(resultInt); } } } /// @notice Yields the excess beyond the floor of x for positive numbers and the part of the number to the right. /// of the radix point for negative numbers. /// @dev Based on the odd function definition. https://en.wikipedia.org/wiki/Fractional_part /// @param x The SD59x18 number to get the fractional part of. /// @param result The fractional part of x as an SD59x18 number. function frac(SD59x18 x) pure returns (SD59x18 result) { result = wrap(x.unwrap() % uUNIT); } /// @notice Calculates the geometric mean of x and y, i.e. $\sqrt{x * y}$. /// /// @dev Notes: /// - The result is rounded toward zero. /// /// Requirements: /// - x * y must fit in SD59x18. /// - x * y must not be negative, since complex numbers are not supported. /// /// @param x The first operand as an SD59x18 number. /// @param y The second operand as an SD59x18 number. /// @return result The result as an SD59x18 number. /// @custom:smtchecker abstract-function-nondet function gm(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) { int256 xInt = x.unwrap(); int256 yInt = y.unwrap(); if (xInt == 0 || yInt == 0) { return ZERO; } unchecked { // Equivalent to `xy / x != y`. Checking for overflow this way is faster than letting Solidity do it. int256 xyInt = xInt * yInt; if (xyInt / xInt != yInt) { revert Errors.PRBMath_SD59x18_Gm_Overflow(x, y); } // The product must not be negative, since complex numbers are not supported. if (xyInt < 0) { revert Errors.PRBMath_SD59x18_Gm_NegativeProduct(x, y); } // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT` // during multiplication. See the comments in {Common.sqrt}. uint256 resultUint = Common.sqrt(uint256(xyInt)); result = wrap(int256(resultUint)); } } /// @notice Calculates the inverse of x. /// /// @dev Notes: /// - The result is rounded toward zero. /// /// Requirements: /// - x must not be zero. /// /// @param x The SD59x18 number for which to calculate the inverse. /// @return result The inverse as an SD59x18 number. /// @custom:smtchecker abstract-function-nondet function inv(SD59x18 x) pure returns (SD59x18 result) { result = wrap(uUNIT_SQUARED / x.unwrap()); } /// @notice Calculates the natural logarithm of x using the following formula: /// /// $$ /// ln{x} = log_2{x} / log_2{e} /// $$ /// /// @dev Notes: /// - Refer to the notes in {log2}. /// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`. /// /// Requirements: /// - Refer to the requirements in {log2}. /// /// @param x The SD59x18 number for which to calculate the natural logarithm. /// @return result The natural logarithm as an SD59x18 number. /// @custom:smtchecker abstract-function-nondet function ln(SD59x18 x) pure returns (SD59x18 result) { // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that // {log2} can return is ~195_205294292027477728. result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E); } /// @notice Calculates the common logarithm of x using the following formula: /// /// $$ /// log_{10}{x} = log_2{x} / log_2{10} /// $$ /// /// However, if x is an exact power of ten, a hard coded value is returned. /// /// @dev Notes: /// - Refer to the notes in {log2}. /// /// Requirements: /// - Refer to the requirements in {log2}. /// /// @param x The SD59x18 number for which to calculate the common logarithm. /// @return result The common logarithm as an SD59x18 number. /// @custom:smtchecker abstract-function-nondet function log10(SD59x18 x) pure returns (SD59x18 result) { int256 xInt = x.unwrap(); if (xInt < 0) { revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x); } // Note that the `mul` in this block is the standard multiplication operation, not {SD59x18.mul}. // prettier-ignore assembly ("memory-safe") { switch x case 1 { result := mul(uUNIT, sub(0, 18)) } case 10 { result := mul(uUNIT, sub(1, 18)) } case 100 { result := mul(uUNIT, sub(2, 18)) } case 1000 { result := mul(uUNIT, sub(3, 18)) } case 10000 { result := mul(uUNIT, sub(4, 18)) } case 100000 { result := mul(uUNIT, sub(5, 18)) } case 1000000 { result := mul(uUNIT, sub(6, 18)) } case 10000000 { result := mul(uUNIT, sub(7, 18)) } case 100000000 { result := mul(uUNIT, sub(8, 18)) } case 1000000000 { result := mul(uUNIT, sub(9, 18)) } case 10000000000 { result := mul(uUNIT, sub(10, 18)) } case 100000000000 { result := mul(uUNIT, sub(11, 18)) } case 1000000000000 { result := mul(uUNIT, sub(12, 18)) } case 10000000000000 { result := mul(uUNIT, sub(13, 18)) } case 100000000000000 { result := mul(uUNIT, sub(14, 18)) } case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) } case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) } case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) } case 1000000000000000000 { result := 0 } case 10000000000000000000 { result := uUNIT } case 100000000000000000000 { result := mul(uUNIT, 2) } case 1000000000000000000000 { result := mul(uUNIT, 3) } case 10000000000000000000000 { result := mul(uUNIT, 4) } case 100000000000000000000000 { result := mul(uUNIT, 5) } case 1000000000000000000000000 { result := mul(uUNIT, 6) } case 10000000000000000000000000 { result := mul(uUNIT, 7) } case 100000000000000000000000000 { result := mul(uUNIT, 8) } case 1000000000000000000000000000 { result := mul(uUNIT, 9) } case 10000000000000000000000000000 { result := mul(uUNIT, 10) } case 100000000000000000000000000000 { result := mul(uUNIT, 11) } case 1000000000000000000000000000000 { result := mul(uUNIT, 12) } case 10000000000000000000000000000000 { result := mul(uUNIT, 13) } case 100000000000000000000000000000000 { result := mul(uUNIT, 14) } case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) } case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) } case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) } case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) } case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) } case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) } case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) } case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) } case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) } case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) } case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) } case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) } case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) } case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) } case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) } case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) } case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) } case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) } case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) } case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) } case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) } case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) } case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) } case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) } case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) } case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) } case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) } case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) } case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) } case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) } case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) } case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) } case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) } case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) } case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) } case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) } case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) } case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) } case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) } case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) } case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) } case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) } case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) } case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) } default { result := uMAX_SD59x18 } } if (result.unwrap() == uMAX_SD59x18) { unchecked { // Inline the fixed-point division to save gas. result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10); } } } /// @notice Calculates the binary logarithm of x using the iterative approximation algorithm: /// /// $$ /// log_2{x} = n + log_2{y}, \text{ where } y = x*2^{-n}, \ y \in [1, 2) /// $$ /// /// For $0 \leq x \lt 1$, the input is inverted: /// /// $$ /// log_2{x} = -log_2{\frac{1}{x}} /// $$ /// /// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation. /// /// Notes: /// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal. /// /// Requirements: /// - x must be greater than zero. /// /// @param x The SD59x18 number for which to calculate the binary logarithm. /// @return result The binary logarithm as an SD59x18 number. /// @custom:smtchecker abstract-function-nondet function log2(SD59x18 x) pure returns (SD59x18 result) { int256 xInt = x.unwrap(); if (xInt <= 0) { revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x); } unchecked { int256 sign; if (xInt >= uUNIT) { sign = 1; } else { sign = -1; // Inline the fixed-point inversion to save gas. xInt = uUNIT_SQUARED / xInt; } // Calculate the integer part of the logarithm. uint256 n = Common.msb(uint256(xInt / uUNIT)); // This is the integer part of the logarithm as an SD59x18 number. The operation can't overflow // because n is at most 255, `UNIT` is 1e18, and the sign is either 1 or -1. int256 resultInt = int256(n) * uUNIT; // Calculate $y = x * 2^{-n}$. int256 y = xInt >> n; // If y is the unit number, the fractional part is zero. if (y == uUNIT) { return wrap(resultInt * sign); } // Calculate the fractional part via the iterative approximation. // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient. int256 DOUBLE_UNIT = 2e18; for (int256 delta = uHALF_UNIT; delta > 0; delta >>= 1) { y = (y * y) / uUNIT; // Is y^2 >= 2e18 and so in the range [2e18, 4e18)? if (y >= DOUBLE_UNIT) { // Add the 2^{-m} factor to the logarithm. resultInt = resultInt + delta; // Halve y, which corresponds to z/2 in the Wikipedia article. y >>= 1; } } resultInt *= sign; result = wrap(resultInt); } } /// @notice Multiplies two SD59x18 numbers together, returning a new SD59x18 number. /// /// @dev Notes: /// - Refer to the notes in {Common.mulDiv18}. /// /// Requirements: /// - Refer to the requirements in {Common.mulDiv18}. /// - None of the inputs can be `MIN_SD59x18`. /// - The result must fit in SD59x18. /// /// @param x The multiplicand as an SD59x18 number. /// @param y The multiplier as an SD59x18 number. /// @return result The product as an SD59x18 number. /// @custom:smtchecker abstract-function-nondet function mul(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) { int256 xInt = x.unwrap(); int256 yInt = y.unwrap(); if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) { revert Errors.PRBMath_SD59x18_Mul_InputTooSmall(); } // Get hold of the absolute values of x and y. uint256 xAbs; uint256 yAbs; unchecked { xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt); yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt); } // Compute the absolute value (x*y÷UNIT). The resulting value must fit in SD59x18. uint256 resultAbs = Common.mulDiv18(xAbs, yAbs); if (resultAbs > uint256(uMAX_SD59x18)) { revert Errors.PRBMath_SD59x18_Mul_Overflow(x, y); } // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for // negative, 0 for positive or zero). bool sameSign = (xInt ^ yInt) > -1; // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative. unchecked { result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs)); } } /// @notice Raises x to the power of y using the following formula: /// /// $$ /// x^y = 2^{log_2{x} * y} /// $$ /// /// @dev Notes: /// - Refer to the notes in {exp2}, {log2}, and {mul}. /// - Returns `UNIT` for 0^0. /// /// Requirements: /// - Refer to the requirements in {exp2}, {log2}, and {mul}. /// /// @param x The base as an SD59x18 number. /// @param y Exponent to raise x to, as an SD59x18 number /// @return result x raised to power y, as an SD59x18 number. /// @custom:smtchecker abstract-function-nondet function pow(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) { int256 xInt = x.unwrap(); int256 yInt = y.unwrap(); // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero. if (xInt == 0) { return yInt == 0 ? UNIT : ZERO; } // If x is `UNIT`, the result is always `UNIT`. else if (xInt == uUNIT) { return UNIT; } // If y is zero, the result is always `UNIT`. if (yInt == 0) { return UNIT; } // If y is `UNIT`, the result is always x. else if (yInt == uUNIT) { return x; } // Calculate the result using the formula. result = exp2(mul(log2(x), y)); } /// @notice Raises x (an SD59x18 number) to the power y (an unsigned basic integer) using the well-known /// algorithm "exponentiation by squaring". /// /// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring. /// /// Notes: /// - Refer to the notes in {Common.mulDiv18}. /// - Returns `UNIT` for 0^0. /// /// Requirements: /// - Refer to the requirements in {abs} and {Common.mulDiv18}. /// - The result must fit in SD59x18. /// /// @param x The base as an SD59x18 number. /// @param y The exponent as a uint256. /// @return result The result as an SD59x18 number. /// @custom:smtchecker abstract-function-nondet function powu(SD59x18 x, uint256 y) pure returns (SD59x18 result) { uint256 xAbs = uint256(abs(x).unwrap()); // Calculate the first iteration of the loop in advance. uint256 resultAbs = y & 1 > 0 ? xAbs : uint256(uUNIT); // Equivalent to `for(y /= 2; y > 0; y /= 2)`. uint256 yAux = y; for (yAux >>= 1; yAux > 0; yAux >>= 1) { xAbs = Common.mulDiv18(xAbs, xAbs); // Equivalent to `y % 2 == 1`. if (yAux & 1 > 0) { resultAbs = Common.mulDiv18(resultAbs, xAbs); } } // The result must fit in SD59x18. if (resultAbs > uint256(uMAX_SD59x18)) { revert Errors.PRBMath_SD59x18_Powu_Overflow(x, y); } unchecked { // Is the base negative and the exponent odd? If yes, the result should be negative. int256 resultInt = int256(resultAbs); bool isNegative = x.unwrap() < 0 && y & 1 == 1; if (isNegative) { resultInt = -resultInt; } result = wrap(resultInt); } } /// @notice Calculates the square root of x using the Babylonian method. /// /// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method. /// /// Notes: /// - Only the positive root is returned. /// - The result is rounded toward zero. /// /// Requirements: /// - x cannot be negative, since complex numbers are not supported. /// - x must be less than `MAX_SD59x18 / UNIT`. /// /// @param x The SD59x18 number for which to calculate the square root. /// @return result The result as an SD59x18 number. /// @custom:smtchecker abstract-function-nondet function sqrt(SD59x18 x) pure returns (SD59x18 result) { int256 xInt = x.unwrap(); if (xInt < 0) { revert Errors.PRBMath_SD59x18_Sqrt_NegativeInput(x); } if (xInt > uMAX_SD59x18 / uUNIT) { revert Errors.PRBMath_SD59x18_Sqrt_Overflow(x); } unchecked { // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two SD59x18 numbers. // In this case, the two numbers are both the square root. uint256 resultUint = Common.sqrt(uint256(xInt * uUNIT)); result = wrap(int256(resultUint)); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.19; import { SD1x18 } from "./ValueType.sol"; /// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD2x18. error PRBMath_SD1x18_ToUD2x18_Underflow(SD1x18 x); /// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD60x18. error PRBMath_SD1x18_ToUD60x18_Underflow(SD1x18 x); /// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint128. error PRBMath_SD1x18_ToUint128_Underflow(SD1x18 x); /// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint256. error PRBMath_SD1x18_ToUint256_Underflow(SD1x18 x); /// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40. error PRBMath_SD1x18_ToUint40_Overflow(SD1x18 x); /// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40. error PRBMath_SD1x18_ToUint40_Underflow(SD1x18 x);
// SPDX-License-Identifier: MIT pragma solidity >=0.8.19; import { SD59x18 } from "./ValueType.sol"; /// @notice Thrown when taking the absolute value of `MIN_SD59x18`. error PRBMath_SD59x18_Abs_MinSD59x18(); /// @notice Thrown when ceiling a number overflows SD59x18. error PRBMath_SD59x18_Ceil_Overflow(SD59x18 x); /// @notice Thrown when converting a basic integer to the fixed-point format overflows SD59x18. error PRBMath_SD59x18_Convert_Overflow(int256 x); /// @notice Thrown when converting a basic integer to the fixed-point format underflows SD59x18. error PRBMath_SD59x18_Convert_Underflow(int256 x); /// @notice Thrown when dividing two numbers and one of them is `MIN_SD59x18`. error PRBMath_SD59x18_Div_InputTooSmall(); /// @notice Thrown when dividing two numbers and one of the intermediary unsigned results overflows SD59x18. error PRBMath_SD59x18_Div_Overflow(SD59x18 x, SD59x18 y); /// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441. error PRBMath_SD59x18_Exp_InputTooBig(SD59x18 x); /// @notice Thrown when taking the binary exponent of a base greater than 192e18. error PRBMath_SD59x18_Exp2_InputTooBig(SD59x18 x); /// @notice Thrown when flooring a number underflows SD59x18. error PRBMath_SD59x18_Floor_Underflow(SD59x18 x); /// @notice Thrown when taking the geometric mean of two numbers and their product is negative. error PRBMath_SD59x18_Gm_NegativeProduct(SD59x18 x, SD59x18 y); /// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows SD59x18. error PRBMath_SD59x18_Gm_Overflow(SD59x18 x, SD59x18 y); /// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18. error PRBMath_SD59x18_IntoSD1x18_Overflow(SD59x18 x); /// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18. error PRBMath_SD59x18_IntoSD1x18_Underflow(SD59x18 x); /// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18. error PRBMath_SD59x18_IntoUD2x18_Overflow(SD59x18 x); /// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18. error PRBMath_SD59x18_IntoUD2x18_Underflow(SD59x18 x); /// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD60x18. error PRBMath_SD59x18_IntoUD60x18_Underflow(SD59x18 x); /// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128. error PRBMath_SD59x18_IntoUint128_Overflow(SD59x18 x); /// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128. error PRBMath_SD59x18_IntoUint128_Underflow(SD59x18 x); /// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint256. error PRBMath_SD59x18_IntoUint256_Underflow(SD59x18 x); /// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40. error PRBMath_SD59x18_IntoUint40_Overflow(SD59x18 x); /// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40. error PRBMath_SD59x18_IntoUint40_Underflow(SD59x18 x); /// @notice Thrown when taking the logarithm of a number less than or equal to zero. error PRBMath_SD59x18_Log_InputTooSmall(SD59x18 x); /// @notice Thrown when multiplying two numbers and one of the inputs is `MIN_SD59x18`. error PRBMath_SD59x18_Mul_InputTooSmall(); /// @notice Thrown when multiplying two numbers and the intermediary absolute result overflows SD59x18. error PRBMath_SD59x18_Mul_Overflow(SD59x18 x, SD59x18 y); /// @notice Thrown when raising a number to a power and the intermediary absolute result overflows SD59x18. error PRBMath_SD59x18_Powu_Overflow(SD59x18 x, uint256 y); /// @notice Thrown when taking the square root of a negative number. error PRBMath_SD59x18_Sqrt_NegativeInput(SD59x18 x); /// @notice Thrown when the calculating the square root overflows SD59x18. error PRBMath_SD59x18_Sqrt_Overflow(SD59x18 x);
{ "optimizer": { "enabled": true, "mode": "z", "fallback_to_optimizing_for_size": true }, "viaIR": true, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "abi" ] } }, "detectMissingLibraries": false, "forceEVMLA": false, "enableEraVMExtensions": false, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"contract IERC721Metadata","name":"nft","type":"address"},{"internalType":"string","name":"symbol","type":"string"}],"name":"SablierV2NFTDescriptor_UnknownNFT","type":"error"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"length","type":"uint256"}],"name":"StringsInsufficientHexLength","type":"error"},{"inputs":[{"internalType":"contract IERC721Metadata","name":"sablier","type":"address"},{"internalType":"uint256","name":"streamId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"uri","type":"string"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
9c4d535b00000000000000000000000000000000000000000000000000000000000000000100070d08e54561dd015b5431d289d5e05a0d50e411d5e485e1d3a9536a2ec800000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000
Deployed Bytecode
0x0004000000000002001800000000000200000000030100190000006003300270000005790030019d000005790330019700030000003103550002000000010355000000010020019000000000020004160000002004000039000000350000c13d0000028004000039000000400040043f000000040030008c0000015c0000413d000000000401043b0000057b044001970000057c0040009c0000015c0000c13d000000440030008c0000015c0000413d000000000002004b0000015c0000c13d0000000402100370000000000202043b0000057d0020009c0000015c0000213d0000057d022001970000042008000039000000400080043f000002800000043f0000006004000039000002a00040043f000002c00000043f000002e00000043f000003000040043f000003200040043f000003600040043f000003800040043f000003a00040043f000003c00040043f000003e00000043f000004000000043f000003400020043f0000057e04000041000004200040043f0000000005000414000000040020008c000e00000002001d0000003d0000c13d000000000231034f000000590000013d0000008001000039000000400010043f000000000002004b0000015c0000c13d000001000040044300000120000004430000057a01000041000015e10001042e0000000404000039000004200300003900000000010500190000000005030019000000000600001915e011690000040f000000000001004b000000570000c13d0000000303000367000000400100043d00000001020000310000001f0420018f00000005052002720000000505500210000000520000613d0000000006510019000000000703034f0000000008010019000100510000003d000015a10000013d0000004f0000c13d000000000004004b000000560000613d000100560000003d000014cf0000013d15e0148e0000040f0000000302000367000004200800003900000001010000310000001f0310018f00000005041002720000000504400210000000640000613d0000042005400039000000000602034f000000006706043c0000000008780436000000000058004b000000600000c13d000000000003004b000000720000613d000000000242034f00000003033002100000042004400039000000000504043300000000053501cf000000000535022f000000000202043b0000010003300089000000000232022f00000000023201cf000000000252019f00000000002404350000001f02100039000000200300008a000000000232016f0000057f0020009c000000800000813d0000042002200039000000400020043f0000042002100039000004200100003915e012050000040f000d00000001001d000000400200043d000005800020009c000000860000a13d000005a60100004100000000001004350000004101000039000000040010043f000005af01000041000015e200010430000100880000003d0000159d0000013d00000581030000410001008b0000003d000015950000013d000000b40000c13d0000000001020019000005800020009c000000800000213d0000000002010019000100920000003d0000159d0000013d0000058303000041000100950000003d000015950000013d000000ef0000c13d0000000001020019000005800020009c000000800000213d00000000020100190001009c0000003d0000159d0000013d00000585030000410000000000310435000000110100003900000000001204350000000d0100002915e013910000040f000000400400043d000000000001004b000000f50000c13d000000240140003900000040020000390000000000210435000006f001000041000000000014043500000004014000390000000e02000029000000000021043500000044024000390000000d01000029000e00000004001d15e011a80000040f0000000e0210006a0000000e0100002915e0148e0000040f0000000003020019000005800020009c000000800000213d00000582010000410000000d0200003900000000040300190000004003400039000000400030043f000000200340003900000000001304350000000000240435000003600040043f0000000e0100002915e012460000040f000003800010043f0000058701000041000003400200043d000000400300043d0000000000130435000100c90000003d000015d20000013d0000000404300039000000000014043500000000010004140000057d02200197000000040020008c000000d70000613d00000024040000390000002006000039000e00000003001d0000000e0500002915e011690000040f0000000e03000029000000000001004b000000450000613d0000000102000031000000200020008c000000200100003900000000010240190000001f01100039000000600510018f00000000040300190000000001350019000000000051004b00000000030000190000000103004039000005880010009c000000800000213d0000000100300190000000800000c13d000000400010043f000000200020008c000000ec0000413d00000000020404330000057d0020009c000000fb0000a13d0000000001000019000000000200001915e0148e0000040f00000584010000410000000003020019000005800020009c0000000e02000039000000800000213d000000b90000013d0000000003040019000005800040009c000000800000213d00000586010000410000000f02000039000000b90000013d0000000403000039000002800020043f00000000033104360000057e040000410000000000430435000005800010009c000000800000213d0000004004100039000000400040043f00000000040104330000000001000414000000040020008c000e00000000001d0000010c0000613d0001010b0000003d000015bf0000013d000e00000001001d15e011ce0000040f0000000e0200002900000001002001900000012d0000c13d0000000002010433000000400020008c0000012d0000a13d0000002001100039000000000212001915e012050000040f00000000430104340000001e0030008c0000015e0000213d00000012020000390000000005000019000000000035004b000001370000813d000000000654001900000000060604330000058a076001970000058b0070009c0000012b0000613d0000058c0070009c0000012b0000613d0000058f0770009a000005900070009c0000012b0000213d0000058d066001970000058e0660009a000005910060009c000001830000413d00000001055000390000011b0000013d0000059303000041000000400100043d000005800010009c0000000502000039000000800000213d0000004004100039000000400040043f000000200410003900000000003404350000000000210435000002a00010043f000003400200043d000000400300043d000005940100004100000000001304350001013e0000003d000015d20000013d000e00000003001d0000000403300039000000000013043500000000010004140000057d02200197000000040020008c000001480000613d000101470000003d000015cb0000013d000000450000613d00000001020000310001014b0000003d000015260000013d0000000e050000290000000e03400029000000000043004b00000000010000190000000101004039000d00000003001d000005880030009c000000800000213d0000000100100190000000800000c13d0000000d01000029000000400010043f000000200020008c0000015c0000413d0000000001050433000005950010009c000001640000a13d0000000001000019000015e200010430000000400100043d000005800010009c000000800000213d00000589030000410000000b02000039000001320000013d000002c00010043f000003400300043d00000596010000410000000d050000290001016a0000003d000015a50000013d00000000010004140000057d03300197000000040030008c0000018a0000613d0000002404000039000000200600003900000000020300190000000d03000029000101740000003d000015c60000013d000001880000c13d000101770000003d000015730000013d0000017e0000613d0000000006510019000000000703034f00000000080100190001017d0000003d000015a10000013d0000017b0000c13d000000000004004b000001820000613d000101820000003d000014cf0000013d15e0148e0000040f0000059203000041000000400100043d000005800010009c000000800000213d000001320000013d0001018a0000003d000015260000013d0000000d01400029000005880010009c000000800000213d000000400010043f000000200020008c000000ec0000413d0000000d030000290000000005030433000000040050008c000000ec0000213d000000010050008c0000019f0000613d0000000703000039000000020050008c000001a40000613d000000030050008c000001a60000613d000000040050008c000001ab0000c13d0000059a05000041000001a70000013d000005800010009c000000800000213d00000598050000410000000903000039000001ae0000013d0000059705000041000001ac0000013d0000059905000041000005800010009c0000000803000039000000800000213d000001ae0000013d0000059b05000041000005800010009c000000800000213d0000004006100039000000400060043f000000200610003900000000005604350000000000310435000003a00010043f000003400300043d000000400500043d0000059c010000410000000000150435000101ba0000003d000015d20000013d000e00000005001d0000000405500039000000000015043500000000010004140000057d03300197000000040030008c000001d80000613d0000002404000039000000200600003900000000020300190000000e03000029000101c70000003d000015c60000013d000001d60000c13d000101ca0000003d000015730000013d000001d10000613d0000000006510019000000000703034f0000000008010019000101d00000003d000015a10000013d000001ce0000c13d000000000004004b000001d50000613d000101d50000003d000014cf0000013d15e0148e0000040f000101d80000003d000015260000013d0000000e03400029000000000043004b00000000010000190000000101004039000d00000003001d000005880030009c000000800000213d0000000100100190000000800000c13d0000000d01000029000000400010043f000000200020008c0000015c0000413d0000000e010000290000000001010433000005950010009c0000015c0000213d000002c00200043d0000059502200198000001f00000c13d000005a60100004100000000001004350000001201000039000000830000013d00002710011000c90000059d0110019700000000012100d9000003e00010043f15e014b50000040f00000000020100190000000d050000290000002001500039000000000021043500000002020003670000000403200370000000000303043b0000006003300210000000400450003900000000003404350000002402200370000000000202043b00000054035000390000000000230435000000540200003900000000002504350000059e0050009c000000800000213d0000000d030000290000008002300039000000400020043f000000000203043315e014a00000040f000e00000001001d00000010021002700000ffff0120018f000001681010011a15e012f10000040f000d00000001001d0000000e010000290000000801100270000000ff0110018f000000501010011a000000140110003915e012f10000040f0000000e02000029000000ff0220018f000000462020011a000e00000001001d0000001e0120003915e012f10000040f0000059f02000041000000400400043d000000200340003900000000002304350000000d030000290000002002300039000b00000004001d000000240440003900000000030304330000000005000019000000000035004b0000022f0000813d000000000645001900000000075200190001022e0000003d000014fb0000013d000002280000013d000000000243001900000000000204350000000b023000290000002403200039000005a00400004100000000004304350000000e030000290000002005300039000000250420003900000000030304330000000006000019000000000036004b000002400000813d00000000074600190001023f0000003d000014dc0000013d0000023a0000013d0000000004430019000000000004043500000000022300190000002503200039000005a10400004100000000004304350000002004100039000000270320003900000000010104330000000005000019000000000015004b000002500000813d00000000063500190001024f0000003d000014f60000013d0000024a0000013d0000000003310019000000000003043500000000011200190000002702100039000005a20300004100000000003204350000000b0300002900000000013100490000000902100039000000000023043500000048011000390001025d0000003d000014c80000013d000005880010009c000000800000213d0000000100200190000000800000c13d000000400010043f000002c00200043d000e00000002001d000002800200043d00000004030000390000000003310436000005a3040000410000000000430435000005800010009c000000800000213d0000057d022001970000004004100039000000400040043f00000000040104330000000001000414000000040020008c000d00000000001d000002760000613d000102750000003d000015bf0000013d000d00000001001d15e011ce0000040f00000000020100190000000d0100002900000001001001900000000001000019000002840000c13d0000000001020433000000200010008c0000000001000019000002840000c13d00000020012000390000000001010433000000ff0010008c0000015c0000213d0000000e02000029000e05950020019c000a00010000003d000002dd0000c13d000000400100043d000d00000001001d000005800010009c000000800000213d0000000d030000290001028f0000003d000015b10000013d000005b202000041000000000021043500000001010000390000000000130435000002800100043d0000057d0110019715e012460000040f000002a00200043d000900000002001d000003400200043d000000400400043d000005b303000041000000000034043500000024030000390000000203300367000000000303043b000e00000004001d00000004044000390000000000340435000800000001001d00000000010004140000057d02200197000000040020008c000002aa0000613d000102a90000003d000015cb0000013d000000450000613d0000000102000031000102ad0000003d000015260000013d0000000e03400029000000000043004b00000000010000190000000101004039000c00000003001d000005880030009c000000800000213d0000000100100190000000800000c13d0000000c01000029000000400010043f000000200020008c0000015c0000413d0000000e010000290000000001010433000e00000001001d000005b40010009c0000015c0000213d000003400300043d000005b5010000410000000c05000029000102c40000003d000015a50000013d00000000010004140000057d03300197000000040030008c000003650000613d0000002404000039000000200600003900000000020300190000000c03000029000102ce0000003d000015c60000013d000003630000c13d000102d10000003d000015730000013d000002d80000613d0000000006510019000000000703034f0000000008010019000102d70000003d000015a10000013d000002d50000c13d000000000004004b000002dc0000613d000102dc0000003d000014cf0000013d15e0148e0000040f000000000001004b000002fd0000613d15e0147e0000040f000000000001004b000002e90000c13d000005a60100004100000000001004350000001201000039000000040010043f0000002402000039000000000100001915e0148e0000040f0000000e0010006c000002fc0000a13d000000400100043d000005800010009c000000800000213d0000004002100039000000400020043f00000004020000390000000001210436000005a4020000410000000000210435000000400300043d000000200130003900000000002104350000002401300039000005a50200004100000000002104350000000601000039000003110000013d000e000e00100101000000400200043d0000000e01000029000005a70010009c0000004001200039000900000002001d0000002002200039000003190000413d0000000903000029000005800030009c000000800000213d000000400010043f000000040100003900000009030000290000000000130435000005b0010000410001030e0000003d0000158f0000013d000005b10200004100000000002104350000000c010000390000000000130435000d00000003001d000005800030009c000000800000213d0000000d010000290000004001100039000000400010043f000002930000013d0000000903000029000005a80030009c000000800000213d0000000904000029000000a003400039000000400030043f000005a90040009c000000800000213d0000000905000029000000c004500039000000400040043f00000000000304350000000000350435000000400300043d000005800030009c000000800000213d0000004004300039000000400040043f0000002004300039000005aa050000410000000000540435000000010400003900000000004304350000000000320435000000400200043d000005800020009c000000800000213d0000004003200039000000400030043f0000002003200039000005ab040000410000000000430435000000010300003900000000003204350000000000210435000000400100043d000005800010009c000000800000213d0000004002100039000000400020043f0000002002100039000005ac03000041000000000032043500000001020000390000000000210435000000090200002900000060022000390000000000120435000000400100043d000005800010009c000000800000213d0000004002100039000000400020043f0000002002100039000005ad03000041000000000032043500000001020000390000000000210435000000090200002900000080022000390000000000120435000c00000000001d000d00000000001d0000000e01000029000003e80010008c000003860000413d0000000d01000029000d00010010003d0000000e02000029000e03e8002001220000000a0220011a000000642020011a000c00000002001d000003580000013d000103650000003d000015260000013d0000000c01400029000700000001001d000005880010009c000000800000213d0000000701000029000000400010043f000000200020008c0000015c0000413d0000000c010000290000000001010433000005b40010009c0000015c0000213d0000000e0110006a000005b60310009c00000007040000290000004002400039000e00200040003d000003aa0000813d0000000701000029000005800010009c000000800000213d000000400020043f000000040100003900000007020000290000000000120435000005a4010000410000000e02000029000103820000003d0000158f0000013d000005bb0200004100000000002104350000000a01000039000003ba0000013d000000400100043d000005800010009c000000800000213d0000004002100039000000400020043f00000007020000390000000001210436000005ae020000410000000000210435000000400300043d0000002001300039000000000021043500000027013000390000058b02000041000000000021043500000008010000390000000000130435000800000003001d000005800030009c000000800000213d00000008010000290000004001100039000000400010043f0000000e0100002915e012f10000040f000e00000001001d0000000c0100002915e013a40000040f00000000030100190000000d01000029000000050010008c0000048a0000413d000005a60100004100000000001004350000003201000039000000830000013d000005b70010009c000003c10000413d0000000701000029000005800010009c000000800000213d000000400020043f000000040100003900000007020000290000000000120435000005b0010000410000000e02000029000103b70000003d0000158f0000013d000005ba0200004100000000002104350000000e010000390000000000130435000c00000003001d000005800030009c000000800000213d0000000c010000290000004001100039000003f70000013d0000000704000029000005800040009c000000800000213d000005b60110012a000000400020043f000005b60030009c0000000502000039000000040200403900000007030000290000000000230435000005b902000041000005b8020040410000000e03000029000000000023043515e012f10000040f0000002002100039000000400300043d000c00000003001d000000200330003900000000010104330000000004000019000000000014004b000003de0000813d00000000053400190000000006420019000000000606043300000000006504350000002004400039000003d60000013d00000000023100190000000000020435000000070300002900000000030304330000000004000019000000000034004b000003eb0000813d00000000052400190000000e06400029000000000606043300000000006504350000002004400039000003e30000013d0000000002230019000000000002043500000000011300190000000c0300002900000000001304350000003f01100039000103f30000003d000014c80000013d000005880010009c000000800000213d0000000100200190000000800000c13d000000400010043f000003800100043d000600000001001d000003e00100043d000700641010012215e013a40000040f000e00000001001d000000070100002915e012f10000040f0000002004100039000000400200043d000000200320003900000000010104330000000005000019000000000015004b0000040b0000813d00000000063500190001040a0000003d000014f60000013d000004050000013d00000000013100190000000e050000290000002004500039000000000001043500000000050504330000000006000019000000000056004b000004180000813d00000000071600190000000008640019000104170000003d000014ed0000013d000004110000013d0000000001150019000005bc04000041000000000041043500000000012100490000001f0410008a0000000000420435000000200400008a000000000141016f0000000001310019000700000001001d000005880010009c000000800000213d000000070020006b000000800000413d0000000705000029000000400050043f000003600400043d000003a00100043d000003e00300043d001800000005001d000005bd0050009c000000800000213d00000007060000290000014005600039000000400050043f00000100056000390000000000450435000000e004600039000000060500002900000000005404350000006004600039000000090500002900000000005404350000004004600039000000080500002900000000005404350000012004600039000900000004001d0000000000140435000000c0016000390000000000310435000000a00360003900000000002304350000008002600039000800000002001d0000000c0400002900000000004204350000000b020000290000000002260436000c00000002001d0000000d040000290000000000420435000000400200043d000001e00020043f000005be0020009c000000800000213d000001c004200039000000400040043f00000060040000390000000000420435000001e00200043d00000020022000390000000000020435000001e00200043d00000040022000390000000000020435000001e00200043d00000060022000390000000000420435000001e00200043d00000080022000390000000000020435000001e00200043d000000a0022000390000000000420435000001e00200043d000000c0022000390000000000020435000001e00200043d000000e0022000390000000000020435000001e00200043d00000100022000390000000000420435000001e00200043d00000120022000390000000000020435000001e00200043d00000140022000390000000000020435000001e00200043d00000160022000390000000000420435000001e00200043d00000180022000390000000000020435000001e00200043d000001a0022000390000000000020435000000400400043d0000000002030433000b00000002001d0000000001010433000000000001004b000d00000004001d000e00200040003d000004930000c13d0000000d01000029000005cc0010009c000000800000213d0000000e01000029000104890000003d000015830000013d000005090000013d0000000d0100002900000005011002100000000901100029000000000401043300000008010000290000000e0200002915e012860000040f000d00000001001d000002930000013d0000000d02000029000005800020009c000000800000213d00000007020000290000000002020433000600000002001d0000000d030000290000004002300039000000400020043f00000010020000390000000000230435000005bf020000410000000e030000290000000000230435000027110010008c000004a70000413d000005a60100004100000000001004350000001101000039000000830000013d000027100110008915e012f10000040f000000400200043d0000002003200039000005c00400004100000000004304350000004f03200039000005c10400004100000000004304350000002f03200039000005c204000041000000000043043500000057042000390000000d0300002900000000030304330000000005000019000000000035004b000004be0000813d00000000064500190000000e07500029000104bd0000003d000014fb0000013d000004b70000013d0000000004430019000000000004043500000000032300190000005704300039000005c30500004100000000005404350000008c04300039000005c40500004100000000005404350000006c04300039000005c505000041000000000054043500000006040000290000002006400039000000a70530003900000000040404330000000007000019000000000047004b000004d50000813d0000000008570019000104d40000003d000014f10000013d000004cf0000013d000000000554001900000000000504350000000003340019000000c704300039000005c6050000410000000000540435000000a704300039000005c70500004100000000005404350000002005100039000000d50430003900000000010104330000000006000019000000000016004b000004e80000813d0000000007460019000104e70000003d000014dc0000013d000004e20000013d0000000004410019000000000004043500000000011300190000011503100039000005c8040000410000000000430435000000f503100039000005c9040000410000000000430435000000d503100039000005ca0400004100000000004304350000013203100039000005cb0400004100000000004304350000000001210049000001160310003900000000003204350000015501100039000000200300008a000000000131016f0000000003210019000000000013004b00000000010000190000000101004039000e00000003001d000005880030009c000000800000213d0000000100100190000000800000c13d0000000e01000029000000400010043f000d00000002001d0000000e01000029000005800010009c000000800000213d0000000e030000290001050f0000003d000015b10000013d000005cd02000041000000000021043500000008010000390000000000130435001700000000001d0000002001000039000002400010043f000000400200043d000005cc0020009c000000800000213d0000002001200039000000400010043f00000000000204350000000d0100002915e013910000040f000000000001004b0000009001000039000000d001006039000600000001001d15e012f10000040f000000400200043d000002400300043d0000000003230019000005ce04000041000105290000003d0000152c0000013d000000000056004b000005300000813d000000000746001900000000083600190001052f0000003d000014ed0000013d000005290000013d000105320000003d000015690000013d000005cf0600004100000000006504350000003505400039000005d006000041000105380000003d0000151f0000013d000000000017004b0000053e0000813d00000000085700190001053d0000003d000014f10000013d000005380000013d000105400000003d0000156e0000013d000005d10500004100000000005404350000008204100039000005d20500004100000000005404350000006204100039000005d30500004100000000005404350000004204100039000005d4050000410000000000540435000000e804100039000005d5050000410000000000540435000000c804100039000005d6050000410000000000540435000000a804100039000005d705000041000105550000003d000015890000013d000000000046004b0000055c0000813d000000000756001900000000083600190001055b0000003d000014ed0000013d000005550000013d0001055e0000003d000015640000013d000005d80400004100000000004304350000014003100039000005d90400004100000000004304350000012003100039000005d60400004100000000004304350000010003100039000005da04000041000000000043043500000151031000390000002701100039000002400400043d0000000b060000290001056f0000003d000015450000013d000000000046004b000005750000813d0000000007360019000105740000003d000014dc0000013d0000056f0000013d000105770000003d000015790000013d000005d8040000410001057a0000003d000015160000013d000000000046004b000005800000813d00000000073600190001057f0000003d000014dc0000013d0000057a0000013d000105820000003d0000157e0000013d000005cb04000041000105850000003d000014e10000013d000005880010009c000000800000213d0000000100300190000000800000c13d000000400010043f000001e00100043d00000100011000390000000000210435000001e00100043d000001200110003900000006020000290000000000210435000002400100043d0000001f01100039000000200200008a000000000221016f000000400100043d000e00000001001d0000000001120019000000000021004b00000000020000190000000102004039000005880010009c000000800000213d0000000100200190000000800000c13d00000009020000290000000002020433000b00000002001d000000400010043f0000000e010000290000000000010435000000400100043d000d00000001001d000005800010009c000000800000213d0000000d03000029000105ac0000003d000015b10000013d000005db02000041000000000021043500000006010000390000000000130435000000000103001915e014560000040f000600000001001d0000000b0100002915e0146b0000040f000000060010006b000000000201001900000006020020290000002801200039000600000001001d15e012f10000040f000000400200043d000002400300043d0000000003230019000005ce0400004100000000004304350000002704200039000002400300043d0000000d05000029000000000353001900000000050504330000000006000019000000000056004b000005cd0000813d00000000074600190000000008360019000105cc0000003d000014ed0000013d000005c60000013d000105cf0000003d000015690000013d000005cf0600004100000000006504350000003505400039000005d006000041000105d50000003d0000151f0000013d000000000017004b000005db0000813d0000000008570019000105da0000003d000014f10000013d000005d50000013d000105dd0000003d0000156e0000013d000005d10500004100000000005404350000008204100039000005d20500004100000000005404350000006204100039000005d30500004100000000005404350000004204100039000005d4050000410000000000540435000000e804100039000005d5050000410000000000540435000000c804100039000005d6050000410000000000540435000000a804100039000005d7050000410000000000540435000000f9051000390000000d0400002900000000040404330000000006000019000000000046004b000005fc0000813d00000000075600190000000008360019000105fb0000003d000014ed0000013d000005f50000013d000105fe0000003d000015640000013d000005d80400004100000000004304350000014003100039000005d90400004100000000004304350000012003100039000005d60400004100000000004304350000010003100039000005da04000041000000000043043500000151031000390000002701100039000002400400043d0000000b060000290001060f0000003d000015450000013d000000000046004b000006150000813d0000000007360019000106140000003d000014dc0000013d0000060f0000013d000106170000003d000015790000013d000005d804000041000000000043043500000131031000390000001b01100039000002400400043d0000000e060000290001061f0000003d000015450000013d000000000046004b000006250000813d0000000007360019000106240000003d000014dc0000013d0000061f0000013d000106270000003d0000157e0000013d000005cb040000410001062a0000003d000014e10000013d000005880010009c000000800000213d0000000100300190000000800000c13d000000400010043f000001e00100043d00000160011000390000000000210435000001e00100043d00000180011000390000000602000029000106370000003d000015340000013d000005880010009c000000800000213d0000000100200190000000800000c13d0000000c020000290000000002020433000c00000002001d000106400000003d000015830000013d000005800010009c000000800000213d0000000e03000029000106450000003d000015b10000013d000005dc02000041000000000021043500000006010000390001064a0000003d000015060000013d000005ce040000410001064d0000003d0000152c0000013d000000000056004b000006540000813d00000000074600190000000008360019000106530000003d000014ed0000013d0000064d0000013d000106560000003d000015690000013d000005cf0600004100000000006504350000003505400039000005d0060000410001065c0000003d0000151f0000013d000000000017004b000006620000813d0000000008570019000106610000003d000014f10000013d0000065c0000013d000106640000003d0000156e0000013d000005d10500004100000000005404350000008204100039000005d20500004100000000005404350000006204100039000005d30500004100000000005404350000004204100039000005d4050000410000000000540435000000e804100039000005d5050000410000000000540435000000c804100039000005d6050000410000000000540435000000a804100039000005d705000041000106790000003d000015890000013d000000000046004b000006800000813d000000000756001900000000083600190001067f0000003d000014ed0000013d000006790000013d000106820000003d000015640000013d000005d80400004100000000004304350000014003100039000005d90400004100000000004304350000012003100039000005d60400004100000000004304350000010003100039000005da04000041000000000043043500000151031000390000002701100039000002400400043d0000000c06000029000106930000003d000015450000013d000000000046004b000006990000813d0000000007360019000106980000003d000014dc0000013d000006930000013d0001069b0000003d000015790000013d000005d8040000410001069e0000003d000015160000013d000000000046004b000006a40000813d0000000007360019000106a30000003d000014dc0000013d0000069e0000013d000106a60000003d0000157e0000013d000005cb04000041000106a90000003d000014e10000013d000005880010009c000000800000213d0000000100300190000000800000c13d000000400010043f000001e00100043d0000000000210435000001e00100043d00000020011000390000000b02000029000106b50000003d000015340000013d000005880010009c000000800000213d0000000100200190000000800000c13d00000008020000290000000002020433000c00000002001d000106be0000003d000015830000013d000005800010009c000000800000213d0000000e03000029000106c30000003d000015b10000013d000005dd0200004100000000002104350000000801000039000106c80000003d000015060000013d000005ce04000041000106cb0000003d0000152c0000013d000000000056004b000006d20000813d00000000074600190000000008360019000106d10000003d000014ed0000013d000006cb0000013d000106d40000003d000015690000013d000005cf0600004100000000006504350000003505400039000005d006000041000106da0000003d0000151f0000013d000000000017004b000006e00000813d0000000008570019000106df0000003d000014f10000013d000006da0000013d000106e20000003d0000156e0000013d000005d10500004100000000005404350000008204100039000005d20500004100000000005404350000006204100039000005d30500004100000000005404350000004204100039000005d4050000410000000000540435000000e804100039000005d5050000410000000000540435000000c804100039000005d6050000410000000000540435000000a804100039000005d705000041000106f70000003d000015890000013d000000000046004b000006fe0000813d00000000075600190000000008360019000106fd0000003d000014ed0000013d000006f70000013d000107000000003d000015640000013d000005d80400004100000000004304350000014003100039000005d90400004100000000004304350000012003100039000005d60400004100000000004304350000010003100039000005da04000041000000000043043500000151031000390000002701100039000002400400043d0000000c06000029000107110000003d000015450000013d000000000046004b000007170000813d0000000007360019000107160000003d000014dc0000013d000007110000013d000107190000003d000015790000013d000005d8040000410001071c0000003d000015160000013d000000000046004b000007220000813d0000000007360019000107210000003d000014dc0000013d0000071c0000013d000107240000003d0000157e0000013d000005cb04000041000107270000003d000014e10000013d000005880010009c000000800000213d0000000100300190000000800000c13d000000400010043f000001e00100043d000000a0011000390000000000210435000001e00100043d000000c0011000390000000b030000290000000000310435000001e00100043d000000200210003900000000020204330000000002320019000001200310003900000000030304330000000002320019000001800310003900000000030304330000000002320019000000800110003900000030032000390000000000310435000003b8012000890000000101100270000001e00200043d00000140022000390000000000120435000001e00200043d000001200320003900000000030304330000000001130019000001a00220003900000010031000390000000000320435000001e00200043d000001800320003900000000030304330000000001130019000002400300043d000000000331001900000040022000390000000000320435000002400200043d0000000001210019000001e00200043d0000002003200039000000000303043300000000013100190000001001100039000000e0022000390000000000120435000001e00100043d000000a00210003900000000040204330000016002100039000000000202043300000000030104330000010001100039000000000101043315e012860000040f000001e00200043d00000060022000390000000000120435001601000000003d000000400100043d000002000010043f000005de0010009c000000800000213d0000010002100039000000400020043f000000c7020000390000000000210435000002400100043d000002000200043d0000000001120019000005df020000410000000000210435000002000100043d0000004001100039000005e0020000410000000000210435000002000100043d0000006001100039000005e1020000410000000000210435000002000100043d0000008001100039000005e2020000410000000000210435000002000100043d000000a001100039000005e3020000410000000000210435000002000100043d000000c001100039000005e4020000410000000000210435000002000100043d000000e001100039000005e502000041000000000021043500000007010000290000000003010433001500000003001d00000009010000290000000001010433000001a00010043f000001e00100043d00000060011000390000000001010433000001c00010043f001400600000003d000000400100043d000002200010043f000005e60010009c000000800000213d0000006002100039000000400020043f00000033020000390000000000210435000002400100043d000002200200043d0000000001120019000005e7020000410000000000210435000002200100043d0000004001100039000005e80200004100000000002104350000014001000039000002600010043f000000400100043d000000e00010043f000005bd0010009c000000800000213d0000014002100039000000400020043f0000011c020000390000000000210435000002400100043d000000e00200043d0000000001120019000005e9020000410000000000210435000000e00100043d0000004001100039000005ea020000410000000000210435000000e00100043d0000006001100039000005eb020000410000000000210435000000e00100043d0000008001100039000005ec020000410000000000210435000000e00100043d000000a001100039000005ed020000410000000000210435000000e00100043d000000c001100039000005ee020000410000000000210435000000e00100043d000000e001100039000005ef020000410000000000210435000000e00100043d0000010001100039000005f0020000410000000000210435000000e00100043d0000012001100039000005f1020000410000000000210435001303a00000003d000000400100043d000001200010043f000005f20010009c000000800000213d000003a002100039000000400020043f0000037b020000390000000000210435000002400100043d000001200200043d0000000001120019000005f3020000410000000000210435000001200100043d0000004001100039000005f4020000410000000000210435000001200100043d0000006001100039000005f5020000410000000000210435000001200100043d0000008001100039000005f6020000410000000000210435000001200100043d000000a001100039000005f7020000410000000000210435000001200100043d000000c001100039000005f8020000410000000000210435000001200100043d000000e001100039000005f9020000410000000000210435000001200100043d0000010001100039000005fa020000410000000000210435000001200100043d0000012001100039000005fb020000410000000000210435000002600100043d000001200200043d0000000001120019000005fc020000410000000000210435000001200100043d0000016001100039000005fd020000410000000000210435000001200100043d0000018001100039000005fe020000410000000000210435000001200100043d000001a001100039000005ff020000410000000000210435000001200100043d000001c00110003900000600020000410000000000210435000001200100043d000001e00110003900000601020000410000000000210435000001200100043d000002000110003900000602020000410000000000210435000001200100043d000002200110003900000603020000410000000000210435000001200100043d000002400110003900000604020000410000000000210435000001200100043d000002600110003900000605020000410000000000210435000001200100043d000002800110003900000606020000410000000000210435000001200100043d000002a00110003900000607020000410000000000210435000001200100043d000002c00110003900000608020000410000000000210435000001200100043d000002e00110003900000609020000410000000000210435000001200100043d00000300011000390000060a020000410000000000210435000001200100043d00000320011000390000060b020000410000000000210435000001200100043d00000340011000390000060c020000410000000000210435000001200100043d00000360011000390000060d020000410000000000210435000001200100043d00000380011000390000060e020000410000000000210435000000a001000039000001800010043f000000400100043d000001400010043f000005a80010009c000000800000213d000000a002100039000000400020043f00000075020000390000000000210435000002400100043d000001400200043d00000000011200190000060f020000410000000000210435000001400100043d000000400110003900000610020000410000000000210435000001400100043d000000600110003900000611020000410000000000210435000001400100043d000000800110003900000612020000410000000000210435000000400200043d000005800020009c000000800000213d000108750000003d0000159d0000013d000005bf04000041000000000041043500000010010000390000000000120435000000400100043d000002400400043d0000000004140019000006130500004100000000005404350000004004100039000006140500004100000000005404350000005e04100039000002400500043d000000000535001900000000060304330000000007000019000000000067004b0000088e0000813d00000000084700190000000009570019000000000909043300000000009804350000002007700039000008860000013d0000000004460019000000000004043500000000041600190000005e06400039000006150700004100000000007604350000007306400039000006160700004100000000007604350000009306400039000002400700043d000000000727001900000000020204330000000008000019000000000028004b000008a20000813d0000000009680019000108a10000003d000015400000013d0000089c0000013d000000000662001900000000000604350000000002420019000000930420003900000617060000410000000000640435000000a70420003900000618060000410000000000640435000000000212004900000098042000390000000000410435000000d702200039000000200400008a000000000242016f0000000004120019000000000024004b00000000020000190000000102004039000005880040009c000000800000213d0000000100200190000000800000c13d000000400040043f000005800040009c000000800000213d0000004002400039000000400020043f0000002002400039000005bf06000041000000000062043500000010020000390000000000240435000000400200043d000002400600043d00000000062600190000061907000041000000000076043500000040062000390000061a0700004100000000007604350000004d06200039000006140700004100000000007604350000006b0620003900000000030304330000000007000019000000000037004b000008d90000813d00000000086700190000000009570019000000000909043300000000009804350000002007700039000008d10000013d0000000006630019000000000006043500000000032300190000006b063000390000061b0700004100000000007604350000006e06300039000006160700004100000000007604350000008e06300039000002400700043d000000000747001900000000040404330000000008000019000000000048004b000008ed0000813d0000000009680019000108ec0000003d000015400000013d000008e70000013d0000000006640019000000000006043500000000033400190000008e043000390000061b06000041000000000064043500000091043000390000061c060000410000000000640435000000000323004900000082043000390000000000420435000000c103300039000000200400008a000000000343016f0000000004230019000000000034004b00000000030000190000000103004039000005880040009c000000800000213d0000000100300190000000800000c13d000000400040043f000005800040009c000000800000213d0000004003400039000000400030043f0000002003400039000005bf06000041000000000063043500000010030000390000000000340435000000400300043d000002400600043d00000000063600190000061d07000041000000000076043500000040063000390000061e07000041000000000076043500000054063000390000061f0700004100000000007604350000007306300039000002400700043d000000000747001900000000040404330000000008000019000000000048004b000009240000813d0000000009680019000109230000003d000015400000013d0000091e0000013d00000000066400190000000000060435000000000434001900000073064000390000061b0700004100000000007604350000007606400039000006160700004100000000007604350000009608400039000000150600002900000000070604330000000009000019000000000079004b000009390000813d000000000a890019000000000b590019000000000b0b04330000000000ba04350000002009900039000009310000013d00000000088700190000000000080435000000000447001900000096074000390000061b080000410000000000870435000000d90740003900000620080000410000000000870435000000b90740003900000621080000410000000000870435000000990740003900000622080000410000000000870435000000f7074000390000061c0800004100000000008704350000000004340049000000e80740003900000000007304350000012704400039000000200700008a000000000474016f0000000007340019000000000047004b00000000040000190000000104004039000005880070009c000000800000213d0000000100400190000000800000c13d000000400070043f000005800070009c000000800000213d0000004004700039000000400040043f0000002004700039000005bf08000041000000000084043500000010040000390000000000470435000000400400043d000002400800043d0000000008480019000006230900004100000000009804350000004008400039000006240900004100000000009804350000062508000041000e00140000002d00000014094000290000000000890435000000800840003900000626090000410000000000980435000000830840003900000627090000410000000000980435000000a20840003900000000060604330000000009000019000000000069004b000009800000813d000000000a890019000000000b590019000000000b0b04330000000000ba04350000002009900039000009780000013d000000000586001900000000000504350000000005460019000000a2065000390000061b080000410000000000860435000000a50650003900000628080000410000000000860435000000c406500039000002400800043d000000000878001900000000070704330000000009000019000000000079004b000009960000813d000000000a690019000000000b980019000000000b0b04330000000000ba043500000020099000390000098e0000013d000000000667001900000000000604350000000005570019000000c4065000390000061b070000410000000000760435000000c7065000390000061c0700004100000000007604350000000005450049000000b8065000390000000000640435000000f705500039000000200600008a000000000665016f0000000005460019000000000065004b00000000060000190000000106004039000005880050009c000000800000213d0000000100600190000000800000c13d000000400050043f15e012860000040f000001600010043f000000400200043d000005800020009c000000800000213d000109b50000003d0000159d0000013d0000059703000041000000000031043500000007010000390000000000120435000001a00100043d15e013910000040f000000000001004b000009c90000c13d000000400200043d000005800020009c000000800000213d000109c20000003d0000159d0000013d0000059a03000041000000000031043500000008010000390000000000120435000001a00100043d15e013910000040f000a00000001001d000000c001000039000001000010043f000000400100043d001200000001001d000005a90010009c000000800000213d000000c002100039000000400020043f00000090020000390000000000210435000002400200043d00000000021200190000062903000041000000000032043500000040021000390000062a0300004100000000003204350000000e021000290000062b03000041000000000032043500000080021000390000062c030000410000000000320435000001800200043d00000000011200190000062d020000410000000000210435000000400100043d000000c00010043f0000062e0010009c000000800000213d000002c002100039000000400020043f00000298020000390000000000210435000002400100043d000000c00200043d00000000011200190000062f020000410000000000210435000000c00100043d000000400110003900000630020000410000000000210435000000c00100043d0000000e0110002900000631020000410000000000210435000000c00100043d000000800110003900000632020000410000000000210435000001800100043d000000c00200043d000000000112001900000633020000410000000000210435000001000100043d000000c00200043d000000000112001900000634020000410000000000210435000000c00100043d000000e001100039000006350200004100000000002104350000001603000029000000c00100043d000000000131001900000636020000410000000000210435000000c00100043d000001200110003900000637020000410000000000210435000002600100043d000000c00200043d000000000112001900000638020000410000000000210435000000c00100043d000001600110003900000639020000410000000000210435000000c00100043d00000180011000390000063a020000410000000000210435000000c00100043d000001a0011000390000063b020000410000000000210435000000c00100043d000001c0011000390000063c020000410000000000210435000000c00100043d000001e0011000390000063d020000410000000000210435000000c00100043d00000200011000390000063e020000410000000000210435000000c00100043d00000220011000390000063f020000410000000000210435000000c00100043d000002400110003900000640020000410000000000210435000000c00100043d000002600110003900000641020000410000000000210435000000c00100043d000002800110003900000642020000410000000000210435000000c00100043d000002a00110003900000643020000410000000000210435000000400100043d0000000a0000006b00000a9f0000c13d000005be0010009c000000800000213d000001c002100039000000400020043f00000199020000390000000000210435000002400200043d0000000002120019000006530400004100000000004204350000004002100039000006540400004100000000004204350000000e0210002900000655040000410000000000420435000000800210003900000656040000410000000000420435000001800200043d000000000212001900000657040000410000000000420435000001000200043d000000000212001900000658040000410000000000420435000000e0021000390000065904000041000000000042043500000000023100190000065a04000041000000000042043500000120021000390000065b040000410000000000420435000002600200043d00000000021200190000065c040000410000000000420435000001a0021000390000065d04000041000000000042043500000180021000390000065e04000041000000000042043500000160021000390000065f040000410000000000420435001100000001001d000000400100043d000006600010009c000000800000213d0000012002100039000000400020043f000000f8020000390000000000210435000002400200043d0000000002120019000006610400004100000000004204350000004002100039000006620400004100000000004204350000000e0210002900000663040000410000000000420435000000800210003900000664040000410000000000420435000001800200043d000000000212001900000665040000410000000000420435000001000200043d000000000212001900000666040000410000000000420435000000e0021000390000066704000041000000000042043500000000043100190000000002000415000000100220008a0000000502200210000006680500004100000ae60000013d000002400200043d0000001f02200039000000200400008a000000000442016f0000000002140019000000000042004b00000000040000190000000104004039000005880020009c000000800000213d0000000100400190000000800000c13d000000400020043f00000017020000290000000000210435001100000001001d000000400100043d000006440010009c000000800000213d000001e002100039000000400020043f000001b1020000390000000000210435000002400200043d0000000002120019000006450400004100000000004204350000004002100039000006460400004100000000004204350000000e0210002900000647040000410000000000420435000000800210003900000648040000410000000000420435000001800200043d000000000212001900000649040000410000000000420435000001000200043d00000000021200190000064a040000410000000000420435000000e0021000390000064b04000041000000000042043500000000023100190000064c04000041000000000042043500000120021000390000064d040000410000000000420435000002600200043d00000000021200190000064e040000410000000000420435000001a0021000390000064f04000041000000000042043500000180021000390000065004000041000000000042043500000160021000390000065104000041000000000042043500000000020004150000000f0220008a00000005022002100000065205000041000001c00410003900000000005404350000000502200270000000000201001f000000400200043d000006690020009c000000800000213d000007e004200039000000400040043f000007a7040000390000000000420435000002400400043d00000000042400190000066a05000041000000000054043500000040042000390000066b0500004100000000005404350000000e042000290000066c05000041000000000054043500000080042000390000066d050000410000000000540435000001800400043d00000000042400190000066e050000410000000000540435000001000400043d00000000042400190000066f050000410000000000540435000000e00420003900000670050000410000000000540435000000000332001900000671040000410000000000430435000001200320003900000672040000410000000000430435000002600300043d000000000323001900000673040000410000000000430435000003800320003900000674040000410000000000430435000003600320003900000675040000410000000000430435000003400320003900000676040000410000000000430435000003200320003900000677040000410000000000430435000003000320003900000678040000410000000000430435000002e00320003900000679040000410000000000430435000002c0032000390000067a040000410000000000430435000002a0032000390000067b04000041000000000043043500000280032000390000067c04000041000000000043043500000260032000390000067d04000041000000000043043500000240032000390000067e04000041000000000043043500000220032000390000067f040000410000000000430435000002000320003900000680040000410000000000430435000001e00320003900000681040000410000000000430435000001c00320003900000682040000410000000000430435000001a00320003900000683040000410000000000430435000001800320003900000684040000410000000000430435000001600320003900000685040000410000000000430435000006860300004100000013042000290000000000340435000007c00320003900000687040000410000000000430435000007a0032000390000068804000041000000000043043500000780032000390000068904000041000000000043043500000760032000390000068a04000041000000000043043500000740032000390000068b04000041000000000043043500000720032000390000068c04000041000000000043043500000700032000390000068d040000410000000000430435000006e0032000390000068e040000410000000000430435000006c0032000390000068f040000410000000000430435000006a00320003900000690040000410000000000430435000006800320003900000691040000410000000000430435000006600320003900000692040000410000000000430435000006400320003900000693040000410000000000430435000006200320003900000694040000410000000000430435000006000320003900000695040000410000000000430435000005e00320003900000696040000410000000000430435000005c00320003900000697040000410000000000430435000005a0032000390000069804000041000000000043043500000580032000390000069904000041000000000043043500000560032000390000069a04000041000000000043043500000540032000390000069b04000041000000000043043500000520032000390000069c04000041000000000043043500000500032000390000069d040000410000000000430435000004e0032000390000069e040000410000000000430435000004c0032000390000069f040000410000000000430435000004a003200039000006a00400004100000000004304350000048003200039000006a10400004100000000004304350000046003200039000006a20400004100000000004304350000044003200039000006a30400004100000000004304350000042003200039000006a40400004100000000004304350000040003200039000006a5040000410000000000430435000003e003200039000006a6040000410000000000430435000003c003200039000006a7040000410000000000430435000000400300043d000002400400043d0000000004340019000006a80500004100000000005404350000003204300039000000120500002900010bb70000003d0000154e0000013d000000000057004b00000bbd0000813d000000000847001900010bbc0000003d000014f10000013d00000bb70000013d00000000044500190000000000040435000000c00500043d00010bc20000003d0000154e0000013d000000000057004b00000bc80000813d000000000847001900010bc70000003d000014f10000013d00000bc20000013d00000000044500190000000000040435000000110500002900010bcd0000003d0000154e0000013d000000000057004b00000bd30000813d000000000847001900010bd20000003d000014f10000013d00000bcd0000013d0000000004450019000000000004043500010bd70000003d000015ac0000013d000000000016004b00000bdd0000813d000000000746001900010bdc0000003d000014dc0000013d00000bd70000013d0000000001410019000000000001043500010be10000003d000015490000013d000000000025004b00000be70000813d000000000615001900010be60000003d000014f60000013d00000be10000013d0000000001120019000005cb02000041000000000021043500000000013100490000001c0210008a0000000000230435000000230110003900010bf00000003d000014c80000013d000005880010009c000000800000213d0000000100200190000000800000c13d000000400010043f000000a00010043f000002400200043d0000000001120019000006a9020000410000000000210435000002200100043d000002400200043d0000000002120019000000a00400043d000000260440003900000000010104330000000005000019000000000015004b00000c080000813d0000000006450019000000000752001900010c070000003d000014fb0000013d00000c010000013d00000000021400190000000000020435000000a00200043d0000000004120019000000e00100043d000002400200043d0000000002120019000000000101043300000026044000390000000005000019000000000015004b00000c190000813d0000000006450019000000000752001900010c180000003d000014fb0000013d00000c120000013d00000000014100190000000000010435000001200200043d00010c1e0000003d000015490000013d000000000025004b00000c240000813d000000000615001900010c230000003d000014f60000013d00000c1e0000013d00000000011200190000000000010435000001400200043d00010c290000003d000015490000013d000000000025004b00000c2f0000813d000000000615001900010c2e0000003d000014f60000013d00000c290000013d00000000011200190000000000010435000001600200043d00010c340000003d000015490000013d000000000025004b00000c3a0000813d000000000615001900010c390000003d000014f60000013d00000c340000013d00000000011200190000000000010435000002400200043d000000000432001900000000020304330000000003000019000000000023004b00000c480000813d0000000005130019000000000634001900000000060604330000000000650435000000200330003900000c400000013d00000000011200190000000000010435000001c00200043d000002400300043d000000000323001900000000020204330000000004000019000000000024004b00000c570000813d0000000005140019000000000643001900000000060604330000000000650435000000200440003900000c4f0000013d0000000001120019000006aa020000410000000000210435000000a00200043d0000000001210049000000190310008a00000000003204350000002601100039000000200200008a000000000221016f000000a00100043d0000000001120019000000000021004b00000000020000190000000102004039000005880010009c000000800000213d0000000100200190000000800000c13d000000400010043f000000180100002900000060021000390000000002020433000b00000002001d00000040021000390000000002020433000a00000002001d00000100021000390000000002020433000000e0011000390000000001010433000c00000001001d000d00000002001d15e013ef0000040f0000004002000039000000800020043f000000400300043d000005800030009c000000800000213d0000004002300039000000400020043f00000005020000390000000000230435000002400200043d0000000002320019000006ab04000041000000000042043500010c880000003d000015d60000013d000006ac050000410000000000540435000e00000006001d000000370460003900000000030304330000000005000019000000000035004b00000c950000813d0000000006450019000000000725001900010c940000003d000014fb0000013d00000c8e0000013d000000000243001900000000000204350000000e023000290000009703200039000006ad0400004100000000004304350000007703200039000006ae0400004100000000004304350000005703200039000006af0400004100000000004304350000003703200039000006b00400004100000000004304350000010903200039000006b1040000410000000000430435000000e903200039000006b2040000410000000000430435000000c903200039000006b3040000410000000000430435000000a903200039000006b40400004100010cb10000003d000015530000013d000000000015004b00000cb70000813d000000000635001900010cb60000003d000014f60000013d00000cb10000013d00010cb90000003d000015ba0000013d000006b50300004100000000003204350000000e0300002900010cbe0000003d000015db0000013d00010cc00000003d000014c80000013d000005880010009c000000800000213d0000000100200190000000800000c13d000000400010043f0000000c010000290000000d0200002915e013ef0000040f00010cca0000003d0000155a0000013d000005880030009c000000800000213d0000000100400190000000800000c13d000000400030043f00000002030000390000000000320435000002400300043d0000000003230019000006b604000041000000000043043500010cd70000003d000015d60000013d000006ac050000410000000000540435000d00000006001d000000370460003900000000020204330000000005000019000000000025004b00000ce40000813d0000000006450019000000000735001900010ce30000003d000014fb0000013d00000cdd0000013d000000000342001900000000000304350000000d022000290000009703200039000006ad0400004100000000004304350000007703200039000006ae0400004100000000004304350000005703200039000006af0400004100000000004304350000003703200039000006b00400004100000000004304350000010903200039000006b1040000410000000000430435000000e903200039000006b2040000410000000000430435000000c903200039000006b3040000410000000000430435000000a903200039000006b40400004100010d000000003d000015530000013d000000000015004b00000d060000813d000000000635001900010d050000003d000014f60000013d00000d000000013d00010d080000003d000015ba0000013d000006b50300004100000000003204350000000d0300002900010d0d0000003d000015db0000013d00010d0f0000003d000014c80000013d000005880010009c000000800000213d0000000100200190000000800000c13d000000400010043f0000000a010000290000000b0200002915e014240000040f00010d190000003d0000155a0000013d000005880030009c000000800000213d0000000100400190000000800000c13d000000400030043f00000004030000390000000000320435000002400300043d0000000003230019000006b704000041000000000043043500010d260000003d000015d60000013d000006ac050000410000000000540435000c00000006001d000000370460003900000000020204330000000005000019000000000025004b00000d330000813d0000000006450019000000000735001900010d320000003d000014fb0000013d00000d2c0000013d000000000342001900000000000304350000000c022000290000009703200039000006ad0400004100000000004304350000007703200039000006ae0400004100000000004304350000005703200039000006af0400004100000000004304350000003703200039000006b00400004100000000004304350000010903200039000006b1040000410000000000430435000000e903200039000006b2040000410000000000430435000000c903200039000006b3040000410000000000430435000000a903200039000006b40400004100010d4f0000003d000015530000013d000000000015004b00000d550000813d000000000635001900010d540000003d000014f60000013d00000d4f0000013d00010d570000003d000015ba0000013d000006b50300004100000000003204350000000c0300002900010d5c0000003d000015db0000013d00010d5e0000003d000014c80000013d000005880010009c000000800000213d0000000100200190000000800000c13d000000400010043f0000000a010000290000000b0200002915e014240000040f000000800200043d0000001f03200039000000200400008a000000000443016f00000000030204330000000002340019000000000042004b00000000040000190000000104004039000005880020009c000000800000213d0000000100400190000000800000c13d000000400020043f00000003020000390000000000230435000002400200043d0000000004320019000006b8020000410000000000240435000000800200043d0000000002020433000002400500043d0000000005250019000006ac060000410000000000650435000000370520003900000000030304330000000006000019000000000036004b00000d8a0000813d0000000007560019000000000846001900010d890000003d000014ed0000013d00000d830000013d0000000004530019000000000004043500000000032300190000009704300039000006ad0500004100000000005404350000007704300039000006ae0500004100000000005404350000005704300039000006af0500004100000000005404350000003704300039000006b00500004100000000005404350000010904300039000006b1050000410000000000540435000000e904300039000006b2050000410000000000540435000000c904300039000006b3050000410000000000540435000000a904300039000006b4050000410000000000540435000001200430003900010da80000003d000015ac0000013d000000000016004b00000dae0000813d000000000746001900010dad0000003d000014dc0000013d00000da80000013d0000000004410019000000000004043500000000013100190000012003100039000006b504000041000000000043043500000000012100490000010b0310003900000000003204350000014a01100039000000200300008a000000000331016f0000000001230019000000000031004b00000000030000190000000103004039000005880010009c000000800000213d0000000100300190000000800000c13d000000400010043f000000800100043d0000000004010433000002400100043d0000000001410019000006b9030000410000000000310435000000800100043d0000000001410019000006ba030000410000000000310435000b00000004001d0000004501400039000002400300043d0000000e05000029000000000453001900000000030504330000000005000019000000000035004b00000dda0000813d000000000615001900010dd90000003d000014f60000013d00000dd40000013d00000000011300190000000000010435000002400300043d0000000d05000029000000000453001900000000030504330000000005000019000000000035004b00000de70000813d000000000615001900010de60000003d000014f60000013d00000de10000013d00000000011300190000000000010435000002400300043d0000000c05000029000000000453001900000000030504330000000005000019000000000035004b00000df40000813d000000000615001900010df30000003d000014f60000013d00000dee0000013d00000000011300190000000000010435000002400300043d000000000323001900000000020204330000000004000019000000000024004b00000e020000813d0000000005140019000000000643001900000000060604330000000000650435000000200440003900000dfa0000013d0000000001120019000005d80200004100000000002104350000000b030000290000000001310049000000190210008a0000000000230435000000260110003900010e0c0000003d000014c80000013d000005880010009c000000800000213d0000000100200190000000800000c13d000000400010043f000001e00100043d000000e0021000390000000002020433000a00000002001d00000040021000390000000002020433000e00000002001d000001a0021000390000000002020433000d00000002001d0000014001100039000000000101043315e012f10000040f000c00000001001d0000000d0100002915e012f10000040f000d00000001001d0000000e0100002915e012f10000040f000e00000001001d0000000a0100002915e012f10000040f000000800200043d0000000003020433000002400200043d0000000002320019000006bb040000410000000000420435000000800400043d0000000004340019000006bc050000410000000000540435000006bd0400004100000065053000390000000000450435000006be04000041000000fc053000390000000000450435000006bf04000041000000dc053000390000000000450435000006c004000041000000bc053000390000000000450435000006c1040000410000009c053000390000000000450435000006c20400004100000045053000390000000000450435000006c3040000410000007c053000390000000000450435000006c4040000410000010e0530003900000000004504350000012704300039000002400500043d0000000c07000029000000000675001900000000050704330000000007000019000000000057004b00000e550000813d000000000847001900010e540000003d000014f10000013d00000e4f0000013d0000000004450019000000000004043500000000043500190000012705400039000006c50600004100000000006504350000013205400039000006c60600004100000000006504350000014905400039000002400600043d0000000d08000029000000000786001900000000060804330000000008000019000000000068004b00000e6a0000813d000000000958001900010e690000003d000015400000013d00000e640000013d0000000005560019000000000005043500000000044600190000014905400039000006c50600004100000000006504350000015405400039000006c70600004100000000006504350000016b05400039000002400600043d0000000e08000029000000000786001900000000060804330000000008000019000000000068004b00000e7f0000813d000000000958001900010e7e0000003d000015400000013d00000e790000013d0000000005560019000000000005043500000000046400190000016b05400039000006c50600004100000000006504350000017605400039000006c80600004100000000006504350000018f054000390000012704400039000002400600043d000000000616001900000000010104330000000007000019000000000017004b00000e940000813d000000000857001900010e930000003d000014f10000013d00000e8e0000013d0000000005510019000000000005043500000000011400190000006804100039000006c50500004100000000005404350000000001310049000000530410003900000000004304350000009201100039000000200400008a000000000441016f0000000001340019000000000041004b00000000040000190000000104004039000005880010009c000000800000213d0000000100400190000000800000c13d000000400010043f000000800100043d0000000001010433000002400400043d0000000004140019000006c9050000410000000000540435000000800400043d0000000004140019000006ca050000410000000000540435000006cb04000041000d00140000002d000000140510002900000000004504350000007b04100039000002000500043d00010ebb0000003d0000154e0000013d000000000057004b00000ec10000813d000000000847001900010ec00000003d000014f10000013d00000ebb0000013d00000000044500190000000000040435000000a00500043d00010ec60000003d0000154e0000013d000000000057004b00000ecc0000813d000000000847001900010ecb0000003d000014f10000013d00000ec60000013d00000000044500190000000000040435000002400500043d0000000b07000029000000000675001900000000050704330000000007000019000000000057004b00000ed90000813d000000000847001900010ed80000003d000014f10000013d00000ed30000013d0000000004450019000000000004043500000000030304330000000005000019000000000035004b00000ee40000813d0000000006450019000000000725001900010ee30000003d000014fb0000013d00000edd0000013d0000000002430019000006cc03000041000000000032043500000000021200490000001a0320008a0000000000310435000000250220003900010eed0000003d000014ff0000013d000005880020009c000000800000213d0000000100300190000000800000c13d000000400020043f000003c00010043f000000800100043d0000000001010433000002400200043d0000000003120019000003400200043d000006cd04000041000000000043043500000024060000390000000204600367000000000404043b000000240510003900000000004504350000000000610435000005e60010009c000000800000213d0000057d022001970000006004100039000000400040043f0000000004010433000e00170000002d0000000001000414000000040020008c00000f200000c13d0000000e040000290000001f0140018f000000200200008a000000000224016f000000000043004b00000f270000813d000000000002004b00000f1c0000613d00000000051300190000000e04100029000000200440008a000000200550008a0000000006240019000000000725001900000000070704330000000000760435000000200220008c00000f160000c13d000000000001004b00000f420000613d0000000e0400002900000f380000013d0000000e05000029000000000605001915e011690000040f000000000001004b0000000001000019000000010100c03900000f430000013d000000000002004b00000f340000613d000000200420008a000000200500008a000000000454016f0000000e0600002900000000046400190000002004400039000000000503001900000000570504340000000006760436000000000046004b00000f300000c13d000000000001004b00000f420000613d0000000e0420002900000000032300190000000301100210000000000204043300000000021201cf000000000212022f00000000030304330000010001100089000000000313022f00000000011301cf000000000121019f00000000001404350000000101000039000c00000001001d15e011ce0000040f000003200010043f0000000c020000290000000102200190000004000020043f00000f610000613d0000000003010433000002400200043d000006ce04200197000006ce05300197000000000645013f000000000045004b0000000004000019000006ce04004041000000000023004b0000000003000019000006ce03008041000006ce0060009c000000000403c019000000000004004b00000fbd0000613d00000000011200190000000002010433000000000002004b0000000001000019000000010100c039000000000012004b00000f620000613d00000fbd0000013d0000000101000039000000010110018f000002e00010043f000000800100043d0000000003010433000002a00100043d000b00000001001d000003400200043d000006cf01000041000000000013043500010f6d0000003d000015d20000013d000c00000003001d00000004033000390000000000130435000002400600043d00000000010004140000057d02200197000000040020008c00000f9d0000613d00000024040000390000000c03000029000000000503001915e011690000040f000000000001004b00000f9c0000c13d00000001020000310000000e01200029000000000021004b0000015c0000213d0000001f0320018f0000000e010000290000000304100367000000800100043d00000000010104330000000505200272000000050550021000000f8d0000613d0000000006510019000000000704034f000000000801001900010f8c0000003d000015a10000013d00000f8a0000c13d000000000003004b00000f9b0000613d000000000454034f00000000055100190000000303300210000000000605043300000000063601cf000000000636022f000000000404043b0000010003300089000000000434022f00000000033401cf000000000363019f000000000035043515e0148e0000040f000002400600043d000000010060007c000000010200003100000000020640190000001f01200039000000200300008a000000000331016f0000000c01300029000000000031004b00000000030000190000000103004039000005880010009c000000800000213d0000000100300190000000800000c13d000000000062004b0000000003000019000006ce03004041000006ce04600197000006ce02200197000000000542013f000000000042004b0000000002000019000006ce02002041000006ce0050009c000000000203c019000000400010043f000000000002004b00000fbd0000c13d0000000c0100002900000000010104330000057d0010009c00000fc00000a13d0000000e01000029000000000201001915e0148e0000040f15e012460000040f000000800200043d0000000005020433000002400200043d0000000003520019000003a00200043d000006d0040000410000000000430435000000800300043d000e00000005001d0000000003530019000002400400043d0000000b0600002900010fcf0000003d000015450000013d000000000046004b00000fd50000813d000000000736001900010fd40000003d000014dc0000013d00000fcf0000013d000000000343001900000000000304350000000e03400029000000800400043d0000000004340019000006d10500004100000000005404350000000d04300029000006d2050000410000000000540435000000630430003900010fe20000003d000015ac0000013d000000000016004b00000fe80000813d000000000746001900010fe70000003d000014dc0000013d00000fe20000013d000000000441001900000000000404350000000001310019000000800300043d00000000013100190000004303100039000006d20400004100000000004304350000002303100039000006d3040000410000000000430435000000460310003900010ff60000003d000015490000013d000000000025004b00000ffc0000813d000000000635001900010ffb0000003d000014f60000013d00000ff60000013d0000000003230019000000000003043500000000011200190000004602100039000006d40300004100000000003204350000000e030000290000000001310049000000290210003900000000002304350000006801100039000110090000003d000014c80000013d000005880010009c000000800000213d0000000100200190000000800000c13d000000400010043f000003800100043d000800000001001d000002a00100043d000c00000001001d000003600100043d000b00000001001d000002800100043d0000057d0110019715e012460000040f00000024020000390000000202200367000000000202043b000900000001001d000000000102001915e012f10000040f000700000001001d000000800100043d0000000003010433000002e00100043d000000000001004b000010340000c13d0000059e0030009c000000800000213d00000000040300190000008001400039000000400010043f0000005b010000390000000000140435000002400100043d0000000001410019000006da020000410000000000210435000000800100043d0000000001410019000006db020000410000000000210435000006dc01000041000010510000013d000001000100043d0000001f01100039000110380000003d000014c80000013d000005880010009c000000800000213d0000000100200190000000800000c13d000000400010043f0000009b0100003900000000040300190000000000140435000002400100043d0000000001410019000006d5020000410000000000210435000000800100043d0000000001410019000006d60200004100000000002104350000000d01400029000006d70200004100000000002104350000008001400039000006d8020000410000000000210435000006d901000041000001800200043d000d00000002001d000600000003001d0000000d023000290000000000120435000000800100043d0000000004010433000d00000004001d000002400100043d0000000002410019000a00000002001d000006dd010000410000000000120435000000800100043d0000000001410019000006de020000410000000000210435000002400100043d0000000b020000290000000001210019000400000001001d0000000003020433000500000003001d000000550240003915e0119c0000040f00000005020000290000000d04200029000300000004001d000006df0100004100000095024000390000000000120435000006e00100004100000075024000390000000000120435000006e10100004100000055024000390000000000120435000002400100043d0000000c020000290000000001210019000500000001001d0000000003020433000200000003001d000000b10240003915e0119c0000040f00000002020000290000000304200029000300000004001d000006e201000041000000b1024000390000000000120435000002400100043d000000070200002900000000012100190000000003020433000700000003001d000000c30240003915e0119c0000040f00000007020000290000000304200029000700000004001d000006e302000041000000c30140003900000000002104350000000b010000290000000003010433000b00000003001d000000c702400039000000040100002915e0119c0000040f0000000b020000290000000704200029000b00000004001d000006e402000041000000c7014000390000000000210435000002400100043d000000080200002900000000012100190000000003020433000800000003001d000000d10240003915e0119c0000040f0000000b0100002900000055011000390000000804100029000b00000004001d0000007c01400039000006e30200004100000000002104350000000c010000290000000003010433000c00000003001d0000008002400039000000050100002915e0119c0000040f0000000b010000290000005c011000390000000c04100029000c00000004001d0000002401400039000006e4020000410000000000210435000002400100043d000000090200002900000000012100190000000003020433000b00000003001d0000002e0240003915e0119c0000040f0000000c0100002900000012011000390000000b04100029000c00000004001d000006e5010000410000001c024000390000000000120435000002400100043d000000060200002900000000012100190000000003020433000b00000003001d000000200240003915e0119c0000040f0000000d010000290000000b031000690000000c0200002900000004022000390000000003320019000000040230008a00000000002104350000001c0230003915e011bb0000040f000110d60000003d000015d20000013d000003600200043d000c00000002001d15e012f10000040f000000800200043d0000000004020433000b00000004001d000002400200043d0000000003420019000900000003001d000006e6020000410000000000230435000002400200043d0000000c0300002900000000053200190000000003030433000c00000003001d000800000001001d0000002b02400039000000000105001915e0119c0000040f000006e7010000410000000c030000290000000b023000290000002b032000390000000000130435000002400100043d000000080300002900000000013100190000002d022000390000000003030433000800000003001d15e0119c0000040f00000008020000290000000c032000290000000d023000390000000b0100002900000000002104350000002d0230003915e011bb0000040f000003c00100043d15e013210000040f000000800200043d0000000005020433000c00000005001d000002400200043d0000000002520019000006e8030000410000000000320435000002400200043d0000000e0400002900000000064200190000000003040433000800000003001d000e00000001001d0000002e02500039000000000106001915e0119c0000040f00000008020000290000000c04200029000800000004001d000006e9010000410000002e0240003900000000001204350000000d010000290000000003010433000d00000003001d0000003e024000390000000a0100002915e0119c0000040f0000000d020000290000000804200029000d00000004001d000006ea010000410000005e024000390000000000120435000006eb010000410000003e0240003900000000001204350000000b010000290000000003010433000b00000003001d0000006d02400039000000090100002915e0119c0000040f0000000b020000290000000d04200029000d00000004001d000006ec010000410000008d024000390000000000120435000006ed010000410000006d024000390000000000120435000002400100043d0000000e0200002900000000012100190000000003020433000e00000003001d000000920240003915e0119c0000040f0000000e020000290000000d04200029000006ee02000041000000920340003900000000002304350000000c01000029000000000314004900000074023000390000000000210435000000940230003915e011bb0000040f0000000c01000029000003000010043f15e013210000040f000000800200043d0000000004020433000e00000004001d000002400200043d0000000002420019000006ef030000410000000000320435000002400200043d00000000051200190000000003010433000d00000003001d0000003d02400039000000000105001915e0119c0000040f0000000d030000290000001d023000390000000e0100002900000000002104350000003d0230003915e011bb0000040f000000800100043d0000000002010433000d00000002001d000002400100043d0000000000120435000002400100043d00000000022100190000000e0100002915e011a80000040f0000000d0210006a0000000d01000029000000000300001915e014960000040f0003000000000002000300000006001d000200000005001d000005790030009c00000579030080410000004003300210000005790040009c00000579040080410000006004400210000000000334019f000005790010009c0000057901008041000000c001100210000000000113019f15e014c30000040f000000020a000029000000000301001900000060033002700000057903300197000000030030006c000000030500002900000000050340190000001f0450018f00000005055002720000000505500210000011890000613d00000000065a0019000000000701034f00000000080a0019000111880000003d000015a10000013d000011860000c13d000000010220018f000000000004004b000011980000613d000000000651034f00000000055a00190000000304400210000000000705043300000000074701cf000000000747022f000000000606043b0000010004400089000000000646022f00000000044601cf000000000474019f0000000000450435000100000003001f00030000000103550000000001020019000000000001042d0000000004000019000000000034004b000011a50000813d000000000524001900000000061400190000000006060433000000000065043500000020044000390000119d0000013d00000000012300190000000000010435000000000001042d0000002004100039000000000301043300000000013204360000000002000019000000000032004b000011b40000813d00000000051200190000000006240019000000000606043300000000006504350000002002200039000011ac0000013d000000000213001900000000000204350000001f02300039000000200300008a000000000232016f0000000001210019000000000001042d0000001f02200039000000200300008a000000000232016f0000000001120019000000000021004b00000000020000190000000102004039000005880010009c000011c80000213d0000000100200190000011c80000c13d000000400010043f000000000001042d000005a60100004100000000001004350000004101000039000000040010043f000005af01000041000015e20001043000010000000000020000000102000032000011fd0000613d000006f10020009c000011ff0000813d0000001f01200039000000200300008a000000000131016f0000003f01100039000000000331016f000000400100043d0000000003310019000000000013004b00000000040000190000000104004039000005880030009c000011ff0000213d0000000100400190000011ff0000c13d000000400030043f0000001f0320018f0000000004210436000000030500036700000005022002720000000502200210000011ee0000613d0000000006240019000000000705034f0000000008040019000111ed0000003d000015a10000013d000011eb0000c13d000000000003004b000011fe0000613d000000000525034f00000000022400190000000303300210000000000402043300000000043401cf000000000434022f000000000505043b0000010003300089000000000535022f00000000033501cf000000000343019f0000000000320435000000000001042d0000006001000039000000000001042d000005a60100004100000000001004350000004101000039000000040010043f000005af01000041000015e2000104300000000003120049000006f20030009c0000123e0000213d0000001f0030008c0000123e0000a13d0000000003010433000005880030009c0000123e0000213d00000000011300190000001f03100039000000000023004b0000000004000019000006ce04008041000006ce03300197000006ce05200197000000000653013f000000000053004b0000000003000019000006ce03004041000006ce0060009c000000000304c019000000000003004b0000123e0000c13d0000000043010434000006f10030009c000012400000813d0000001f01300039000000200500008a000000000151016f0000003f01100039000000000551016f000000400100043d0000000005510019000000000015004b00000000060000190000000106004039000005880050009c000012400000213d0000000100600190000012400000c13d000000400050043f00000000053104360000000006340019000000000026004b0000123e0000213d0000000002000019000000000032004b0000123b0000813d00000000065200190000000007240019000000000707043300000000007604350000002002200039000012330000013d00000000023500190000000000020435000000000001042d0000000001000019000015e200010430000005a60100004100000000001004350000004101000039000000040010043f000005af01000041000015e2000104300000000002010019000000400100043d000006f30010009c0000127b0000813d0000057d022001970000006004100039000000400040043f0000002a030000390000000003310436000000000500003100000002055003670000000006030019000000005705043c0000000006760436000000000046004b000012520000c13d0000000004030433000006f404400197000005b2044001c7000000000043043500000021041000390000000005040433000006f405500197000006f5055001c7000000000054043500000029060000390000000004020019000000010560008c000012720000a13d0000000007010433000000000067004b000012750000a13d00000000063600190000000007060433000006f4077001970000000308400210000000780880018f000006f80880021f000006f908800197000000000787019f000000000076043500000004044002700000000006050019000012610000013d000000000004004b0000127f0000c13d000000000001042d000005a60100004100000000001004350000003201000039000000040010043f000005af01000041000015e200010430000005a60100004100000000001004350000004101000039000012780000013d000006f6010000410000000000100435000000040020043f0000001401000039000000240010043f000006f701000041000015e200010430000100000000000200000000050100190000002006500039000000400100043d000000200710003900000000050504330000000008000019000000000058004b000012950000813d0000000009780019000000000a860019000000000a0a04330000000000a9043500000020088000390000128d0000013d00000000057500190000002006200039000000000005043500000000020204330000000007000019000000000027004b000012a00000813d00000000085700190001129f0000003d000014f10000013d0000129a0000013d00000000025200190000002005300039000000000002043500000000030304330000000006000019000000000036004b000012ab0000813d0000000007260019000112aa0000003d000014dc0000013d000012a50000013d00000000022300190000002003400039000000000002043500000000040404330000000005000019000000000045004b000012b70000813d00000000062500190000000007530019000112b60000003d000014fb0000013d000012b00000013d000000000224001900000000000204350000000002120049000000200320008a00000000003104350000001f02200039000112bf0000003d000014ff0000013d000005880020009c000012c50000213d0000000100300190000012c50000c13d000000400020043f000000000001042d000005a60100004100000000001004350000004101000039000000040010043f000005af01000041000015e2000104300000000002010019000006f10020009c000012eb0000813d0000001f01200039000000200400008a000000000341016f0000003f01300039000000000441016f000000400100043d0000000004410019000000000014004b00000000050000190000000105004039000005880040009c000012eb0000213d0000000100500190000012eb0000c13d000000400040043f00000000042104360000001f0230018f0000000500300272000012e80000613d000000000500003100000002055003670000000003340019000000005605043c0000000004640436000000000034004b000012e40000c13d000000000002004b000012ea0000613d000000000001042d000005a60100004100000000001004350000004101000039000000040010043f000005af01000041000015e2000104300002000000000002000006fa0010009c000012f70000413d0000004003000039000006fa0210012a000013000000013d000006fc0010009c0000000002010019000006fb0220212a00000000030000190000002003002039000006fd0020009c00000010033081bf0000059502208197000006fd0220812a000006fe0020009c00000008033080390000058802208197000006fe0220812a000027100020008c00000004033080390000057902208197000027100220811a000000640020008c000200000001001d00000002033080390000ffff0120818f000000640210811a000000090020008c0000000103302039000100000003001d000000010130003915e012cb0000040f000000010210002900000021022000390000000205000029000000090050008c0000000a3550011a0000000303300210000000010220008a0000000004020433000006f404400197000006f80330021f000006f903300197000000000334019f0000000000320435000013150000213d000000000001042d0003000000000002000000400b00043d0000000002010433000000000002004b0000137a0000613d000005e600b0009c000013870000213d0000006002b00039000000400020043f0000004003b00039000006ff0200004100000000002304350000002003b0003900000700020000410000000000230435000000400200003900000000002b04350000000002010433000007010020009c00020000000b001d000300000001001d0000138b0000813d0000000201200039000000030110011a000000020110021015e012cb0000040f000000030c00002900000000020c04330000000002c2001900000002030000290000000103300039000000000b0100190000002001b0003900000020042000390000000005040433000000000004043500000000060c0019000000000026004b0000136c0000813d0000000306600039000000000706043300000012087002700001134d0000003d000015b50000013d0000000009010433000006f409900197000000000889019f00000000008104350000000c08700270000113540000003d000015b50000013d0000000109100039000000000a090433000006f40aa0019700000000088a019f000000000089043500000006087002700001135c0000003d000015b50000013d0000000209100039000000000a090433000006f40aa0019700000000088a019f00000000008904350000003f0770018f00000000077300190000000007070433000000f80770021000000003081000390000000009080433000006f409900197000000000779019f00000000007804350000000401100039000013460000013d000000000054043500000000020c0433000000032020011a000000020020008c000013800000613d000000010020008c000013850000c13d000000010210008a0000000003020433000006f40330019700000702033001c70000000000320435000000020110008a000013810000013d0000070300b0009c000013870000813d0000002001b00039000000400010043f00000000000b0435000013850000013d000000010110008a0000000002010433000006f40220019700000702022001c7000000000021043500000000010b0019000000000001042d000005a601000041000000000010043500000041010000390000138e0000013d000005a60100004100000000001004350000001101000039000000040010043f000005af01000041000015e200010430000300000000000200000000130104340000000042020434000000000023004b0000000002000019000013a20000c13d0000000002030019000200000003001d000100000004001d15e014a00000040f000300000001001d0000000101000029000000020200002915e014a00000040f000000030010006b00000000020000190000000102006039000000010120018f000000000001042d0002000000000002000000000001004b000013bc0000613d000200000001001d15e012f10000040f00000000020100190000002003200039000000400100043d000000200410003900000002050000290000000a0050008c000013c30000413d00000705050000410000000000540435000000210410003900000000020204330000000005000019000000000025004b000013cf0000813d00000000064500190000000007530019000113bb0000003d000014fb0000013d000013b50000013d000000400100043d000005cc0010009c000013e90000213d0000002002100039000000400020043f0000000000010435000000000001042d00000704050000410000000000540435000000220410003900000000020204330000000005000019000000000025004b000013dc0000813d00000000064500190000000007530019000113ce0000003d000014fb0000013d000013c80000013d0000000003420019000000000003043500000001032000390000000000310435000000200300008a000000000232016f00000000022100190000004002200039000005880020009c000013e90000213d000000000012004b000013e70000813d000013e90000013d00000000034200190000000000030435000000020320003900000000003104350000004102200039000113e30000003d000014ff0000013d000005880020009c000013e90000213d0000000100300190000013e90000c13d000000400020043f000000000001042d000005a60100004100000000001004350000004101000039000000040010043f000005af01000041000015e200010430000100000000000200000000030100190000002004300039000000400100043d000000200510003900000000030304330000000006000019000000000036004b000013fd0000813d00000000075600190000000008640019000113fc0000003d000014ed0000013d000013f60000013d0000000004530019000000000004043500000000041300190000002005400039000007060600004100000000006504350000002505400039000006e60600004100000000006504350000002005200039000000300440003900000000020204330000000006000019000000000026004b000014100000813d00000000074600190001140f0000003d000014dc0000013d0000140a0000013d000000000442001900000000000404350000000002230019000000100320003900000000003104350000004f02200039000114180000003d000014ff0000013d000005880020009c0000141e0000213d00000001003001900000141e0000c13d000000400020043f000000000001042d000005a60100004100000000001004350000004101000039000000040010043f000005af01000041000015e200010430000100000000000200000000030100190000002004300039000000400100043d000000200510003900000000030304330000000006000019000000000036004b000014320000813d00000000075600190000000008640019000114310000003d000014ed0000013d0000142b0000013d0000000004530019000000000004043500000000041300190000002005400039000007060600004100000000006504350000002005200039000000250440003900000000020204330000000006000019000000000026004b000014420000813d0000000007460019000114410000003d000014dc0000013d0000143c0000013d0000000004420019000000000004043500000000022300190000000503200039000000000031043500000044022000390001144a0000003d000014ff0000013d000005880020009c000014500000213d0000000100300190000014500000c13d000000400020043f000000000001042d000005a60100004100000000001004350000004101000039000000040010043f000005af01000041000015e2000104300000000021010434000000000001004b000014690000613d00000000030000190000000004000019000000000014004b000014640000813d000000000542001900000000050504330000058a05500197000007070050009c000000000304601900000001044000390000145b0000013d0000000d0200008a00000000022300a90000000d011000c90000000001120019000000000001042d0000000001000019000000000001042d0000000021010434000000000001004b0000147c0000613d00000000030000190000000004000019000000000014004b000014790000813d000000000542001900000000050504330000058a05500197000007070050009c00000000030460190000000104400039000014700000013d00000000013100490000000401100210000000000001042d0000000001000019000000000001042d0000000002010019000000000002004b0000148b0000613d0000000a030000390000000101000039000000010020019000000000043300a9000000010300603900000000011300a900000001022002720000000003040019000014830000c13d000000000001042d0000000101000039000000000001042d000000000001042f000005790010009c00000579010080410000004001100210000005790020009c00000579020080410000006002200210000000000112019f000015e200010430000005790010009c00000579010080410000004001100210000005790020009c00000579020080410000006002200210000000000112019f000000e002300210000000000121019f000015e10001042e000005790010009c00000579010080410000004001100210000005790020009c00000579020080410000006002200210000000000112019f0000000002000414000005790020009c0000057902008041000000c002200210000000000112019f00000708011001c7000080100200003915e014c30000040f0000000100200190000014b30000613d000000000101043b000000000001042d0000000001000019000015e200010430000007090100004100000000001004390000000001000414000005790010009c0000057901008041000000c0011002100000070a011001c70000800b0200003915e014c30000040f0000000100200190000014c20000613d000000000101043b000000000001042d000000000001042f000014c6002104230000000102000039000000000001042d0000000002000019000000000001042d000000200200008a000000000221016f0000000001320019000000000021004b00000000020000190000000102004039000000010000013b000000000353034f00000000055100190000000304400210000000000605043300000000064601cf000000000646022f000000000303043b0000010004400089000000000343022f00000000034301cf000000000363019f0000000000350435000000010000013b0000000008650019000000000808043300000000008704350000002006600039000000010000013b00000000004304350000000001210049000000fa0310003900000000003204350000013901100039000000200300008a000000000331016f0000000001230019000000000031004b00000000030000190000000103004039000000010000013b000000000808043300000000008704350000002006600039000000010000013b0000000009760019000000000909043300000000009804350000002007700039000000010000013b0000000007540019000000000707043300000000007604350000002005500039000000010000013b000000000707043300000000007604350000002005500039000000010000013b000000200300008a000000000332016f0000000002130019000000000032004b00000000030000190000000103004039000000010000013b0000000000130435000000000103001915e014560000040f000b00000001001d0000000c0100002915e0146b0000040f0000000b0010006b00000000020100190000000b020020290000002801200039000b00000001001d15e012f10000040f000000400200043d000002400300043d0000000003230019000000010000013b000000000043043500000131031000390000001b01100039000002400400043d0000000d06000029000000000564001900000000040604330000000006000019000000010000013b00000000006504350000004205400039000002400600043d000000000616001900000000010104330000000007000019000000010000013b000000200020008c000000200100003900000000010240190000001f01100039000000600410018f000000010000013b00000000004304350000002704200039000002400300043d0000000e05000029000000000353001900000000050504330000000006000019000000010000013b0000000000210435000002400100043d0000001f01100039000000200200008a000000000221016f000000400100043d000d00000001001d0000000001120019000000000021004b00000000020000190000000102004039000000010000013b000000000a870019000000000a0a04330000000000a904350000002008800039000000010000013b000000000564001900000000040604330000000006000019000000010000013b000002400400043d000000000424001900000000020204330000000005000019000000010000013b000002400600043d000000000656001900000000050504330000000007000019000000010000013b00000000004304350000012003200039000002400400043d000000000414001900000000010104330000000005000019000000010000013b000000800200043d0000001f03200039000000200400008a000000000443016f00000000020204330000000003240019000000000043004b00000000040000190000000104004039000000010000013b000000000354001900000000000304350000000001410019000000f903100039000000010000013b0000000004450019000000000004043500000000042500190000002705400039000000010000013b000000000551001900000000000504350000000001410019000000a204100039000000010000013b0000000303000367000000400100043d0000001f0420018f00000005052002720000000505500210000000010000013b0000000003340019000000000003043500000000014100190000012a03100039000000010000013b0000000003340019000000000003043500000000014100190000011603100039000000010000013b000000400010043f0000000d010000290000000000010435000000400100043d000e00000001001d000000010000013b0000000000540435000000f9051000390000000e0400002900000000040404330000000006000019000000010000013b0000000000120435000000400300043d000000200230003900000000001204350000002401300039000000010000013b0000000000310435000000110100003900000000001204350000000d0100002915e013910000040f000000400200043d000000000001004b000000010000013b0000004001200039000000400010043f0000002001200039000000010000013b000000007907043c0000000008980436000000000068004b000000010000013b000000000015043500000024010000390000000201100367000000000101043b00000004055000390000000000150435000000010000013b000002400500043d000000000515001900000000010104330000000006000019000000010000013b0000004001300039000000400010043f0000002001300039000000010000013b0000003f0880018f00000000088300190000000008080433000000f808800210000000010000013b0000000003310019000000000003043500000000012100190000012002100039000000010000013b0000000005000019000000000600001915e011690000040f000000000001004b00000000010000190000000101006039000000010000013b000000000503001915e011690000040f0000000102000031000000000001004b000000010000013b000000240400003900000020060000390000000e03000029000000000503001915e011690000040f000000000001004b000000010000013b00000024010000390000000201100367000000000101043b000000010000013b000000800400043d0000000006040433000002400400043d0000000004640019000000010000013b00000000013100490000010b0210003900000000002304350000014a01100039000000010000013b000015e000000432000015e10001042e000015e200010430000000000000000000000000000000000000000000000000000000000000000000000000ffffffff0000000200000000000000000000000000000040000001000000000000000000ffffffff00000000000000000000000000000000000000000000000000000000e9dc637500000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffff95d89b4100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fffffffffffffbe0000000000000000000000000000000000000000000000000ffffffffffffffbf5341422d56322d4c4f434b55502d4c494e0000000000000000000000000000004c6f636b7570204c696e656172000000000000000000000000000000000000005341422d56322d4c4f434b55502d44594e0000000000000000000000000000004c6f636b75702044796e616d69630000000000000000000000000000000000005341422d56322d4c4f434b55502d5452410000000000000000000000000000004c6f636b7570205472616e636865640000000000000000000000000000000000eac8f5b800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffff4c6f6e672053796d626f6c000000000000000000000000000000000000000000ff0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002d00000000000000000000000000000000000000000000000000000000000000df000000000000000000000000000000000000000000000000000000000000005a000000000000000000000000000000000000000000000000000000000000013900000000000000000000000000000000000000000000000000000000000001f6fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffee6ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff556e737570706f727465642053796d626f6c00000000000000000000000000004552433230000000000000000000000000000000000000000000000000000000a80fc0710000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffad35efd400000000000000000000000000000000000000000000000000000000536574746c65640000000000000000000000000000000000000000000000000053747265616d696e67000000000000000000000000000000000000000000000043616e63656c65640000000000000000000000000000000000000000000000004465706c6574656400000000000000000000000000000000000000000000000050656e64696e67000000000000000000000000000000000000000000000000004869e12d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000ffffffffffffff7f68736c28000000000000000000000000000000000000000000000000000000002c00000000000000000000000000000000000000000000000000000000000000252c0000000000000000000000000000000000000000000000000000000000002529000000000000000000000000000000000000000000000000000000000000313ce56700000000000000000000000000000000000000000000000000000000266c743b0000000000000000000000000000000000000000000000000000000020310000000000000000000000000000000000000000000000000000000000004e487b710000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000038d7ea4c68000000000000000000000000000000000000000000000000000ffffffffffffff5f000000000000000000000000000000000000000000000000ffffffffffffff3f4b000000000000000000000000000000000000000000000000000000000000004d00000000000000000000000000000000000000000000000000000000000000420000000000000000000000000000000000000000000000000000000000000054000000000000000000000000000000000000000000000000000000000000002623383830353b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000240000000000000000000000002667743b00000000000000000000000000000000000000000000000000000000203939392e3939540000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000bc2be1be00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffff9067b67700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001518000000000000000000000000000000000000000000000000000000000337f980020446179000000000000000000000000000000000000000000000000000000002044617973000000000000000000000000000000000000000000000000000000203939393920446179730000000000000000000000000000000000000000000020312044617900000000000000000000000000000000000000000000000000002500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fffffffffffffebf000000000000000000000000000000000000000000000000fffffffffffffe3f68736c283233302c3231252c31312529000000000000000000000000000000003c672066696c6c3d226e6f6e65223e00000000000000000000000000000000007374726f6b653d220000000000000000000000000000000000000000000000003c636972636c652063783d22313636222063793d2235302220723d223232222022207374726f6b652d77696474683d223130222f3e00000000000000000000006774683d2231303030302220723d22323222207374726f6b653d2200000000003c636972636c652063783d22313636222063793d2235302220706174684c656e652d646173686f66667365743d2200000000000000000000000000000000000022207374726f6b652d6461736861727261793d22313030303022207374726f6b22207472616e73666f726d2d6f726967696e3d22313636203530222f3e00000077696474683d223522207472616e73666f726d3d22726f74617465282d39302922207374726f6b652d6c696e656361703d22726f756e6422207374726f6b652d3c2f673e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffdf50726f67726573730000000000000000000000000000000000000000000000003c672069643d2200000000000000000000000000000000000000000000000000222066696c6c3d2223666666223e0000000000000000000000000000000000003c726563742077696474683d22000000000000000000000000000000000000003d2234222f3e00000000000000000000000000000000000000000000000000007374726f6b652d6f7061636974793d222e3122207374726f6b652d7769647468222072783d223135222072793d22313522207374726f6b653d2223666666222022206865696768743d22313030222066696c6c2d6f7061636974793d222e3033666f6e742d73697a653d2232327078223e0000000000000000000000000000002227436f7572696572204e6577272c417269616c2c6d6f6e6f737061636522203c7465787420783d2232302220793d2233342220666f6e742d66616d696c793d3c2f746578743e00000000000000000000000000000000000000000000000000666f6e742d73697a653d2232367078223e0000000000000000000000000000003c7465787420783d2232302220793d2237322220666f6e742d66616d696c793d5374617475730000000000000000000000000000000000000000000000000000416d6f756e7400000000000000000000000000000000000000000000000000004475726174696f6e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fffffffffffffeff3c726563742077696474683d223130302522206865696768743d2231303025222066696c7465723d2275726c28234e6f69736529222f3e3c7265637420783d2237302220793d223730222077696474683d2238363022206865696768743d22383630222066696c6c3d2223666666222066696c6c2d6f7061636974793d222e3033222072783d223435222072793d22343522207374726f6b653d222366666622207374726f6b652d6f7061636974793d222e3122207374726f6b652d77696474683d2234222f3e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffff9f3c636972636c652069643d22476c6f772220723d22353030222066696c6c3d2275726c282352616469616c476c6f7729222f3e000000000000000000000000003c66696c7465722069643d224e6f697365223e3c6665466c6f6f6420783d22302220793d2230222077696474683d223130302522206865696768743d22313030252220666c6f6f642d636f6c6f723d2268736c283233302c3231252c313125292220666c6f6f642d6f7061636974793d22312220726573756c743d22666c6f6f6446696c6c222f3e3c666554757262756c656e636520626173654672657175656e63793d222e3422206e756d4f6374617665733d22332220726573756c743d224e6f6973652220747970653d226672616374616c4e6f697365222f3e3c6665426c656e6420696e3d224e6f6973652220696e323d22666c6f6f6446696c6c22206d6f64653d22736f66742d6c69676874222f3e3c2f66696c7465723e00000000000000000000000000000000000000000000000000000000fffffffffffffc5f3c706174682069643d224c6f676f222066696c6c3d2223666666222066696c6c2d6f7061636974793d222e312220643d226d3133332e3535392c3132342e303334632d2e3031332c322e3431322d312e3035392c342e3834382d322e3932332c362e3430322d322e3535382c312e3831392d352e3136382c332e3433392d372e3838382c342e3939362d31342e34342c382e3236322d33312e3034372c31322e3536352d34372e3637342c31322e3536392d382e3835382e3033362d31372e3833382d312e3237322d32362e3332382d332e3636332d392e3830362d322e3736362d31392e3038372d372e3131332d32372e3536322d31322e3737382d31332e3834322d382e3032352c392e3436382d32382e3630362c31362e3135332d33352e323635683063322e3033352d312e3833382c342e3235322d332e3534362c362e3436332d352e323234683063362e3432392d352e3635352c31362e3231382d322e3833352c32302e3335382c342e31372c342e3134332c352e3035372c382e3831362c392e3634392c31332e39322c31332e373334682e30333763352e3733362c362e3436312c31352e3335372d322e3235332c392e33382d382e34382c302c302d332e3531352d332e3531352d332e3531352d332e3531352d31312e34392d31312e3437382d35322e3635362d35322e3636342d36342e3833372d36342e3833376c2e3034392d2e303337632d312e3732352d312e3630362d322e3731392d332e3834372d322e3735312d362e3230346830632d2e3034362d322e3337352c312e3036322d342e3538322c322e3732362d362e32323968306c2e3138352d2e3134386830632e3039392d2e3036322c2e3232322d2e3134382c2e33372d2e323539683063322e30362d312e3336322c332e3935312d322e3632312c362e3034342d332e3834324335372e3736332d332e3437332c39372e37362d322e3334312c3132382e3633372c31382e3333326331362e3637312c392e3934362d32362e3334342c35342e3831332d33382e3635312c34302e3139392d362e3239392d362e3039362d31382e3036332d31372e3734332d31392e3636382d31382e3831312d362e3031362d342e3034372d31332e3036312c342e3737362d372e3735322c392e3735316c36382e3235342c36382e33373163312e3732342c312e3630312c322e3731342c332e38342c322e3733382c362e3139325a222f3e00000000003c706174682069643d22466c6f6174696e6754657874222066696c6c3d226e6f6e652220643d224d313235203435683735307338302030203830203830763735307330203830202d3830203830682d373530732d38302030202d3830202d3830762d3735307330202d3830203830202d3830222f3e00000000000000000000003c72616469616c4772616469656e742069643d2252616469616c476c6f77223e3c73746f70206f66667365743d223025222073746f702d636f6c6f723d220000222073746f702d6f7061636974793d222e36222f3e00000000000000000000003c73746f70206f66667365743d2231303025222073746f702d636f6c6f723d22222073746f702d6f7061636974793d2230222f3e0000000000000000000000003c2f72616469616c4772616469656e743e0000000000000000000000000000003c6c696e6561724772616469656e742069643d2253616e64546f70222078313d223025222079313d223025223e00000000000000000000000000000000000000222f3e00000000000000000000000000000000000000000000000000000000003c2f6c696e6561724772616469656e743e0000000000000000000000000000003c6c696e6561724772616469656e742069643d2253616e64426f74746f6d222078313d2231303025222079313d2231303025223e0000000000000000000000003c73746f70206f66667365743d22313025222073746f702d636f6c6f723d22006c7565733d223330253b3630253b313230253b3630253b3330253b222f3e00002236732220726570656174436f756e743d22696e646566696e697465222076613c616e696d617465206174747269627574654e616d653d22783122206475723d3c6c696e6561724772616469656e742069643d22486f7572676c6173735374726f6b6522206772616469656e745472616e73666f726d3d22726f746174652839302922206772616469656e74556e6974733d227573657253706163654f6e557365223e00000000000000000000000000000000000000000000000000000000003c73746f70206f66667365743d22353025222073746f702d636f6c6f723d22003c73746f70206f66667365743d22383025222073746f702d636f6c6f723d22003c7061746820643d224d2035302c3336302061203330302c333030203020312c31203630302c302061203330302c333030203020312c31202d3630302c30222066696c6c3d2223666666222066696c6c2d6f7061636974793d222e303222207374726f6b653d2275726c2823486f7572676c6173735374726f6b652922207374726f6b652d77696474683d2234222f3e00000000000000000000000000000000000000000000000000000000000000000000000000000000fffffffffffffd3f3c7061746820643d226d3536362c3136312e323031762d35332e39323463302d31392e3338322d32322e3531332d33372e3536332d36332e3339382d35312e3139382d34302e3735362d31332e3539322d39342e3934362d32312e3037392d3135322e3538372d32312e303739732d3131312e3833382c372e3438372d3135322e3630322c32312e303739632d34302e3839332c31332e3633362d36332e3431332c33312e3831362d36332e3431332c35312e3139387635332e39323463302c31372e3138312c31372e3730342c33332e3432372c35302e3232332c34362e333934763238342e383039632d33322e3531392c31322e39362d35302e3232332c32392e3230362d35302e3232332c34362e3339347635332e39323463302c31392e3338322c32322e35322c33372e3536332c36332e3431332c35312e3139382c34302e3736332c31332e3539322c39342e3935342c32312e3037392c3135322e3630322c32312e303739733131312e3833312d372e3438372c3135322e3538372d32312e3037396334302e3838362d31332e3633362c36332e3339382d33312e3831362c36332e3339382d35312e313938762d35332e39323463302d31372e3139362d31372e3730342d33332e3433352d35302e3232332d34362e343031563230372e3630336333322e3531392d31322e3936372c35302e3232332d32392e3230362c35302e3232332d34362e3430315a6d2d3334372e3436322c35372e3739336c3133302e3935392c3133312e3032372d3133302e3935392c3133312e303133563231382e3939345a6d3236322e3932342e303232763236322e3031386c2d3133302e3933372d3133312e3030362c3133302e3933372d3133312e3031335a222066696c6c3d2223313631383232223e3c2f706174683e0000000000000000000000000000000000000000000000000000000000000000fffffffffffffe1f3c7061746820643d226d3438312e34362c3438312e35347638312e3031632d322e33352e37372d342e38322c312e35312d372e33392c322e32332d33302e332c382e35342d37342e36352c31332e39322d3132342e30362c31332e39322d35332e362c302d3130312e32342d362e33332d3133312e34372d31362e3136762d38316c34362e332d34362e3331683137302e33336c34362e32392c34362e33315a222066696c6c3d2275726c282353616e64426f74746f6d29222f3e3c7061746820643d226d3433352e31372c3433352e323363302c312e31372d2e34362c322e33322d312e33332c332e34342d372e31312c392e30382d34312e39332c31352e39382d38332e38312c31352e3938732d37362e372d362e392d38332e38322d31352e3938632d2e38372d312e31322d312e33332d322e32372d312e33332d332e2c342e34392c37362e37322c31316c382e34322c382e34325a222066696c6c3d2e35312c34322e39352d31312e30322c37362e382d31312e30327336322e39373434762d2e30346c382e33342d382e33352e30312d2e30316331332e37322d362275726c282353616e64546f7029222f3e0000000000000000000000000000003c706f6c79676f6e20706f696e74733d22333530203335302e303236203431352e3033203238342e39373820323835203238342e39373820333530203335302e303236222066696c6c3d2275726c282353616e64426f74746f6d29222f3e3c7061746820643d226d3431362e3334312c3238312e39373563302c2e3931342d2e3335342c312e3830392d312e3033352c322e36382d352e3534322c372e3037362d33322e3636312c31322e34352d36352e32382c31322e34352d33322e3632342c302d35392e3733382d352e3337342d36352e32382d31322e34352d2e3638312d2e3837322d312e3033352d312e3736372d312e3033352d322e36382c302d2e3931342e3335342d312e3830382c312e3033352d322e3637362c352e3534322d372e3037362c33322e3635362d31322e34352c36352e32382d31322e34352c335a222066696c6c3d2275726c282353616e64546f7029222f3e000000000000002e3638312e3836372c312e3033352c312e3736322c312e3033352c322e363736322e3631392c302c35392e3733382c352e3337342c36352e32382c31322e3435000000000000000000000000000000000000000000000000fffffffffffffedf3c7061746820643d226d3438312e34362c3530342e3130317635382e343439632d322e33352e37372d342e38322c312e35312d372e33392c322e32332d33302e332c382e35342d37342e36352c31332e39322d3132342e30362c31332e39322d35332e362c302d3130312e32342d362e33332d3133312e34372d31362e3136762d35382e343339683236322e39325a222066696c6c3d2275726c282353616e64426f74746f6d29222f3e3c656c6c697073652063783d22333530222063793d223530342e313031222072783d223133312e343632222072793d2232382e313038222066696c6c3d2275726c282353616e64546f7029222f3e0000000000000000000000000000000000000000000000000000000000000000fffffffffffff81f3c672066696c6c3d226e6f6e6522207374726f6b653d2275726c2823486f7572676c6173735374726f6b652922207374726f6b652d6c696e656361703d22726f756e6422207374726f6b652d6d697465726c696d69743d22313022207374726f6b652d77696474683d2234223e3c7061746820643d226d3536352e3634312c3130372e323863302c392e3533372d352e35362c31382e3632392d31352e3637362c32362e393733682d2e303233632d392e3230342c372e3539362d32322e3139342c31342e3536322d33382e3139372c32302e3539322d33392e3530342c31342e3933362d39372e3332352c32342e3335352d3136312e3733332c32342e3335352d39302e34382c302d3136372e3934382d31382e3538322d3139392e3935332d34342e393438682d2e303233632d31302e3131352d382e3334342d31352e36643d226d3138342e35382c3533372e353863302c352e34352c342e32372c3130323d223531352e343136222079323d223533372e353739222f3e3c70617468206c696e652078313d223531352e343135222079313d223230372e3335322220783432222078323d223438312e383139222079323d223536322e343238222f3e3c37222f3e3c6c696e652078313d223438312e383138222079313d223231382e313231382e313138222078323d223231382e313831222079323d223536322e353333372e353739222f3e3c6c696e652078313d223231382e313831222079313d222079313d223230362e383233222078323d223138342e353835222079323d22352079323d223130372e3238222f3e3c6c696e652078313d223138342e353834223536352e3634222079313d223136312e323033222078323d223536352e363422223133342e3336222079323d223130372e3238222f3e3c6c696e652078313d22696e652078313d223133342e3336222079313d223136312e323033222078323d352e3632392d33322e3138362c3231352e3632392d37312e393231222f3e3c6c2c39362e3535342c37312e3932312c3231352e3635322c37312e3932317332317061746820643d226d3133342e33362c3136312e32303363302c33392e373335352e3632392c33322e3138352c3231352e3632392c37312e3932315a222f3e3c2c39362e3535342d37312e3932312c3231352e3635322d37312e39323173323137362d31372e3433372d31352e3637362d32362e3937332c302d33392e3733352e36352c31322e30332c31352e3432682e303263352e35312c332e33392c3132222f3e3c2f673e00000000000000000000000000000000000000000000000000203335302e303135203335302e303236203438312e383232203231382e313532223231382e313835203438312e393031203231382e323331203438312e3835342e313835203231382e313239222f3e3c706f6c796c696e6520706f696e74733d2e373735203438312e383534203335302e303135203335302e303236203231382e383232203438312e393031203438312e373938203438312e38373720343831223533382e373937222f3e3c706f6c796c696e6520706f696e74733d223438312e3634222079313d223539322e3732222078323d223536352e3634222079323d2e3336222079323d223533382e373937222f3e3c6c696e652078313d223536352078313d223133342e3336222079313d223539322e3732222078323d2231333432392d33322e3138362c3231352e3632392d37312e393231222f3e3c6c696e652e3535342c37312e3932312c3231352e3635322c37312e393231733231352e36746820643d226d3133342e33362c3539322e373263302c33392e3733352c393631382e3836392d33332e3636352d35302e3232332d34362e3135222f3e3c7061372d31372e3433332c31352e3637372d32362e3936392c302d31372e3536322d342d31392e313733682e3032326331302e3131342d382e3334322c31352e363731342e3332362d352e3639362c32362e3033352d31322e3136312c33342e35323234342d2e3436372c322e3437332d2e3934322c332e3637332d312e3432342c2e37392c32302e3836372d352e3932362c32392e3932342d392e3334392c312e36332d352e3539352c3133312e3830372d31352e3030326331302e3834372d32322e3138312c31352e3030322c3133312e3833352c31352e3030327339352e332e3630392c33332e3539372c31302e3738382c33362e34352c392e3430372c382e3532342c31392e3135392c392e3939392c332e3939312c32312e3236392c3730323263382e3530332c372e3030352c32302e3231332c31332e3436332c33343533362c352e3536342c31382e3632372c31352e3637372c32362e393639682e2d35302e3232332c32382e35382d35302e3232332c34362e3134322c302c392e226d3138342e3538322c3439322e363536632d33312e3335342c31322e343835322e30342d392e39372c31322e30342d31352e3432222f3e3c7061746820643d30352d362e30342c32312e35362d392e3433683063372e37362d342e37372c312e32392d312e35342c372e37352d322e33352c382e37372d322e38372c31362e332e37362d352e33382c3132342e30362d31332e39322c322e372d2e37362c352e30322c31362e32382c3133312e38332c31362e32382c34392e34312c302c392e37392c362e35352c32312e35352c392e34322c33302e32312c392e392c37383c672069643d22486f7572676c617373223e00000000000000000000000000003c646566733e00000000000000000000000000000000000000000000000000003c2f646566733e000000000000000000000000000000000000000000000000002d313030250000000000000000000000000000000000000000000000000000003c74657874506174682073746172744f66667365743d2200000000000000000020666f6e742d73697a653d2232367078223e000000000000000000000000000069616c2c6d6f6e6f7370616365222066696c6c2d6f7061636974793d222e3822662220666f6e742d66616d696c793d2227436f7572696572204e6577272c41722220687265663d2223466c6f6174696e6754657874222066696c6c3d22236666696e646566696e6974652220746f3d2231303025222f3e00000000000000000075723d22353073222066726f6d3d2230252220726570656174436f756e743d22654e616d653d2273746172744f66667365742220626567696e3d2230732220643c616e696d6174652061646469746976653d2273756d222061747472696275743c2f74657874506174683e00000000000000000000000000000000000000000030250000000000000000000000000000000000000000000000000000000000002d3530250000000000000000000000000000000000000000000000000000000035302500000000000000000000000000000000000000000000000000000000003c7465787420746578742d72656e646572696e673d226f7074696d697a655370656564223e0000000000000000000000000000000000000000000000000000003c75736520687265663d2223476c6f77222066696c6c2d6f7061636974793d222e39222f3e0000000000000000000000000000000000000000000000000000003030222066696c6c2d6f7061636974793d222e39222f3e0000000000000000006f726967696e3d2235303020353030222f3e000000000000000000000000000072616e73666f726d3d22726f746174652831302922207472616e73666f726d2d65663d2223486f7572676c6173732220783d223135302220793d22393022207422207472616e73666f726d3d227363616c65282e3629222f3e3c7573652068723c75736520687265663d2223476c6f772220783d22313030302220793d2231303c75736520687265663d22234c6f676f2220783d223137302220793d223137303c75736520687265663d222350726f67726573732220783d22000000000000002220793d22373930222f3e0000000000000000000000000000000000000000003c75736520687265663d22235374617475732220783d220000000000000000003c75736520687265663d2223416d6f756e742220783d220000000000000000003c75736520687265663d22234475726174696f6e2220783d22000000000000003c73766720786d6c6e733d22687474703a2f2f7777772e77332e6f72672f323030302f737667222077696474683d223130303022206865696768743d2231303030222076696577426f783d2230203020313030302031303030223e00000000003c2f7376673e0000000000000000000000000000000000000000000000000000b2564569000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000b971302a000000000000000000000000000000000000000000000000000000005b7b2274726169745f74797065223a224173736574222c2276616c7565223a22227d2c7b2274726169745f74797065223a2253656e646572222c2276616c7565223a220000000000000000000000000000000000000000000000000000000000227d2c7b2274726169745f74797065223a22537461747573222c2276616c7565227d5d0000000000000000000000000000000000000000000000000000000000e29aa0efb88f205741524e494e473a205472616e7366657272696e6720746865204e4654206d616b657320746865206e6577206f776e65722074686520726563697069656e74206f66207468652073747265616d2e205468652066756e647320617265206e6f74206175746f6d61746963616c6c792077697468647261776e20666f72207468652070726576696f757320726563697069656e742e0000000000e29d95494e464f3a2054686973204e4654206973206e6f6e2d7472616e7366657261626c652e2049742063616e6e6f7420626520736f6c64206f72207472616e7366657272656420746f20616e6f74686572206163636f756e742e000000000054686973204e465420726570726573656e74732061207061796d656e742073747265616d20696e2061205361626c696572205632200000000000000000000000732c207768696368206172652064656e6f6d696e6174656420696e20000000002063616e207769746864726177207468652073747265616d656420617373657420636f6e74726163742e20546865206f776e6572206f662074686973204e46542e5c6e5c6e2d2053747265616d2049443a2000000000000000000000000000005c6e2d200000000000000000000000000000000000000000000000000000000020416464726573733a20000000000000000000000000000000000000000000005c6e5c6e000000000000000000000000000000000000000000000000000000005361626c6965722056322000000000000000000000000000000000000000000020230000000000000000000000000000000000000000000000000000000000007b2261747472696275746573223a0000000000000000000000000000000000002c226465736372697074696f6e223a2200000000000000000000000000000000722e636f6d222c226e616d65223a220000000000000000000000000000000000222c2265787465726e616c5f75726c223a2268747470733a2f2f7361626c6965736536342c000000000000000000000000000000000000000000000000000000222c22696d616765223a22646174613a696d6167652f7376672b786d6c3b6261227d000000000000000000000000000000000000000000000000000000000000646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000814a8a2e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000ffffffffffffffa000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7800000000000000000000000000000000000000000000000000000000000000e22e27eb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004400000000000000000000000030313233343536373839616263646566000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000000000000184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000000000000000000000000000000000000000004ee2d6d415b85acef810000000000000000000000000000000000000000000004ee2d6d415b85acef80ffffffff000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000000000000000000000000000000000000005f5e1006768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f4142434445464748494a4b4c4d4e4f505152535455565758595a616263646566bffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe3d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffe02e300000000000000000000000000000000000000000000000000000000000002e0000000000000000000000000000000000000000000000000000000000000020e280a2200000000000000000000000000000000000000000000000000000003b0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000009a8a0592ac89c5ad3bc6df8224c17b485976f597df104ee20d0df415241f670b02000002000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dd209663194e7a42f08b322b2ad5f82d75008fc8b5ec4ed52cc79661c9065f89
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.