-
Notifications
You must be signed in to change notification settings - Fork 509
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 proxy tests #427
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 comment otherwise looks good
} | ||
|
||
/// @notice Returns the native currency label as a string | ||
function nativeCurrencyLabel() public view returns (string memory) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would love to see unit tests for this function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code copied from here btw, but I couldn't find a unit test on the fly there either:
https://github.com/Uniswap/v3-periphery/blob/0682387198a24c7cd63566a2c58398533860a5d1/contracts/NonfungibleTokenPositionDescriptor.sol#L35-L45
src/PositionDescriptor.sol
Outdated
@@ -26,14 +26,27 @@ contract PositionDescriptor is IPositionDescriptor { | |||
address private constant WBTC = 0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599; | |||
|
|||
address public immutable wrappedNative; | |||
string public nativeCurrencyLabel; | |||
bytes32 public immutable nativeCurrencyLabelBytes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest making this variable private as we already have a getter
bytes32 public immutable nativeCurrencyLabelBytes; | |
bytes32 private immutable nativeCurrencyLabelBytes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i like that
} | ||
|
||
/// @notice Returns the native currency label as a string | ||
function nativeCurrencyLabel() public view returns (string memory) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code copied from here btw, but I couldn't find a unit test on the fly there either:
https://github.com/Uniswap/v3-periphery/blob/0682387198a24c7cd63566a2c58398533860a5d1/contracts/NonfungibleTokenPositionDescriptor.sol#L35-L45
assertEq(proxyAsImplementation.nativeCurrencyLabelBytes(), nativeCurrencyLabelBytes); | ||
} | ||
|
||
function test_nativeCurrencyLabel_succeeds() public { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i added the unit test here!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update test to also test the raw bytes32
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i cant since its private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unless we change to public
? tickUpper <= TickMath.getTickAtSqrtPrice(sqrtPriceX96) | ||
: tickLower > TickMath.getTickAtSqrtPrice(sqrtPriceX96) | ||
? TickMath.getSqrtPriceAtTick(tickUpper) <= sqrtPriceX96 | ||
: TickMath.getSqrtPriceAtTick(tickLower) >= sqrtPriceX96 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
YES so much better thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with this i can sleep happy 😂
@@ -26,14 +26,27 @@ contract PositionDescriptor is IPositionDescriptor { | |||
address private constant WBTC = 0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599; | |||
|
|||
address public immutable wrappedNative; | |||
string public nativeCurrencyLabel; | |||
bytes32 private immutable nativeCurrencyLabelBytes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this private?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can make public?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
daniel suggested we make it private since we already have a public getter for nativeCurrencyLabel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dont see why it can't just be public tho.. theres no downside
assertEq(proxyAsImplementation.nativeCurrencyLabelBytes(), nativeCurrencyLabelBytes); | ||
} | ||
|
||
function test_nativeCurrencyLabel_succeeds() public { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update test to also test the raw bytes32
@@ -918,15 +918,15 @@ contract PositionManagerModifyLiquiditiesTest is Test, PosmTestSetup, LiquidityF | |||
// Read below as: | |||
// bool currency0IsFOT = fotKey.currency0 == Currency.wrap(address(fotToken)); | |||
// bool positionIsEntirelyInOtherToken = currency0IsFOT | |||
// ? tickUpper <= TickMath.getTickAtSqrtPrice(sqrtPriceX96) | |||
// : tickLower > TickMath.getTickAtSqrtPrice(sqrtPriceX96); | |||
// ? TickMath.getSqrtPriceAtTick(tickUpper) <= sqrtPriceX96 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
test/shared/PosmTestSetup.sol
Outdated
); | ||
} | ||
|
||
function deployDescriptor(IPoolManager poolManager, bytes32 label) internal returns (IPositionDescriptor) { | ||
positionDescriptor = | ||
Deploy.positionDescriptor(address(poolManager), 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, label, hex"00"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is that address hardcoded for native? shouldn't it be address(_WETH9)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its hardcoded so i can check if its equal in PositionDescriptor.t.sol
if it wasnt hardcoded, foundry would deploy WETH9 to a random address
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could do it the opposite way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its just that if we want to run fork tests this would break no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm i guess not if we're not doing any actual transfers with that token, it is odd though that the weth we pass into posm will be different than the weth in position descriptor
@@ -1113,7 +1099,7 @@ contract PositionManagerModifyLiquiditiesTest is Test, PosmTestSetup, LiquidityF | |||
|
|||
// After redeeming the position, the liquidity provider should not have received any of the fot token since the position was entirely in the other token. | |||
assertEq(fotKey.currency1.balanceOf(address(this)), balance1._after); | |||
assertGe(fotKey.currency0.balanceOf(address(this)), balance0._after); | |||
assertGt(fotKey.currency0.balanceOf(address(this)), balance0._after); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this assumes that the fot token is currency1?
Related Issue
testing position descriptor as proxy
Description of changes