-
Notifications
You must be signed in to change notification settings - Fork 506
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
8b1e603
b2c943b
6e67c90
ba6c3cd
6f05aaf
ccea1c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,46 +48,46 @@ contract PositionDescriptorTest is Test, PosmTestSetup { | |
} | ||
|
||
function test_bytecodeSize_positionDescriptor() public { | ||
vm.snapshotValue("positionDescriptor bytecode size", address(positionDescriptor).code.length); | ||
vm.snapshotValue("positionDescriptor bytecode size", address(proxyAsImplementation).code.length); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would leave this as a snapshot on the actual position descriptor bytecode & then I'd just add one for the proxy too There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh yes meant to do that |
||
} | ||
|
||
function test_setup_succeeds() public view { | ||
assertEq(address(positionDescriptor.poolManager()), address(manager)); | ||
assertEq(positionDescriptor.wrappedNative(), WETH9); | ||
assertEq(positionDescriptor.nativeCurrencyLabel(), nativeCurrencyLabel); | ||
assertEq(address(proxyAsImplementation.poolManager()), address(manager)); | ||
assertEq(proxyAsImplementation.wrappedNative(), WETH9); | ||
assertEq(proxyAsImplementation.nativeCurrencyLabel(), nativeCurrencyLabel); | ||
} | ||
|
||
function test_currencyRatioPriority_mainnet_succeeds() public { | ||
vm.chainId(1); | ||
assertEq(positionDescriptor.currencyRatioPriority(WETH9), CurrencyRatioSortOrder.DENOMINATOR); | ||
assertEq(positionDescriptor.currencyRatioPriority(address(0)), CurrencyRatioSortOrder.DENOMINATOR); | ||
assertEq(positionDescriptor.currencyRatioPriority(USDC), CurrencyRatioSortOrder.NUMERATOR_MOST); | ||
assertEq(positionDescriptor.currencyRatioPriority(USDT), CurrencyRatioSortOrder.NUMERATOR_MORE); | ||
assertEq(positionDescriptor.currencyRatioPriority(DAI), CurrencyRatioSortOrder.NUMERATOR); | ||
assertEq(positionDescriptor.currencyRatioPriority(TBTC), CurrencyRatioSortOrder.DENOMINATOR_MORE); | ||
assertEq(positionDescriptor.currencyRatioPriority(WBTC), CurrencyRatioSortOrder.DENOMINATOR_MOST); | ||
assertEq(positionDescriptor.currencyRatioPriority(makeAddr("ALICE")), 0); | ||
assertEq(proxyAsImplementation.currencyRatioPriority(WETH9), CurrencyRatioSortOrder.DENOMINATOR); | ||
assertEq(proxyAsImplementation.currencyRatioPriority(address(0)), CurrencyRatioSortOrder.DENOMINATOR); | ||
assertEq(proxyAsImplementation.currencyRatioPriority(USDC), CurrencyRatioSortOrder.NUMERATOR_MOST); | ||
assertEq(proxyAsImplementation.currencyRatioPriority(USDT), CurrencyRatioSortOrder.NUMERATOR_MORE); | ||
assertEq(proxyAsImplementation.currencyRatioPriority(DAI), CurrencyRatioSortOrder.NUMERATOR); | ||
assertEq(proxyAsImplementation.currencyRatioPriority(TBTC), CurrencyRatioSortOrder.DENOMINATOR_MORE); | ||
assertEq(proxyAsImplementation.currencyRatioPriority(WBTC), CurrencyRatioSortOrder.DENOMINATOR_MOST); | ||
assertEq(proxyAsImplementation.currencyRatioPriority(makeAddr("ALICE")), 0); | ||
} | ||
|
||
function test_currencyRatioPriority_notMainnet_succeeds() public { | ||
assertEq(positionDescriptor.currencyRatioPriority(WETH9), CurrencyRatioSortOrder.DENOMINATOR); | ||
assertEq(positionDescriptor.currencyRatioPriority(address(0)), CurrencyRatioSortOrder.DENOMINATOR); | ||
assertEq(positionDescriptor.currencyRatioPriority(USDC), 0); | ||
assertEq(positionDescriptor.currencyRatioPriority(USDT), 0); | ||
assertEq(positionDescriptor.currencyRatioPriority(DAI), 0); | ||
assertEq(positionDescriptor.currencyRatioPriority(TBTC), 0); | ||
assertEq(positionDescriptor.currencyRatioPriority(WBTC), 0); | ||
assertEq(positionDescriptor.currencyRatioPriority(makeAddr("ALICE")), 0); | ||
assertEq(proxyAsImplementation.currencyRatioPriority(WETH9), CurrencyRatioSortOrder.DENOMINATOR); | ||
assertEq(proxyAsImplementation.currencyRatioPriority(address(0)), CurrencyRatioSortOrder.DENOMINATOR); | ||
assertEq(proxyAsImplementation.currencyRatioPriority(USDC), 0); | ||
assertEq(proxyAsImplementation.currencyRatioPriority(USDT), 0); | ||
assertEq(proxyAsImplementation.currencyRatioPriority(DAI), 0); | ||
assertEq(proxyAsImplementation.currencyRatioPriority(TBTC), 0); | ||
assertEq(proxyAsImplementation.currencyRatioPriority(WBTC), 0); | ||
assertEq(proxyAsImplementation.currencyRatioPriority(makeAddr("ALICE")), 0); | ||
} | ||
|
||
function test_flipRatio_succeeds() public { | ||
vm.chainId(1); | ||
// bc price = token1/token0 | ||
assertTrue(positionDescriptor.flipRatio(USDC, WETH9)); | ||
assertFalse(positionDescriptor.flipRatio(DAI, USDC)); | ||
assertFalse(positionDescriptor.flipRatio(WBTC, WETH9)); | ||
assertFalse(positionDescriptor.flipRatio(WBTC, USDC)); | ||
assertFalse(positionDescriptor.flipRatio(WBTC, DAI)); | ||
assertTrue(proxyAsImplementation.flipRatio(USDC, WETH9)); | ||
assertFalse(proxyAsImplementation.flipRatio(DAI, USDC)); | ||
assertFalse(proxyAsImplementation.flipRatio(WBTC, WETH9)); | ||
assertFalse(proxyAsImplementation.flipRatio(WBTC, USDC)); | ||
assertFalse(proxyAsImplementation.flipRatio(WBTC, DAI)); | ||
} | ||
|
||
function test_tokenURI_succeeds() public { | ||
|
@@ -112,7 +112,7 @@ contract PositionDescriptorTest is Test, PosmTestSetup { | |
// The prefix length is calculated by converting the string to bytes and finding its length | ||
uint256 prefixLength = bytes("data:application/json;base64,").length; | ||
|
||
string memory uri = positionDescriptor.tokenURI(lpm, tokenId); | ||
string memory uri = proxyAsImplementation.tokenURI(lpm, tokenId); | ||
// Convert the uri to bytes | ||
bytes memory uriBytes = bytes(uri); | ||
|
||
|
@@ -133,7 +133,7 @@ contract PositionDescriptorTest is Test, PosmTestSetup { | |
} | ||
|
||
// quote is currency1, base is currency0 | ||
assertFalse(positionDescriptor.flipRatio(Currency.unwrap(key.currency0), Currency.unwrap(key.currency1))); | ||
assertFalse(proxyAsImplementation.flipRatio(Currency.unwrap(key.currency0), Currency.unwrap(key.currency1))); | ||
|
||
string memory symbol0 = SafeCurrencyMetadata.currencySymbol(Currency.unwrap(currency0), nativeCurrencyLabel); | ||
string memory symbol1 = SafeCurrencyMetadata.currencySymbol(Currency.unwrap(currency1), nativeCurrencyLabel); | ||
|
@@ -231,7 +231,7 @@ contract PositionDescriptorTest is Test, PosmTestSetup { | |
// The prefix length is calculated by converting the string to bytes and finding its length | ||
uint256 prefixLength = bytes("data:application/json;base64,").length; | ||
|
||
string memory uri = positionDescriptor.tokenURI(lpm, tokenId); | ||
string memory uri = proxyAsImplementation.tokenURI(lpm, tokenId); | ||
// Convert the uri to bytes | ||
bytes memory uriBytes = bytes(uri); | ||
|
||
|
@@ -253,7 +253,7 @@ contract PositionDescriptorTest is Test, PosmTestSetup { | |
|
||
// quote is currency1, base is currency0 | ||
assertFalse( | ||
positionDescriptor.flipRatio(Currency.unwrap(nativeKey.currency0), Currency.unwrap(nativeKey.currency1)) | ||
proxyAsImplementation.flipRatio(Currency.unwrap(nativeKey.currency0), Currency.unwrap(nativeKey.currency1)) | ||
); | ||
|
||
string memory symbol0 = | ||
|
@@ -354,7 +354,7 @@ contract PositionDescriptorTest is Test, PosmTestSetup { | |
|
||
vm.expectRevert(abi.encodeWithSelector(IPositionDescriptor.InvalidTokenId.selector, tokenId + 1)); | ||
|
||
positionDescriptor.tokenURI(lpm, tokenId + 1); | ||
proxyAsImplementation.tokenURI(lpm, tokenId + 1); | ||
} | ||
|
||
// Helper functions for testing purposes | ||
|
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