From f4d24f58e5d8afc6c78761943722b0b64e8a67d4 Mon Sep 17 00:00:00 2001 From: diana Date: Tue, 8 Oct 2024 11:51:15 -0400 Subject: [PATCH] position descriptor edits (#359) * oz remapping and memory * make internal --- .forge-snapshots/positionDescriptor bytecode size.snap | 1 + src/libraries/Descriptor.sol | 8 ++++---- src/libraries/SVG.sol | 4 ++-- src/libraries/SafeCurrencyMetadata.sol | 2 +- test/PositionDescriptor.t.sol | 7 ++++++- 5 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 .forge-snapshots/positionDescriptor bytecode size.snap diff --git a/.forge-snapshots/positionDescriptor bytecode size.snap b/.forge-snapshots/positionDescriptor bytecode size.snap new file mode 100644 index 00000000..ec121d73 --- /dev/null +++ b/.forge-snapshots/positionDescriptor bytecode size.snap @@ -0,0 +1 @@ +31065 \ No newline at end of file diff --git a/src/libraries/Descriptor.sol b/src/libraries/Descriptor.sol index 8e32a35d..527e7bd8 100644 --- a/src/libraries/Descriptor.sol +++ b/src/libraries/Descriptor.sol @@ -5,8 +5,8 @@ import {Currency, CurrencyLibrary} from "@uniswap/v4-core/src/types/Currency.sol import {TickMath} from "@uniswap/v4-core/src/libraries/TickMath.sol"; import {FullMath} from "@uniswap/v4-core/src/libraries/FullMath.sol"; import {LPFeeLibrary} from "@uniswap/v4-core/src/libraries/LPFeeLibrary.sol"; -import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; -import {Base64} from "@openzeppelin/contracts/utils/Base64.sol"; +import {Strings} from "openzeppelin-contracts/contracts/utils/Strings.sol"; +import {Base64} from "openzeppelin-contracts/contracts/utils/Base64.sol"; import {SVG} from "./SVG.sol"; import {HexStrings} from "./HexStrings.sol"; @@ -42,7 +42,7 @@ library Descriptor { /// @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) { + function constructTokenURI(ConstructTokenURIParams memory params) internal pure returns (string memory) { string memory name = generateName(params, feeToPercentString(params.fee)); string memory descriptionPartOne = generateDescriptionPartOne( escapeQuotes(params.quoteCurrencySymbol), @@ -175,7 +175,7 @@ library Descriptor { /// @param params Parameters needed to generate the name /// @param feeTier The fee tier of the pool /// @return The name of the NFT - function generateName(ConstructTokenURIParams calldata params, string memory feeTier) + function generateName(ConstructTokenURIParams memory params, string memory feeTier) private pure returns (string memory) diff --git a/src/libraries/SVG.sol b/src/libraries/SVG.sol index 24d71282..dea00e66 100644 --- a/src/libraries/SVG.sol +++ b/src/libraries/SVG.sol @@ -4,8 +4,8 @@ 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"; import {BitMath} from "@uniswap/v4-core/src/libraries/BitMath.sol"; -import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; -import {Base64} from "@openzeppelin/contracts/utils/Base64.sol"; +import {Strings} from "openzeppelin-contracts/contracts/utils/Strings.sol"; +import {Base64} from "openzeppelin-contracts/contracts/utils/Base64.sol"; /// @title SVG /// @notice Provides a function for generating an SVG associated with a Uniswap NFT diff --git a/src/libraries/SafeCurrencyMetadata.sol b/src/libraries/SafeCurrencyMetadata.sol index 84aa2881..f4d7cf27 100644 --- a/src/libraries/SafeCurrencyMetadata.sol +++ b/src/libraries/SafeCurrencyMetadata.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; -import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; +import {IERC20Metadata} from "openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import {Currency, CurrencyLibrary} from "@uniswap/v4-core/src/types/Currency.sol"; import {AddressStringUtil} from "./AddressStringUtil.sol"; diff --git a/test/PositionDescriptor.t.sol b/test/PositionDescriptor.t.sol index 6658a735..7ee83911 100644 --- a/test/PositionDescriptor.t.sol +++ b/test/PositionDescriptor.t.sol @@ -11,8 +11,9 @@ import {PositionConfig} from "./shared/PositionConfig.sol"; import {PosmTestSetup} from "./shared/PosmTestSetup.sol"; import {ActionConstants} from "../src/libraries/ActionConstants.sol"; import {Base64} from "./base64.sol"; +import {GasSnapshot} from "forge-gas-snapshot/GasSnapshot.sol"; -contract PositionDescriptorTest is Test, PosmTestSetup { +contract PositionDescriptorTest is Test, PosmTestSetup, GasSnapshot { using Base64 for string; address public WETH9 = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; @@ -36,6 +37,10 @@ contract PositionDescriptorTest is Test, PosmTestSetup { deployAndApprovePosm(manager); } + function test_bytecodeSize_positionDescriptor() public { + snapSize("positionDescriptor bytecode size", address(positionDescriptor)); + } + function test_setup_succeeds() public view { assertEq(address(positionDescriptor.poolManager()), address(manager)); assertEq(positionDescriptor.wrappedNative(), WETH9);