Skip to content

Conversation

@mgretzke
Copy link
Collaborator

@mgretzke mgretzke commented Aug 8, 2025

Preparations to add support for the IOnChainAllocator interface Uniswap/the-compact#154

@mgretzke mgretzke requested a review from 0age August 8, 2025 22:08
address compactContract,
uint256 nonce,
address recipient,
uint256[2][] calldata idsAndAmounts,
Copy link
Contributor

Choose a reason for hiding this comment

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

one thing that's a little funky is that there doesn't seem to be a way to prepare an allocation for an unknown amount (e.g. fee on transfer balance post-deposit). That said, I think it's still workable in most cases through other means before you get to the preparation stage

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is! You can leave the amounts empty in my implementation, it will only use the amounts it retrieved directly via its balance checks. The only check I do is in the OnChainAllocator to make sure the amounts do not exceed 224.max because that is not supported. The only I did idsAndAmounts is because it is the exact same format as batchDepositAndRegisterFor (plus you can do small checks like the unit224.max check)

error InvalidPreparation();
error InvalidRegistration(address recipient, bytes32 claimHash, bytes32 typehash);

function prepareAllocation(
Copy link
Contributor

Choose a reason for hiding this comment

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

in this step, shouldn't we also ensure that the compact isn't already registered (so that you can't prepare and execute multiple times?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought about this as well, but you can't register it multiple times because the nonce increments each execution

}
}

function executeAllocation(
Copy link
Contributor

Choose a reason for hiding this comment

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

tstore should get cleared so you can't execute multiple times

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See comment before:
As far as I can tell, there is no way to reexecute because of the incrementing nonce and it's nice to save a couple 100 gas. But please let me know if you still see a way to do the execution again!

Copy link
Contributor

@0age 0age left a comment

Choose a reason for hiding this comment

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

left a few notes (as single comments) that we should look into but mainly looking good

@mgretzke mgretzke marked this pull request as ready for review August 10, 2025 19:09
@mgretzke mgretzke requested a review from a team as a code owner August 10, 2025 19:09
@mgretzke mgretzke merged commit 35a3a3e into on-chain-allocator Aug 10, 2025
3 checks passed
@mgretzke mgretzke deleted the IOnChainAllocation branch August 10, 2025 19:32
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