Skip to main content

MerkleAllowlist

Git Source

Inherits: BaseCallback

This contract implements a merkle tree-based allowlist for buyers to participate in an auction. In this implementation, buyers do not have a limit on the amount they can purchase/bid.

State Variables

lotMerkleRoot

The root of the merkle tree that represents the allowlist for a lot

The merkle tree should adhere to the format specified in the OpenZeppelin MerkleProof library at https://github.com/OpenZeppelin/merkle-tree

In particular, leaf values (such as (address) or (address,uint256)) should be double-hashed.

mapping(uint96 lotId => bytes32 merkleRoot) public lotMerkleRoot;

Functions

constructor

constructor(
address auctionHouse_,
Callbacks.Permissions memory permissions_
) BaseCallback(auctionHouse_, permissions_);

_onCreate

This function performs the following:

  • Validates the callback data
  • Sets the merkle root
  • Emits a MerkleRootSet event

This function reverts if:

  • The callback data is of an invalid length
function _onCreate(
uint96 lotId_,
address,
address,
address,
uint256,
bool,
bytes calldata callbackData_
) internal virtual override;

Parameters

NameTypeDescription
lotId_uint96The id of the lot
<none>address
<none>address
<none>address
<none>uint256
<none>bool
callbackData_bytesabi-encoded data: (bytes32) representing the merkle root

_onCancel

Not implemented

function _onCancel(uint96, uint256, bool, bytes calldata) internal pure override;

_onCurate

Not implemented

function _onCurate(uint96, uint256, bool, bytes calldata) internal pure override;

_onPurchase

This function performs the following:

  • Validates that the buyer is allowed to participate
  • Calls any additional implementation-specific logic

This function reverts if:

  • The buyer is not allowed to participate
function _onPurchase(
uint96 lotId_,
address buyer_,
uint256 amount_,
uint256 payout_,
bool prefunded_,
bytes calldata callbackData_
) internal virtual override;

Parameters

NameTypeDescription
lotId_uint96
buyer_address
amount_uint256
payout_uint256
prefunded_bool
callbackData_bytesabi-encoded data: (bytes32[]) representing the merkle proof

__onPurchase

Additional implementation-specific logic for the purchase callback

This function can be overridden by an inheriting contract to implement additional logic

function __onPurchase(
uint96 lotId_,
address buyer_,
uint256 amount_,
uint256 payout_,
bool prefunded_,
bytes calldata callbackData_
) internal virtual;

Parameters

NameTypeDescription
lotId_uint96The id of the lot
buyer_addressThe address of the buyer
amount_uint256The amount of quote tokens sent
payout_uint256The amount of base tokens to be sent
prefunded_boolWhether the lot is prefunded
callbackData_bytesabi-encoded callback data

_onBid

This function performs the following:

  • Validates that the buyer is allowed to participate
  • Calls any additional implementation-specific logic

This function reverts if:

  • The buyer is not allowed to participate
function _onBid(
uint96 lotId_,
uint64 bidId_,
address buyer_,
uint256 amount_,
bytes calldata callbackData_
) internal virtual override;

Parameters

NameTypeDescription
lotId_uint96
bidId_uint64
buyer_address
amount_uint256
callbackData_bytesabi-encoded data: (bytes32[]) representing the merkle proof

__onBid

Additional implementation-specific logic for the bid callback

This function can be overridden by an inheriting contract to implement additional logic

function __onBid(
uint96 lotId_,
uint64 bidId_,
address buyer_,
uint256 amount_,
bytes calldata callbackData_
) internal virtual;

_onSettle

Not implemented

function _onSettle(uint96, uint256, uint256, bytes calldata) internal pure override;

_canParticipate

function _canParticipate(
uint96 lotId_,
address buyer_,
bytes calldata callbackData_
) internal view virtual;

setMerkleRoot

Sets the merkle root for the allowlist This function can be called by the lot's seller to update the merkle root after onCreate().

This function performs the following:

  • Performs validation
  • Sets the merkle root
  • Emits a MerkleRootSet event

This function reverts if:

  • The caller is not the lot's seller
  • The auction has not been registered
function setMerkleRoot(uint96 lotId_, bytes32 merkleRoot_) external onlyRegisteredLot(lotId_);

Parameters

NameTypeDescription
lotId_uint96
merkleRoot_bytes32The new merkle root

Events

MerkleRootSet

Emitted when the merkle root is set

event MerkleRootSet(uint96 lotId, bytes32 merkleRoot);