Skip to main content

TokenAllowlist

Git Source

Inherits: BaseCallback

Allowlist contract that checks if a user's balance of a token is above a threshold

This shouldn't be used with liquid, transferable ERC-20s because it can easily be bypassed via flash loans or other swap mechanisms

The intent is to use this with non-transferable tokens (e.g. vote escrow) or illiquid tokens that are not as easily manipulated, e.g. community NFTs

State Variables

lotChecks

Stores the token and balance threshold for each lot

mapping(uint96 lotId => TokenCheck) public lotChecks;

Functions

constructor

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

_onCreate

This function reverts if:

  • callbackData_ is not of the correct length
  • The token contract is not a contract
  • The token contract does not have an ERC20 balanceOf function
function _onCreate(
uint96 lotId_,
address,
address,
address,
uint256,
bool,
bytes calldata callbackData_
) internal override;

Parameters

NameTypeDescription
lotId_uint96
<none>address
<none>address
<none>address
<none>uint256
<none>bool
callbackData_bytesabi-encoded data: (ITokenBalance, uint96) representing the token contract and balance threshold

_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 reverts if:

  • The buyer's balance is below the threshold
function _onPurchase(
uint96 lotId_,
address buyer_,
uint256,
uint256,
bool,
bytes calldata
) internal view override;

_onBid

This function reverts if:

  • The buyer's balance is below the threshold
function _onBid(
uint96 lotId_,
uint64,
address buyer_,
uint256,
bytes calldata
) internal view override;

_onSettle

Not implemented

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

_canParticipate

function _canParticipate(uint96 lotId_, address buyer_) internal view;

Structs

TokenCheck

struct TokenCheck {
ITokenBalance token;
uint256 threshold;
}