Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Position descriptor #353

Merged
merged 53 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
2434576
position descriptor stuff
dianakocsis Aug 20, 2024
c423b33
messy checkpoint
snreynolds Aug 28, 2024
e497389
update subscribers
snreynolds Aug 28, 2024
830fdf5
stack too deep, permit error
snreynolds Aug 28, 2024
8eb66b3
use packed, no via-ir, but stack too deep concerning for tests
snreynolds Aug 29, 2024
7e8fc42
use external
snreynolds Aug 29, 2024
f94823f
review comments
snreynolds Aug 29, 2024
a77fb26
merge confs
snreynolds Aug 29, 2024
547c893
clear lower 8 bits on unsubscribe
snreynolds Aug 29, 2024
e695f43
move _pay, minimize diff
snreynolds Aug 29, 2024
df58a26
pr comments
snreynolds Aug 29, 2024
d6d1353
fix: test_fuzz_erc721Permit_SignatureDeadlineExpired
snreynolds Aug 29, 2024
7fd6b5b
naming
snreynolds Aug 29, 2024
84cc704
fix
snreynolds Aug 29, 2024
ec4ebdd
natspec
snreynolds Aug 29, 2024
5a88042
fix: stack too deep in tests
snreynolds Aug 29, 2024
fe1d709
remove console
snreynolds Aug 29, 2024
31a22de
merge main
snreynolds Aug 29, 2024
ca37b8c
move PositionConfig to shared testing infra
snreynolds Aug 29, 2024
ec14729
remove pool key checker lib
snreynolds Aug 29, 2024
21ae901
pr commmeeennnnttsss
snreynolds Aug 29, 2024
b29c5fe
fmt
snreynolds Aug 29, 2024
a2bc1b2
Merge branch 'main' into position-descriptor
dianakocsis Sep 3, 2024
e6315a3
pass in pd to posm
dianakocsis Sep 4, 2024
e7eb9f0
descriptooooor
dianakocsis Sep 18, 2024
69208ec
new files
dianakocsis Sep 18, 2024
e6dfb70
commentsss
dianakocsis Sep 18, 2024
9b723c3
Merge branch 'main' into position-descriptor
dianakocsis Sep 18, 2024
7d69f53
format
dianakocsis Sep 18, 2024
0ba4e38
fix comment
dianakocsis Sep 18, 2024
2b518bf
warnings
dianakocsis Sep 19, 2024
04b719a
more fixes
dianakocsis Sep 19, 2024
7e110cc
priority
dianakocsis Sep 19, 2024
924d12e
update core to fix snapshots
dianakocsis Sep 19, 2024
a6af3b7
re-add files
dianakocsis Sep 19, 2024
69af352
deploy script
dianakocsis Sep 20, 2024
04b458e
does this work
dianakocsis Sep 20, 2024
9ff5137
format
dianakocsis Sep 20, 2024
8506989
merge main
dianakocsis Sep 23, 2024
4542c59
pass in string directly
dianakocsis Sep 23, 2024
d0b81fe
remove extra check
dianakocsis Sep 23, 2024
4d53d2a
comments, selector, and reference
dianakocsis Sep 24, 2024
e4ccd57
Merge branch 'main' into position-descriptor
dianakocsis Sep 24, 2024
a4892e3
some changes
dianakocsis Sep 26, 2024
c08ccd9
more fixes
dianakocsis Sep 26, 2024
40904b0
format
dianakocsis Sep 26, 2024
8a6033e
more review changes
dianakocsis Oct 1, 2024
6ff9887
add safeerc20metadata file
dianakocsis Oct 1, 2024
8ea6b67
updates
dianakocsis Oct 2, 2024
072102f
format
dianakocsis Oct 2, 2024
bd90cee
currency name plus more tests
dianakocsis Oct 4, 2024
f72f195
invalid token id
dianakocsis Oct 7, 2024
c10da46
re-add comments
dianakocsis Oct 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_permit.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
79064
79076
2 changes: 1 addition & 1 deletion src/PositionManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ contract PositionManager is
)
BaseActionsRouter(_poolManager)
Permit2Forwarder(_permit2)
ERC721Permit_v4("Uniswap V4 Positions NFT", "UNI-V4-POSM")
ERC721Permit_v4("Uniswap v4 Positions NFT", "UNI-V4-POSM")
Notifier(_unsubscribeGasLimit)
{
tokenDescriptor = _tokenDescriptor;
Expand Down
2 changes: 1 addition & 1 deletion src/V4Router.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {Actions} from "./libraries/Actions.sol";
import {ActionConstants} from "./libraries/ActionConstants.sol";

/// @title UniswapV4Router
/// @notice Abstract contract that contains all internal logic needed for routing through Uniswap V4 pools
/// @notice Abstract contract that contains all internal logic needed for routing through Uniswap v4 pools
/// @dev the entry point to executing actions in this contract is calling `BaseActionsRouter._executeActions`
/// An inheriting contract should call _executeActions at the point that they wish actions to be executed
abstract contract V4Router is IV4Router, BaseActionsRouter, DeltaResolver {
Expand Down
4 changes: 4 additions & 0 deletions src/libraries/CurrencyRatioSortOrder.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

/// @title CurrencyRatioSortOrder
/// @notice Provides constants for sorting currencies when displaying price ratios
/// Currencies given larger values will be in the numerator of the price ratio
/// @dev Reference: https://github.com/Uniswap/v3-periphery/blob/main/contracts/libraries/TokenRatioSortOrder.sol
library CurrencyRatioSortOrder {
dianakocsis marked this conversation as resolved.
Show resolved Hide resolved
int256 constant NUMERATOR_MOST = 300;
int256 constant NUMERATOR_MORE = 200;
Expand Down
24 changes: 14 additions & 10 deletions src/libraries/Descriptor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ 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 {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 {SVG} from "./SVG.sol";
Expand Down Expand Up @@ -46,12 +47,12 @@ library Descriptor {
string memory descriptionPartOne = generateDescriptionPartOne(
escapeQuotes(params.quoteCurrencySymbol),
escapeQuotes(params.baseCurrencySymbol),
addressToString(params.poolManager),
addressToString(Currency.unwrap(params.quoteCurrency))
addressToString(params.poolManager)
);
string memory descriptionPartTwo = generateDescriptionPartTwo(
params.tokenId.toString(),
escapeQuotes(params.baseCurrencySymbol),
addressToString(Currency.unwrap(params.quoteCurrency)),
addressToString(Currency.unwrap(params.baseCurrency)),
addressToString(params.hooks),
feeToPercentString(params.fee)
Expand Down Expand Up @@ -111,18 +112,16 @@ library Descriptor {
/// @param quoteCurrencySymbol The symbol of the quote currency
/// @param baseCurrencySymbol The symbol of the base currency
/// @param poolManager The address of the pool manager
/// @param quoteCurrency The address of the quote currency
/// @return The first part of the description
function generateDescriptionPartOne(
string memory quoteCurrencySymbol,
string memory baseCurrencySymbol,
string memory poolManager,
string memory quoteCurrency
string memory poolManager
) private pure returns (string memory) {
// displays quote currency first, then base currency
return string(
abi.encodePacked(
"This NFT represents a liquidity position in a Uniswap V4 ",
"This NFT represents a liquidity position in a Uniswap v4 ",
quoteCurrencySymbol,
"-",
baseCurrencySymbol,
Expand All @@ -131,30 +130,32 @@ library Descriptor {
"\\nPool Manager Address: ",
poolManager,
"\\n",
quoteCurrencySymbol,
" Address: ",
quoteCurrency,
"\\n"
quoteCurrencySymbol
)
);
}

/// @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 quoteCurrency The address of the quote currency
/// @param baseCurrency The address of the base currency
/// @param hooks The address of the hooks contract
/// @param feeTier The fee tier of the pool
/// @return The second part of the description
function generateDescriptionPartTwo(
dianakocsis marked this conversation as resolved.
Show resolved Hide resolved
string memory tokenId,
string memory baseCurrencySymbol,
hensha256 marked this conversation as resolved.
Show resolved Hide resolved
string memory quoteCurrency,
string memory baseCurrency,
string memory hooks,
string memory feeTier
) private pure returns (string memory) {
return string(
abi.encodePacked(
' Address: ',
quoteCurrency,
"\\n",
baseCurrencySymbol,
" Address: ",
baseCurrency,
Expand Down Expand Up @@ -402,6 +403,9 @@ library Descriptor {
/// @param fee fee amount
/// @return fee as a decimal string with percent sign
function feeToPercentString(uint24 fee) internal pure returns (string memory) {
if (fee == LPFeeLibrary.DYNAMIC_FEE_FLAG) {
dianakocsis marked this conversation as resolved.
Show resolved Hide resolved
return "Dynamic";
}
if (fee == 0) {
return "0%";
}
Expand Down
6 changes: 0 additions & 6 deletions src/libraries/SVG.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ library SVG {
/// @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) {
/*
address: "0xe8ab59d3bcde16a29912de83a90eb39628cfc163",
msg: "Forged in SVG for Uniswap in 2021 by 0xe8ab59d3bcde16a29912de83a90eb39628cfc163",
sig: "0x2df0e99d9cbfec33a705d83f75666d98b22dea7c1af412c584f7d626d83f02875993df740dc87563b9c73378f8462426da572d7989de88079a382ad96c57b68d1b",
version: "2"
*/
return string(
abi.encodePacked(
generateSVGDefs(params),
Expand Down
2 changes: 1 addition & 1 deletion test/position-managers/Permit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ contract PermitTest is Test, PosmTestSetup {
keccak256(
abi.encode(
keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"),
keccak256("Uniswap V4 Positions NFT"), // storage is private on EIP712.sol so we need to hardcode these
keccak256("Uniswap v4 Positions NFT"), // storage is private on EIP712.sol so we need to hardcode these
block.chainid,
address(lpm)
)
Expand Down
Loading