Skip to main content

Clearing

Asset Tokenization Studio Team

Clearing

Abstract implementation of the clearing module's global state and account-level reads.

Implements the one-shot initializer, the activation lifecycle and the account-scoped read queries on top of ClearingStorageWrapper and ClearingReadOps. The activation toggles enforce the onlyUnpaused and onlyRole(ROLE_CLEARING) guards; initializeClearing is gated by onlyRole(DEFAULT_ADMIN_ROLE) + onlyFacetNotRegistered. by ClearingFacet.

Methods​

activateClearing​

function activateClearing() external nonpayable returns (bool success_)

Activates the clearing functionality

Returns​

NameTypeDescription
success_boolTrue when the activation completes successfully

deactivateClearing​

function deactivateClearing() external nonpayable returns (bool success_)

Deactivates the clearing functionality

Returns​

NameTypeDescription
success_boolTrue when the deactivation completes successfully

getClearedAmountFor​

function getClearedAmountFor(address _tokenHolder) external view returns (uint256 amount_)

Gets the total cleared amount for a token holder across all partitions

Parameters​

NameTypeDescription
_tokenHolderaddressThe address of the token holder

Returns​

NameTypeDescription
amount_uint256Total cleared amount currently locked for the holder

getClearingThirdParty​

function getClearingThirdParty(bytes32 _partition, address _tokenHolder, enum IClearingTypes.ClearingOperationType _clearingOperationType, uint256 _clearingId) external view returns (address thirdParty_)

Gets the address of the party that initiated the clearing operation

Parameters​

NameTypeDescription
_partitionbytes32The partition of the token
_tokenHolderaddressThe address of the token holder
_clearingOperationTypeenum IClearingTypes.ClearingOperationTypeType of clearing operation (Transfer, Redeem, or HoldCreation)
_clearingIduint256Identifier of the clearing operation

Returns​

NameTypeDescription
thirdParty_addressAddress that initiated the clearing operation

initializeClearing​

function initializeClearing(bool _activateClearing) external nonpayable

Initializes the clearing module with the given activation state

Can only be called once per token; subsequent calls revert with FacetAlreadyRegistered

Parameters​

NameTypeDescription
_activateClearingboolWhether clearing should be activated on initialization

isClearingActivated​

function isClearingActivated() external view returns (bool)

Returns whether the clearing functionality is activated or not

Returns​

NameTypeDescription
_0boolTrue if activated, false otherwise

Events​

ClearedHoldByPartition​

event ClearedHoldByPartition(address indexed operator, address indexed tokenHolder, bytes32 partition, uint256 clearingId, IHoldTypes.Hold hold, uint256 expirationDate, bytes data, bytes operatorData)

Emitted when a token holder registers a clearing-guarded hold creation on a partition.

Parameters​

NameTypeDescription
operator indexedaddressAddress that submitted the clearing operation.
tokenHolder indexedaddressAddress of the holder whose tokens are to be placed under hold.
partitionbytes32ERC-1400 partition the tokens belong to.
clearingIduint256Sequential identifier for the registered operation.
holdIHoldTypes.HoldHold parameters that will be used on approval.
expirationDateuint256Unix timestamp after which the clearing operation may be reclaimed.
databytesCaller-supplied data attached to the operation.
operatorDatabytesData provided by the operator.

ClearedHoldFromByPartition​

event ClearedHoldFromByPartition(address indexed operator, address indexed tokenHolder, bytes32 partition, uint256 clearingId, IHoldTypes.Hold hold, uint256 expirationDate, bytes data, bytes operatorData)

Emitted when a clearing-guarded hold creation is registered on behalf of a token holder via holdFromByPartition.

Parameters​

NameTypeDescription
operator indexedaddressAddress that submitted the clearing operation on behalf of the holder.
tokenHolder indexedaddressAddress of the holder whose tokens are to be placed under hold.
partitionbytes32ERC-1400 partition the tokens belong to.
clearingIduint256Sequential identifier for the registered operation.
holdIHoldTypes.HoldHold parameters that will be used on approval.
expirationDateuint256Unix timestamp after which the clearing operation may be reclaimed.
databytesCaller-supplied data attached to the operation.
operatorDatabytesData provided by the operator.

ClearedOperatorRedeemByPartition​

event ClearedOperatorRedeemByPartition(address indexed operator, address indexed tokenHolder, bytes32 partition, uint256 clearingId, uint256 amount, uint256 expirationDate, bytes data, bytes operatorData)

Emitted when an operator registers a clearing-guarded redemption using operator-level permissions.

Parameters​

NameTypeDescription
operator indexedaddressAuthorised operator that submitted the clearing operation.
tokenHolder indexedaddressAddress of the holder whose tokens are pending redemption.
partitionbytes32ERC-1400 partition the tokens belong to.
clearingIduint256Sequential identifier for the registered operation.
amountuint256Token quantity pending redemption.
expirationDateuint256Unix timestamp after which the operation may be reclaimed.
databytesCaller-supplied data attached to the operation.
operatorDatabytesData provided by the operator.

