Skip to main content

Cap

Asset Tokenization Studio Team

Cap

Abstract contract implementing maximum supply management for a security token, both globally and per partition.

Implements ICap. Cap state is stored at STORAGE_LOCATION_CAP via CapStorageWrapper. All timestamp-sensitive operations delegate to TimeTravelStorageiWrapper.getBlockTimestamp() so the same code path is exercisable in test environments. setMaxSupply and getMaxSupply use the adjusted supply (AdjustBalancesStorageWrapper) to account for pending scheduled balance adjustments. Intended to be inherited exclusively by CapFacet.

Methods​

getMaxSupply​

function getMaxSupply() external view returns (uint256 maxSupply_)

Returns the current effective maximum supply.

The raw stored cap is multiplied by any pending scheduled balance-adjustment factor (ABAF) at the current block timestamp. If the product would overflow uint256, the value saturates to MAX_UINT256.

Returns​

NameTypeDescription
maxSupply_uint256The effective maximum supply at the current timestamp.

initializeCap​

function initializeCap(uint256 maxSupply, ICap.PartitionCap[] partitionCap) external nonpayable

Parameters​

NameTypeDescription
maxSupplyuint256undefined
partitionCapICap.PartitionCap[]undefined

setMaxSupply​

function setMaxSupply(uint256 maxSupply) external nonpayable returns (bool success_)

Updates the global maximum supply of the token.

Requires the token to be unpaused and ROLE_CAP. Cap validation and event emission are handled inside CapStorageWrapper.setMaxSupply.

Parameters​

NameTypeDescription
maxSupplyuint256undefined

Returns​

NameTypeDescription
success_boolTrue if the cap was successfully updated.

Events​

CapInitialized​

event CapInitialized(uint256 maxSupply, ICap.PartitionCap[] partitionCap)

Emitted once when the Cap capability is initialised on a token.

Fires exclusively from initializeCap after the storage write succeeds.

Parameters​

NameTypeDescription
maxSupplyuint256The global maximum token supply set during initialisation.
partitionCapICap.PartitionCap[]Array of per-partition cap configurations.

MaxSupplyByPartitionSet​

event MaxSupplyByPartitionSet(address indexed operator, bytes32 indexed partition, uint256 newMaxSupply, uint256 previousMaxSupply)

Emitted when the maximum supply for a specific partition is updated.

Parameters​

NameTypeDescription
operator indexedaddressAddress of the caller who performed the update.
partition indexedbytes32The partition whose cap was changed.
newMaxSupplyuint256The new maximum supply value for the partition.
previousMaxSupplyuint256The previous maximum supply value for the partition.

MaxSupplySet​

event MaxSupplySet(address indexed operator, uint256 newMaxSupply, uint256 previousMaxSupply)

Emitted when the global maximum supply is updated.

Parameters​

NameTypeDescription
operator indexedaddressAddress of the caller who performed the update.
newMaxSupplyuint256The new maximum supply value.
previousMaxSupplyuint256The previous maximum supply value.

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.

Deactivated​

error Deactivated()

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

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.

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).

MaxSupplyReached​

error MaxSupplyReached(uint256 maxSupply)

Thrown when a mint would cause the total supply to exceed the global maximum.

Parameters​

NameTypeDescription
maxSupplyuint256The current global maximum supply.

MaxSupplyReachedForPartition​

error MaxSupplyReachedForPartition(bytes32 partition, uint256 maxSupply)

Thrown when a mint would cause a partition's total supply to exceed its cap.

Parameters​

NameTypeDescription
partitionbytes32The partition whose cap would be exceeded.
maxSupplyuint256The current maximum supply for the partition.

NewMaxSupplyCannotBeZero​

error NewMaxSupplyCannotBeZero()

Thrown when a proposed new global cap is zero.

NewMaxSupplyForPartitionTooLow​

error NewMaxSupplyForPartitionTooLow(bytes32 partition, uint256 maxSupply, uint256 totalSupply)

Thrown when a proposed new partition cap is below the partition's current adjusted total supply.

Parameters​

NameTypeDescription
partitionbytes32The partition whose cap would be set below its current supply.
maxSupplyuint256The proposed new maximum supply for the partition.
totalSupplyuint256The current adjusted total supply for the partition.

NewMaxSupplyTooLow​

error NewMaxSupplyTooLow(uint256 maxSupply, uint256 totalSupply)

Thrown when a proposed new global cap is below the current adjusted total supply.

Parameters​

NameTypeDescription
maxSupplyuint256The proposed new maximum supply.
totalSupplyuint256The current adjusted total supply that exceeds it.

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.