ShareClass
Inherits: IssuedAsset
Author: CapSign Inc.
Extends the IssuedAsset contract to add features specific to share classes, such as dividends, splits, and corporate actions.
State Variables
cumulativeSplitNum
*We maintain cumulative multipliers:
cumulativeSplitNum / cumulativeSplitDen track how splits have changed quantity/cost basis.
cumulativeDivNum / cumulativeDivDen track how stock dividends have changed quantity. Example:
1st split: 2-for-1 => multiply (2/1) into cumulativeSplitNum/Den
2nd split: 3-for-1 => multiply again => final ratio = (2/1) * (3/1) = (6/1)
1st dividend: 10% => multiply (110/100) into (cumulativeDivNum/cumulativeDivDen)*
uint96 public cumulativeSplitNum = 1;
cumulativeSplitDen
uint96 public cumulativeSplitDen = 1;
cumulativeDivNum
uint96 public cumulativeDivNum = 1;
cumulativeDivDen
uint96 public cumulativeDivDen = 1;
cumulativeDivCostBasisNum
uint96 public cumulativeDivCostBasisNum = 1;
cumulativeDivCostBasisDen
uint96 public cumulativeDivCostBasisDen = 1;
userRawTotals
mapping(address => uint96) public userRawTotals;
isPublicIssuer
bool public isPublicIssuer;
authorizedAmount
The authorized amount of shares that can be issued.
uint256 public authorizedAmount;
complianceModules
address[] public complianceModules;
Functions
initialize
function initialize(address _issuer, string memory _name, string memory _prefix) public virtual initializer;
addComplianceModule
Adds a transfer restriction module.
Only callable by an admin.
function addComplianceModule(address _module) external onlyAdmin;
removeComplianceModule
Removes a transfer restriction module by index.
Only callable by an admin.
function removeComplianceModule(uint256 index) external onlyAdmin;
_beforeTransferHook
Runs registered transfer restriction module checks.
function _beforeTransferHook(address from, address to, uint96 quantity, bytes32 tokenId, bytes memory data)
internal
view;
Parameters
from
address
The sender (or address(0) for createLoting).
to
address
The recipient.
quantity
uint96
The "real" token quantity involved.
tokenId
bytes32
The lot identifier (or zero if not yet assigned).
data
bytes
applyStockDividend
*Applies a stock dividend. If reducesBasis
is true, we treat it like a split for cost basis. Otherwise, only the share quantity ratio is updated. Example usage:
applyStockDividend(110, 100, false) -> 10% dividend, does NOT reduce cost basis.
applyStockDividend(150, 100, true) -> 50% dividend, does reduce cost basis.*
function applyStockDividend(uint96 divNum, uint96 divDen, bool reducesBasis) external onlyAdmin;
Parameters
divNum
uint96
Numerator of the dividend ratio.
divDen
uint96
Denominator of the dividend ratio.
reducesBasis
bool
Whether this dividend reduces cost basis.
applyStockSplit
*Applies a new stock split ratio (e.g., 2-for-1). This function updates the cumulativeSplitNum/cumulativeSplitDen ratio multiplicatively. Example:
If you already had a 2-for-1 in effect (2/1), and you call this with (3,1), your final ratio is (23)/(11) = (6/1).*
function applyStockSplit(uint96 splitNum, uint96 splitDen) external onlyAdmin;
Parameters
splitNum
uint96
Numerator of the new split ratio.
splitDen
uint96
Denominator of the new split ratio.
createLot
Overridden createLot, which expects the user to specify a "real" quantity. Internally, we convert it to a "raw" quantity before storing.
function createLot(
address to,
uint96 realAmount,
address paymentCurrency,
uint96 costBasis,
uint64 acquisitionDate,
string memory uri,
bytes memory data
) public virtual override onlyAdmin returns (bytes32 tokenId);
transferFrom
Overridden transferFrom: we interpret 'transferQuantity' as a "real" quantity, then convert to raw, and call the base function.
function transferFrom(
bytes32 tokenId,
address from,
address to,
uint96 transferRealQuantity,
string memory uri,
bytes memory data
) public virtual override onlyAdmin;
getVotingPower
Convert raw total to real using ratio
function getVotingPower(address account) external view returns (uint256 votingPower);
_getRealQuantity
Helper to compute the real (post-split + post-dividend) quantity. We apply: realQuantity = rawQuantity (cumulativeSplitNum / cumulativeSplitDen) (cumulativeDivNum / cumulativeDivDen)
function _getRealQuantity(uint96 rawQuantity) internal view returns (uint96);
_convertRealToRawQuantity
Helper to convert real (post-split + dividend) quantity back to raw. Inverse of _getRealQuantity
.
function _convertRealToRawQuantity(uint96 realQuantity) internal view returns (uint96);
_getRealCostBasis
Helper to compute the real (post-split + post-dividend) cost basis. For splits, cost basis = rawBasis * (splitDen / splitNum). For large dividends (that reduce basis): cost basis is also scaled by (divCostBasisDen / divCostBasisNum). For small dividends, that ratio remains 1/1 (unchanged).
function _getRealCostBasis(uint96 rawBasis) internal view returns (uint96);
getTotalRealSupply
Returns the total real supply of shares, adjusted for splits and dividends.
function getTotalRealSupply() external view returns (uint256);
Returns
<none>
uint256
The total real supply of shares.
getLot
Returns the stored data plus "real" (post-split+dividend) quantity and costBasis.
function getLot(bytes32 lotId)
external
view
override
returns (
bytes32 parentLotId,
bool isValid,
uint96 realQuantity,
address paymentCurrency,
uint96 realCostBasis,
uint64 acquisitionDate,
uint64 lastUpdate,
string memory uri,
bytes memory data
);
Parameters
lotId
bytes32
The lot ID to query.
Returns
parentLotId
bytes32
Hash of the parent lot, or 0x0 if none.
isValid
bool
Whether the lot is active.
realQuantity
uint96
The adjusted quantity after splits/dividends.
paymentCurrency
address
The payment currency for this lot.
realCostBasis
uint96
The adjusted cost basis after splits (and optionally dividends).
acquisitionDate
uint64
The original acquisition timestamp (unmodified).
lastUpdate
uint64
The last time this lot was updated.
uri
string
The URI of the lot.
data
bytes
Additional data associated with the lot.
getRawLot
Convenience function to return the raw stored data without transformations.
function getRawLot(bytes32 lotId)
external
view
returns (
bytes32 parentLotId,
bool isValid,
uint96 quantity,
address paymentCurrency,
uint96 costBasis,
uint64 acquisitionDate,
uint64 lastUpdate,
string memory uri,
bytes memory data
);
setIssuerPublicStatus
Sets the issuer public status. If _isPublic
is true, the share class issuer is considered public (registered with the SEC). Otherwise, it is considered private. Only callable by an admin.
function setIssuerPublicStatus(bool _isPublic) external onlyAdmin;
setAuthorizedAmount
Sets the authorized amount of shares that can be issued. Only callable by an admin.
function setAuthorizedAmount(uint256 _authorizedAmount) external onlyAdmin;
Events
ComplianceModuleAdded
event ComplianceModuleAdded(address module);
ComplianceModuleRemoved
event ComplianceModuleRemoved(address module);
StockSplitApplied
Events for corporate actions
event StockSplitApplied(uint96 splitNum, uint96 splitDen);
StockDividendApplied
event StockDividendApplied(uint96 divNum, uint96 divDen, bool reducesBasis);
IssuerPublicStatusUpdated
Event that emits when the issuer public status is updated.
event IssuerPublicStatusUpdated(bool isPublic);
AuthorizedAmountUpdated
Event that emits when the authorized amount is updated.
event AuthorizedAmountUpdated(uint256 authorizedAmount);
Last updated
Was this helpful?