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

Position descriptor #353

merged 53 commits into from
Oct 7, 2024

Conversation

dianakocsis
Copy link
Contributor

@dianakocsis dianakocsis commented Sep 18, 2024

WIP

src/PositionDescriptor.sol Outdated Show resolved Hide resolved
src/PositionDescriptor.sol Outdated Show resolved Hide resolved
src/PositionDescriptor.sol Show resolved Hide resolved
src/libraries/SafeERC20Namer.sol Outdated Show resolved Hide resolved
src/libraries/SafeERC20Namer.sol Outdated Show resolved Hide resolved
src/libraries/SafeERC20Namer.sol Outdated Show resolved Hide resolved
src/PositionManager.sol Show resolved Hide resolved
src/libraries/AddressStringUtil.sol Show resolved Hide resolved
src/libraries/AddressStringUtil.sol Outdated Show resolved Hide resolved

int256 constant DENOMINATOR_MOST = -300;
int256 constant DENOMINATOR_MORE = -200;
int256 constant DENOMINATOR_2 = -150;
Copy link
Contributor

Choose a reason for hiding this comment

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

why cant WETH just use DENOMINATOR as well? I feel like ETH/WETH pools are going to be very unusual, and the pricing of them probably shouldnt matter?

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 made them different because the native currency might not always be ETH

Copy link
Contributor Author

@dianakocsis dianakocsis Sep 26, 2024

Choose a reason for hiding this comment

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

would it make sense to pass in something like wrappedNative instead of WETH? that way for CELO, Polygon, and zksync (if we ever deploy to them) we would be able to cover both addresses?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

and then that way wrappedNative and native have the same priority.
we would then not care about WETH priority on those chains.
so on those chains it could be possible to display price like WETH/CELO

Copy link
Contributor

Choose a reason for hiding this comment

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

mm thats true ok. I just hate the name DENOMINATOR_2 😂 please can you rename it? then we can keep it hahah

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh i was thinking we could just remove it altogether

src/libraries/CurrencyRatioSortOrder.sol Show resolved Hide resolved
src/libraries/AddressStringUtil.sol Outdated Show resolved Hide resolved
src/libraries/SVG.sol Outdated Show resolved Hide resolved
buffer[params.sigfigIndex--] = ".";
}
buffer[params.sigfigIndex] = bytes1(uint8(48 + (params.sigfigs % 10)));
// can overflow when sigfigIndex = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

why is overflow desirable?

src/libraries/Descriptor.sol Show resolved Hide resolved
src/libraries/Descriptor.sol Outdated Show resolved Hide resolved
tokenId: tokenId,
quoteCurrency: quoteCurrency,
baseCurrency: baseCurrency,
quoteCurrencySymbol: quoteCurrency.isAddressZero()
Copy link
Contributor

Choose a reason for hiding this comment

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

i think id rather this logic was inside the namer. Like SafeCurrencyNamer and then in there check .isAddressZero() to abstract away from this contract

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so have the isAddressZero check inside of the namer? that's not directly related to name though. Plus, the isAddressZero check is also used for decimals

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess I'm wondering if SafeERC20Namer should be called like SafeCurrencyMetadata or something?
and then it can include

  • logic for checking for isAddressZero and returning information for native
  • try-catching decimals (from other comment) and returning 0 if not

: SafeERC20Namer.tokenSymbol(Currency.unwrap(baseCurrency)),
quoteCurrencyDecimals: quoteCurrency.isAddressZero()
? 18
: IERC20Metadata(Currency.unwrap(quoteCurrency)).decimals(),
Copy link
Contributor

Choose a reason for hiding this comment

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

why is safe decimal fetching not needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure because for name we check to see if its returned in bytes and then convert it to string.
i guess we could do something similar for uint8?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure how likely that decimals will be in bytes tho

Copy link
Contributor

Choose a reason for hiding this comment

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

but what if the token doesnt have a decimals function? they dont have to. I think you have to default it to 0

Copy link
Contributor

Choose a reason for hiding this comment

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

if you look at the spec the function is optional. So you can do a try-catch and default to 0 or something

hensha256
hensha256 previously approved these changes Oct 3, 2024
/// @title SafeERC20Metadata
/// @notice can produce symbols and decimals from inconsistent or absent ERC20 implementations
/// @dev Reference: https://github.com/Uniswap/solidity-lib/blob/master/contracts/libraries/SafeERC20Namer.sol
library SafeERC20Metadata {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a tiny nit to rename it SafeCurrencyMetadata now that it includes native?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay nice!

@marktoda marktoda requested a review from hensha256 October 7, 2024 17:25
@dianakocsis dianakocsis merged commit 7706c80 into main Oct 7, 2024
3 checks passed
@dianakocsis dianakocsis deleted the position-descriptor branch October 7, 2024 21:09
@dianakocsis dianakocsis restored the position-descriptor branch October 8, 2024 15:11
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.

3 participants