ClearedOperatorTransferByPartition​

event ClearedOperatorTransferByPartition(address indexed operator, address indexed tokenHolder, address indexed to, bytes32 partition, uint256 clearingId, uint256 amount, uint256 expirationDate, bytes data, bytes operatorData)

Emitted when an operator registers a clearing-guarded transfer using operator-level permissions.

Parameters​

NameTypeDescription
operator indexedaddressAuthorised operator that submitted the clearing operation.
tokenHolder indexedaddressAddress of the holder whose tokens are pending transfer.
to indexedaddressIntended recipient of the tokens upon approval.
partitionbytes32ERC-1400 partition the tokens belong to.
clearingIduint256Sequential identifier for the registered operation.
amountuint256Token quantity pending transfer.
expirationDateuint256Unix timestamp after which the operation may be reclaimed.
databytesCaller-supplied data attached to the operation.
operatorDatabytesData provided by the operator.

ClearedRedeemByPartition​

event ClearedRedeemByPartition(address indexed operator, address indexed tokenHolder, bytes32 partition, uint256 clearingId, uint256 amount, uint256 expirationDate, bytes data, bytes operatorData)

Emitted when a token holder registers a clearing-guarded redemption on a partition.

Parameters​

NameTypeDescription
operator indexedaddressAddress that submitted the clearing operation.
tokenHolder indexedaddressAddress of the holder whose tokens are pending redemption.
partitionbytes32ERC-1400 partition the tokens belong to.
clearingIduint256Sequential identifier for the registered operation.
amountuint256Token quantity pending redemption.
expirationDateuint256Unix timestamp after which the operation may be reclaimed.
databytesCaller-supplied data attached to the operation.
operatorDatabytesData provided by the operator.

ClearedRedeemFromByPartition​

event ClearedRedeemFromByPartition(address indexed operator, address indexed tokenHolder, bytes32 partition, uint256 clearingId, uint256 amount, uint256 expirationDate, bytes data, bytes operatorData)

Emitted when a clearing-guarded redemption is registered on behalf of a token holder via redeemFromByPartition.

Parameters​

NameTypeDescription
operator indexedaddressAddress that submitted the clearing operation on behalf of the holder.
tokenHolder indexedaddressAddress of the holder whose tokens are pending redemption.
partitionbytes32ERC-1400 partition the tokens belong to.
clearingIduint256Sequential identifier for the registered operation.
amountuint256Token quantity pending redemption.
expirationDateuint256Unix timestamp after which the operation may be reclaimed.
databytesCaller-supplied data attached to the operation.
operatorDatabytesData provided by the operator.

ClearedTransferByPartition​

event ClearedTransferByPartition(address indexed operator, address indexed tokenHolder, address indexed to, bytes32 partition, uint256 clearingId, uint256 amount, uint256 expirationDate, bytes data, bytes operatorData)

Emitted when a token holder registers a clearing-guarded transfer on a partition.

Parameters​

NameTypeDescription
operator indexedaddressAddress that submitted the clearing operation.
tokenHolder indexedaddressAddress of the holder whose tokens are pending transfer.
to indexedaddressIntended recipient of the tokens upon approval.
partitionbytes32ERC-1400 partition the tokens belong to.
clearingIduint256Sequential identifier for the registered operation.
amountuint256Token quantity pending transfer.
expirationDateuint256Unix timestamp after which the operation may be reclaimed.
databytesCaller-supplied data attached to the operation.
operatorDatabytesData provided by the operator.

ClearedTransferFromByPartition​

event ClearedTransferFromByPartition(address indexed operator, address indexed tokenHolder, address indexed to, bytes32 partition, uint256 clearingId, uint256 amount, uint256 expirationDate, bytes data, bytes operatorData)

Emitted when a clearing-guarded transfer is registered on behalf of a token holder via transferFromByPartition.

Parameters​

NameTypeDescription
operator indexedaddressAddress that submitted the clearing operation on behalf of the holder.
tokenHolder indexedaddressAddress of the holder whose tokens are pending transfer.
to indexedaddressIntended recipient of the tokens upon approval.
partitionbytes32ERC-1400 partition the tokens belong to.
clearingIduint256Sequential identifier for the registered operation.
amountuint256Token quantity pending transfer.
expirationDateuint256Unix timestamp after which the operation may be reclaimed.
databytesCaller-supplied data attached to the operation.
operatorDatabytesData provided by the operator.

ClearingActivated​

event ClearingActivated(address indexed operator)

Emitted when the clearing feature is enabled for the token.

Parameters​

NameTypeDescription
operator indexedaddressAddress of the administrator that activated clearing.

ClearingDeactivated​

event ClearingDeactivated(address indexed operator)

Emitted when the clearing feature is disabled for the token.

Parameters​

NameTypeDescription
operator indexedaddressAddress of the administrator that deactivated clearing.

ClearingInitialized​

event ClearingInitialized(bool clearingActive)

Emitted once when the clearing module is initialised on a token.

Fires exclusively from initializeClearing after the storage write succeeds.

