Skip to content

Commit

Permalink
some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dianakocsis committed Sep 26, 2024
1 parent e4ccd57 commit a4892e3
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 14 deletions.
8 changes: 6 additions & 2 deletions src/libraries/AddressStringUtil.sol
Original file line number Diff line number Diff line change
@@ -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));
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/CurrencyRatioSortOrder.sol
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
15 changes: 8 additions & 7 deletions src/libraries/Descriptor.sol
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion src/libraries/HexStrings.sol
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
5 changes: 3 additions & 2 deletions src/libraries/SVG.sol
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/SafeERC20Namer.sol
Original file line number Diff line number Diff line change
@@ -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";
Expand Down

0 comments on commit a4892e3

Please sign in to comment.