Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dianakocsis committed Sep 19, 2024
1 parent 2b518bf commit 04b719a
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 34 deletions.
13 changes: 6 additions & 7 deletions src/PositionDescriptor.sol
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;
pragma solidity 0.8.26;

import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol";
import {Currency, CurrencyLibrary} from "@uniswap/v4-core/src/types/Currency.sol";
import {IHooks} from "@uniswap/v4-core/src/interfaces/IHooks.sol";
import {StateLibrary} from "@uniswap/v4-core/src/libraries/StateLibrary.sol";
import {PoolKey} from "@uniswap/v4-core/src/types/PoolKey.sol";
import {PoolId, PoolIdLibrary} from "@uniswap/v4-core/src/types/PoolId.sol";
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import {IPositionManager} from "./interfaces/IPositionManager.sol";
import {IPositionDescriptor} from "./interfaces/IPositionDescriptor.sol";
import {PositionInfo, PositionInfoLibrary} from "./libraries/PositionInfoLibrary.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "./interfaces/IPositionDescriptor.sol";
import "./libraries/Descriptor.sol";
import "./interfaces/IPositionManager.sol";
import "./libraries/CurrencyRatioSortOrder.sol";
import "./libraries/SafeERC20Namer.sol";
import {Descriptor} from "./libraries/Descriptor.sol";
import {CurrencyRatioSortOrder} from "./libraries/CurrencyRatioSortOrder.sol";
import {SafeERC20Namer} from "./libraries/SafeERC20Namer.sol";

/// @title Describes NFT token positions
/// @notice Produces a string containing the data URI for a JSON metadata string
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/AddressStringUtil.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;
pragma solidity ^0.8.20;

/// @title AddressStringUtil
/// @notice provides utility functions for converting addresses to strings
Expand Down
14 changes: 7 additions & 7 deletions src/libraries/Descriptor.sol
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;
pragma solidity ^0.8.20;

import {Currency, CurrencyLibrary} from "@uniswap/v4-core/src/types/Currency.sol";
import {IHooks} from "@uniswap/v4-core/src/interfaces/IHooks.sol";
import {TickMath} from "@uniswap/v4-core/src/libraries/TickMath.sol";
import {FullMath} from "@uniswap/v4-core/src/libraries/FullMath.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/Base64.sol";
import "./SVG.sol";
import "./HexStrings.sol";
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
import {Base64} from "@openzeppelin/contracts/utils/Base64.sol";
import {SVG} from "./SVG.sol";
import {HexStrings} from "./HexStrings.sol";

/// @title Descriptor
/// @notice Describes NFT token positions
Expand Down Expand Up @@ -483,11 +483,11 @@ library Descriptor {
return SVG.generateSVG(svgParams);
}
/// @notice Checks if the current tick is within the tick range, above, or below
/// @notice Checks if the current price is within your position range, above, or below
/// @param tickLower The lower tick
/// @param tickUpper The upper tick
/// @param tickCurrent The current tick
/// @return 0 if current tick is within range, -1 if below, 1 if above
/// @return 0 if the current price is within the position range, -1 if below, 1 if above
function overRange(int24 tickLower, int24 tickUpper, int24 tickCurrent) private pure returns (int8) {
if (tickCurrent < tickLower) {
return -1;
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/HexStrings.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;
pragma solidity ^0.8.20;

/// @title HexStrings
/// @notice Provides function for converting numbers to hexadecimal strings
Expand Down
22 changes: 7 additions & 15 deletions src/libraries/SVG.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;
pragma solidity ^0.8.20;

import {Currency, CurrencyLibrary} from "@uniswap/v4-core/src/types/Currency.sol";
import {IHooks} from "@uniswap/v4-core/src/interfaces/IHooks.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@uniswap/v4-core/src/libraries/BitMath.sol";
import "@openzeppelin/contracts/utils/Base64.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";

/// @title SVG
/// @notice Provides a function for generating an SVG associated with a Uniswap NFT
Expand Down Expand Up @@ -226,7 +226,7 @@ library SVG {
);
}

/// @notice Generate the SVG for the curve that represents the position. Fade up (top is faded) if position over range, fade down (bottom is faded) if under range, else no fade
/// @notice Generate the SVG for the curve that represents the position. Fade up (top is faded) if current price is above your position range, fade down (bottom is faded) if current price is below your position range
/// Circles are generated at the ends of the curve if the position is in range, or at one end of the curve it is on if not in range
/// @param tickLower The lower tick
/// @param tickUpper The upper tick
Expand Down Expand Up @@ -335,7 +335,7 @@ library SVG {
}
}

/// @notice Generate the SVG for the position data (token ID, hooks address, min tick, max tick) and the location curve (the LP's position in the curve where the provider is active in the pool)
/// @notice Generate the SVG for the position data (token ID, hooks address, min tick, max tick) and the location curve (where your position falls on the curve)
/// @param tokenId The token ID
/// @param hook The hooks address
/// @param tickLower The lower tick
Expand Down Expand Up @@ -397,11 +397,6 @@ library SVG {
);
}

/// @notice Get a substring of a string
/// @param str The string
/// @param startIndex The start index
/// @param endIndex The end index
/// @return The substring
function substring(string memory str, uint256 startIndex, uint256 endIndex) internal pure returns (string memory) {
bytes memory strBytes = bytes(str);
bytes memory result = new bytes(endIndex - startIndex);
Expand All @@ -411,9 +406,6 @@ library SVG {
return string(result);
}

/// @notice Convert a tick to a string
/// @param tick The tick to convert
/// @return The tick as a string
function tickToString(int24 tick) private pure returns (string memory) {
string memory sign = "";
if (tick < 0) {
Expand All @@ -423,7 +415,7 @@ library SVG {
return string(abi.encodePacked(sign, uint256(uint24(tick)).toString()));
}

/// @notice Get the location of where the liquidity is supplied based on the tick range of the position
/// @notice Get the location of where your position falls on the curve
/// @param tickLower The lower tick
/// @param tickUpper The upper tick
/// @return The x and y coordinates of the location of the liquidity
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.24;
pragma solidity ^0.8.20;

import "./AddressStringUtil.sol";

Expand Down
4 changes: 2 additions & 2 deletions test/PositionDescriptor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ contract PositionDescriptorTest is Test, PosmTestSetup {
}

function test_tokenURI_succeeds() public {
int24 tickLower = -int24(key.tickSpacing);
int24 tickUpper = int24(key.tickSpacing);
int24 tickLower = int24(key.tickSpacing);
int24 tickUpper = int24(key.tickSpacing * 2);
uint256 amount0Desired = 100e18;
uint256 amount1Desired = 100e18;
uint256 liquidityToAdd = LiquidityAmounts.getLiquidityForAmounts(
Expand Down

0 comments on commit 04b719a

Please sign in to comment.