Parameters​

NameTypeDescription
clearingActiveboolWhether clearing was activated at initialisation time.

ClearingOperationApproved​

event ClearingOperationApproved(address indexed operator, address indexed tokenHolder, bytes32 indexed partition, uint256 clearingId, enum IClearingTypes.ClearingOperationType clearingOperationType, bytes operationData)

Emitted when a pending clearing operation is approved and the underlying token operation is executed.

Parameters​

NameTypeDescription
operator indexedaddressAddress that approved the operation.
tokenHolder indexedaddressAddress of the holder whose tokens were pending.
partition indexedbytes32ERC-1400 partition the tokens belong to.
clearingIduint256Sequential identifier of the approved operation.
clearingOperationTypeenum IClearingTypes.ClearingOperationTypeDiscriminant indicating the kind of operation approved.
operationDatabytesEncoded data forwarded to the underlying token call.

ClearingOperationCanceled​

event ClearingOperationCanceled(address indexed operator, address indexed tokenHolder, bytes32 indexed partition, uint256 clearingId, enum IClearingTypes.ClearingOperationType clearingOperationType)

Emitted when a pending clearing operation is cancelled before it expires.

Parameters​

NameTypeDescription
operator indexedaddressAddress that cancelled the operation.
tokenHolder indexedaddressAddress of the holder whose tokens were pending.
partition indexedbytes32ERC-1400 partition the tokens belong to.
clearingIduint256Sequential identifier of the cancelled operation.
clearingOperationTypeenum IClearingTypes.ClearingOperationTypeDiscriminant indicating the kind of operation cancelled.

ClearingOperationReclaimed​

event ClearingOperationReclaimed(address indexed operator, address indexed tokenHolder, bytes32 indexed partition, uint256 clearingId, enum IClearingTypes.ClearingOperationType clearingOperationType)

Emitted when an expired clearing operation is reclaimed, releasing the locked tokens back to the holder.

Parameters​

NameTypeDescription
operator indexedaddressAddress that reclaimed the operation.
tokenHolder indexedaddressAddress of the holder whose tokens were pending.
partition indexedbytes32ERC-1400 partition the tokens belong to.
clearingIduint256Sequential identifier of the reclaimed operation.
clearingOperationTypeenum IClearingTypes.ClearingOperationTypeDiscriminant indicating the kind of operation reclaimed.

Errors​

AccountHasNoRole​

error AccountHasNoRole(address account, bytes32 role)

Thrown when an account does not hold a required role.

Parameters​

NameTypeDescription
accountaddressThe account that lacks the role.
rolebytes32The role that is not held.

AssetNotOperational​

error AssetNotOperational(bytes32 configId, uint256 versionId)

Raised by InitializerStorageWrapper.checkOperational (and the related isConfigVersionOperational helper) when an operation is attempted on a configuration version that has not yet been marked operational.

Parameters​

NameTypeDescription
configIdbytes32Resolver-proxy configuration whose operational status was checked.
versionIduint256Configuration version whose operational status was checked.

ClearingIsActivated​

error ClearingIsActivated()

Thrown when an administration action requires clearing to be inactive but it is currently enabled.

ClearingIsDisabled​

error ClearingIsDisabled()

Thrown when a clearing-dependent operation is attempted while the clearing feature is disabled on the token.

Deactivated​

error Deactivated()

Thrown when an operation guarded by onlyActivated is attempted on a token whose deactivation flag has already been set.

ExpirationDateNotReached​

error ExpirationDateNotReached()

Thrown when an action requires the clearing operation to have expired (e.g., a reclaim attempt) but the expiration timestamp has not yet passed.

ExpirationDateReached​

error ExpirationDateReached()

Thrown when an action requires the clearing operation to still be within its validity window but its expiration timestamp has already passed.

FacetAlreadyRegistered​

error FacetAlreadyRegistered(bytes32 facetId, uint256 lastVersion)

Raised when an initialiser tries to register a facet that already has a non-zero last registered version (i.e. the facet is being re-initialised on a fresh install).

Parameters​

NameTypeDescription
facetIdbytes32Identifier of the offending facet.
lastVersionuint256Last version recorded for that facet at the time of the check.

InvalidClearingAmount​

error InvalidClearingAmount()

Thrown when the token amount supplied for a clearing operation is invalid (e.g., zero or exceeding the holder's available balance).

IsPaused​

error IsPaused()

Thrown when an operation that requires the token to be unpaused is attempted while the token is paused (own flag or any external pause contract).

UnrecognizedResolverProxyVersion​

error UnrecognizedResolverProxyVersion(bytes8 _resolverProxyVersion)

Thrown when the provided proxy version does not match any BLR compatible standard.

Parameters​

NameTypeDescription
_resolverProxyVersionbytes8proxy version that is not compatible with the BLR.

WalletRecovered​

error WalletRecovered()

Thrown when attempting to recover a wallet that has already been recovered.

WrongClearingId​

error WrongClearingId()

Thrown when the supplied clearingId does not correspond to an existing or active clearing operation for the given holder and partition.