Skip to content

Conversation

@mgretzke
Copy link
Collaborator

@mgretzke mgretzke commented Jul 14, 2025

Pull Request

Description

Adding the HybridAllocator and the HybridERC7683 allocator.

HybridAllocator

  • A new allocator, allowing to create allocations on chain, as well as allowing signers to create allocations off chain.
  • On chain allocations must include a deposit to the compact of the tokens in question, to ensure no double allocations with signature based allocations are possible.
  • Uses BatchCompacts for on chain allocations by default. Single Compacts must be provided in the batch format.

HybridERC7683

  • An ERC7683 conform version of the HybridAllocator.

Not all contracts are tested yet.

@mgretzke mgretzke requested review from 0age and ccashwell July 14, 2025 11:36
@mgretzke mgretzke requested a review from a team as a code owner July 14, 2025 11:36
Copy link
Member

@ccashwell ccashwell left a comment

Choose a reason for hiding this comment

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

Overall, this is a fantastic implementation. I added a few small notes/questions inline, but no showstoppers really 👍

bytes calldata allocatorData // Arbitrary data provided by the arbiter.
) external override onlyCompact returns (bytes4) {
uint256 length = idsAndAmounts.length;
if (length > 1) {
Copy link
Member

Choose a reason for hiding this comment

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

Why reject batch claims? What actually stops us from supporting here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated the ERC7683Allocator to be based on the new OnChainAllocator contract, which works with batchCompacts:
https://github.com/Uniswap/sc-allocators/blob/OnChainAllocator/src/allocators/ERC7683Allocator.sol

Comment on lines 44 to 48
function addSigner(address signer_) external onlySigner {
signers[signer_] = true;
signerCount++;
}
Copy link
Member

Choose a reason for hiding this comment

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

In order to avoid a potential vulnerability in scenarios where ecrecover returns address(0) during signature validation, we should explicitly block the zero address here:

Suggested change
function addSigner(address signer_) external onlySigner {
signers[signer_] = true;
signerCount++;
}
function addSigner(address signer_) external onlySigner {
require(signer_ != address(0), InvalidSigner());
signers[signer_] = true;
signerCount++;
}

Comment on lines 59 to 66
function replaceSigner(address newSigner_) external onlySigner {
signers[msg.sender] = false;
signers[newSigner_] = true;
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
function replaceSigner(address newSigner_) external onlySigner {
signers[msg.sender] = false;
signers[newSigner_] = true;
}
function replaceSigner(address newSigner_) external onlySigner {
require(newSigner_ != address(0), InvalidSigner());
signers[msg.sender] = false;
signers[newSigner_] = true;
}

@mgretzke mgretzke requested a review from marktoda August 1, 2025 15:21
import {ITheCompact} from '@uniswap/the-compact/interfaces/ITheCompact.sol';
import {IHybridAllocator} from 'src/interfaces/IHybridAllocator.sol';

contract HybridAllocator is IHybridAllocator {
Copy link

Choose a reason for hiding this comment

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

nit: top level natspec explaining the high level purpose and functinoality

}

// Check if the signer is an authorized allocator address
return signers[ecrecover(digest, v, r, s)];
Copy link

Choose a reason for hiding this comment

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

for safety its often worth a special check and revert if ecrecover returns address(0) => ie invalid signature

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is that required, even if we ensure that signers[address(0)] can never be true?

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.

5 participants