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 proxy tests #427

Merged
merged 14 commits into from
Jan 17, 2025
Merged

position descriptor proxy tests #427

merged 14 commits into from
Jan 17, 2025

Conversation

dianakocsis
Copy link
Contributor

Related Issue

testing position descriptor as proxy

Description of changes

Copy link
Member

@snreynolds snreynolds left a 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

test/PositionDescriptor.t.sol Outdated Show resolved Hide resolved
}

/// @notice Returns the native currency label as a string
function nativeCurrencyLabel() public view returns (string memory) {
Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -26,14 +26,27 @@ contract PositionDescriptor is IPositionDescriptor {
address private constant WBTC = 0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599;

address public immutable wrappedNative;
string public nativeCurrencyLabel;
bytes32 public immutable nativeCurrencyLabelBytes;
Copy link
Contributor

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

Suggested change
bytes32 public immutable nativeCurrencyLabelBytes;
bytes32 private immutable nativeCurrencyLabelBytes;

Copy link
Contributor Author

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertEq(proxyAsImplementation.nativeCurrencyLabelBytes(), nativeCurrencyLabelBytes);
}

function test_nativeCurrencyLabel_succeeds() public {
Copy link
Contributor Author

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!

Copy link
Member

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

Copy link
Contributor Author

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

Copy link
Contributor Author

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

gretzke
gretzke previously approved these changes Jan 14, 2025
? tickUpper <= TickMath.getTickAtSqrtPrice(sqrtPriceX96)
: tickLower > TickMath.getTickAtSqrtPrice(sqrtPriceX96)
? TickMath.getSqrtPriceAtTick(tickUpper) <= sqrtPriceX96
: TickMath.getSqrtPriceAtTick(tickLower) >= sqrtPriceX96
Copy link
Contributor

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

Copy link
Contributor

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 😂

hensha256
hensha256 previously approved these changes Jan 16, 2025
@@ -26,14 +26,27 @@ contract PositionDescriptor is IPositionDescriptor {
address private constant WBTC = 0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599;

address public immutable wrappedNative;
string public nativeCurrencyLabel;
bytes32 private immutable nativeCurrencyLabelBytes;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this private?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can make public?

Copy link
Contributor Author

@dianakocsis dianakocsis Jan 16, 2025

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

Copy link
Member

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 {
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

);
}

function deployDescriptor(IPoolManager poolManager, bytes32 label) internal returns (IPositionDescriptor) {
positionDescriptor =
Deploy.positionDescriptor(address(poolManager), 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, label, hex"00");
Copy link
Member

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)?

Copy link
Contributor Author

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

Copy link
Contributor Author

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

Copy link
Member

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?

Copy link
Member

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);
Copy link
Member

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?

@dianakocsis dianakocsis merged commit 3796e9c into main Jan 17, 2025
3 checks passed
@dianakocsis dianakocsis deleted the upgradeable-tests branch January 17, 2025 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants