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

Signature-based approvals documentation improvements #242

Open
McMannaman opened this issue Nov 15, 2023 · 0 comments
Open

Signature-based approvals documentation improvements #242

McMannaman opened this issue Nov 15, 2023 · 0 comments

Comments

@McMannaman
Copy link

McMannaman commented Nov 15, 2023

  1. The following comment could lead to misinterpretation of the nonce for signature-based approvals:

https://github.com/Uniswap/permit2/blob/cc56ad0f3439c502c246fc5cfcc3db92bb8b7219/src/interfaces/IAllowanceTransfer.sol#L110C165-L110C165
"current nonce thats updated on any signature based approvals"
in fact, signagure-based (not allowance-based) transfers use unordered nonce, so this comment probably to be rephrased more clearly (even if permit2 overall is 'signature-based approvals').

  1. Regarding unordered nonce there is a documentation fragment that is also confusing:
    https://docs.uniswap.org/contracts/permit2/reference/signature-transfer#nonce-schema
    "...There are 2248 possible indices and this 2248 possible bitmaps..."
    it probably originally was "... 2^248 possible indices and 2^248 possible bitmaps..." but was damaged by markup.

It would be nice to fix that typo (just for that created a PR Uniswap/docs#641), and add something like:

uint256 contains 256 single bits that could be used as bit flags for a nonce, this is 256 = 2^8.
So the offset for nonce bitmap is calculated as dividing the nonce provided by 256 (bit shifting right >> 8), and lower 8 bits are location of the bit flag for the nonce.

  1. One more moment:
    There is no method provided to get a free ("non-dirty") nonce value for the SignatureTransfer. Using something simple (as just a wallet's transaction nonce) may collide as other protocols can use same numbers before.
    The numerical space for unordered nonces is huge, regardless, probably it would be very useful for Uniswap Permit2 to provide more clarity and some 'official' way of generating nonce number for signature transfers, e.g.:
    'A reasonable method of getting free nonce number can be: get a large fixed offset (e.g. ascii to hex value of the protocol name) and add wallet's nonce'. This would also provide some example of how this parameter should be obtained.
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

No branches or pull requests

1 participant