diff --git a/src/libraries/AddressStringUtil.sol b/src/libraries/AddressStringUtil.sol index b80404c8..999bc2d9 100644 --- a/src/libraries/AddressStringUtil.sol +++ b/src/libraries/AddressStringUtil.sol @@ -1,16 +1,20 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; +pragma solidity ^0.8.0; /// @title AddressStringUtil /// @notice provides utility functions for converting addresses to strings /// @dev Reference: https://github.com/Uniswap/solidity-lib/blob/master/contracts/libraries/AddressStringUtil.sol library AddressStringUtil { + error InvalidAddressLength(uint256 len); + /// @notice Converts an address to the uppercase hex string, extracting only len bytes (up to 20, multiple of 2) /// @param addr the address to convert /// @param len the number of bytes to extract /// @return the hex string function toAsciiString(address addr, uint256 len) internal pure returns (string memory) { - require(len % 2 == 0 && len > 0 && len <= 40, "AddressStringUtil: INVALID_LEN"); + if (!(len % 2 == 0 && len > 0 && len <= 40)) { + revert InvalidAddressLength(len); + } bytes memory s = new bytes(len); uint256 addrNum = uint256(uint160(addr)); diff --git a/src/libraries/CurrencyRatioSortOrder.sol b/src/libraries/CurrencyRatioSortOrder.sol index 857d7448..6114c1f9 100644 --- a/src/libraries/CurrencyRatioSortOrder.sol +++ b/src/libraries/CurrencyRatioSortOrder.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; +pragma solidity ^0.8.0; library CurrencyRatioSortOrder { int256 constant NUMERATOR_MOST = 300; diff --git a/src/libraries/Descriptor.sol b/src/libraries/Descriptor.sol index 0f04eb2c..9af53218 100644 --- a/src/libraries/Descriptor.sol +++ b/src/libraries/Descriptor.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; +pragma solidity ^0.8.0; import {Currency, CurrencyLibrary} from "@uniswap/v4-core/src/types/Currency.sol"; import {IHooks} from "@uniswap/v4-core/src/interfaces/IHooks.sol"; @@ -12,6 +12,7 @@ import {HexStrings} from "./HexStrings.sol"; /// @title Descriptor /// @notice Describes NFT token positions +/// @dev Reference: https://github.com/Uniswap/v3-periphery/blob/main/contracts/libraries/NFTDescriptor.sol library Descriptor { using TickMath for int24; using Strings for uint256; @@ -37,7 +38,7 @@ library Descriptor { address hooks; } - /// @notice Constructs the token URI for a Uniswap V4 NFT + /// @notice Constructs the token URI for a Uniswap v4 NFT /// @param params Parameters needed to construct the token URI /// @return The token URI as a string function constructTokenURI(ConstructTokenURIParams calldata params) public pure returns (string memory) { @@ -106,7 +107,7 @@ library Descriptor { return symbol; } - /// @notice Generates the first part of the description for a Uniswap V4 NFT + /// @notice Generates the first part of the description for a Uniswap v4 NFT /// @param quoteCurrencySymbol The symbol of the quote currency /// @param baseCurrencySymbol The symbol of the base currency /// @param poolManager The address of the pool manager @@ -138,7 +139,7 @@ library Descriptor { ); } - /// @notice Generates the second part of the description for a Uniswap V4 NFTs + /// @notice Generates the second part of the description for a Uniswap v4 NFTs /// @param tokenId The token ID /// @param baseCurrencySymbol The symbol of the base currency /// @param baseCurrency The address of the base currency @@ -169,7 +170,7 @@ library Descriptor { ); } - /// @notice Generates the name for a Uniswap V4 NFT + /// @notice Generates the name for a Uniswap v4 NFT /// @param params Parameters needed to generate the name /// @param feeTier The fee tier of the pool /// @return The name of the NFT @@ -452,7 +453,7 @@ library Descriptor { return (uint256(uint160(addr))).toHexString(20); } - /// @notice Generates the SVG image for a Uniswap V4 NFT + /// @notice Generates the SVG image for a Uniswap v4 NFT /// @param params Parameters needed to generate the SVG image /// @return svg The SVG image as a string function generateSVGImage(ConstructTokenURIParams memory params) internal pure returns (string memory svg) { @@ -503,7 +504,7 @@ library Descriptor { pure returns (string memory) { - return (n - inMn * (outMx - outMn) / (inMx - inMn) + outMn).toString(); + return ((n - inMn) * (outMx - outMn) / (inMx - inMn) + outMn).toString(); } function currencyToColorHex(uint256 currency, uint256 offset) internal pure returns (string memory str) { diff --git a/src/libraries/HexStrings.sol b/src/libraries/HexStrings.sol index 0be747d3..d5a32387 100644 --- a/src/libraries/HexStrings.sol +++ b/src/libraries/HexStrings.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; +pragma solidity ^0.8.0; /// @title HexStrings /// @notice Provides function for converting numbers to hexadecimal strings +/// @dev Reference: https://github.com/Uniswap/v3-periphery/blob/main/contracts/libraries/HexStrings.sol library HexStrings { bytes16 internal constant ALPHABET = "0123456789abcdef"; diff --git a/src/libraries/SVG.sol b/src/libraries/SVG.sol index b12bd285..9e860ea2 100644 --- a/src/libraries/SVG.sol +++ b/src/libraries/SVG.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; +pragma solidity ^0.8.0; import {Currency, CurrencyLibrary} from "@uniswap/v4-core/src/types/Currency.sol"; import {IHooks} from "@uniswap/v4-core/src/interfaces/IHooks.sol"; @@ -9,6 +9,7 @@ import {Base64} from "@openzeppelin/contracts/utils/Base64.sol"; /// @title SVG /// @notice Provides a function for generating an SVG associated with a Uniswap NFT +/// @dev Reference: https://github.com/Uniswap/v3-periphery/blob/main/contracts/libraries/NFTSVG.sol library SVG { using Strings for uint256; @@ -48,7 +49,7 @@ library SVG { string y3; } - /// @notice Generate the SVG associated with a Uniswap V4 NFT + /// @notice Generate the SVG associated with a Uniswap v4 NFT /// @param params The SVGParams struct containing the parameters for the SVG /// @return svg The SVG string associated with the NFT function generateSVG(SVGParams memory params) internal pure returns (string memory svg) { diff --git a/src/libraries/SafeERC20Namer.sol b/src/libraries/SafeERC20Namer.sol index c1b07070..0e8417a7 100644 --- a/src/libraries/SafeERC20Namer.sol +++ b/src/libraries/SafeERC20Namer.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; +pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import "./AddressStringUtil.sol";