EsoStorage
Diamond storage library for Employee Stock Option functionality
Uses deterministic storage slots to avoid storage collisions with IssuedAsset
State Variables
ESO_STORAGE_POSITION
bytes32 constant ESO_STORAGE_POSITION = keccak256("capsign.storage.eso");
Functions
layout
Get the ESO storage layout
function layout() internal pure returns (Layout storage l);
Returns
l
Layout
The storage layout struct
initializeEsoStorage
Initialize the ESO storage with default values
function initializeEsoStorage() internal;
createOptionTokenInternal
Create a new option token
function createOptionTokenInternal(
bytes32 tokenId,
address owner,
uint96 quantity,
address paymentCurrency,
uint96 strikePrice,
uint256 vestingStartTime,
uint256 cliffTime,
uint256 vestingEndTime
) internal;
Parameters
tokenId
bytes32
The unique token ID
owner
address
The owner address
quantity
uint96
The number of options
paymentCurrency
address
The payment currency
strikePrice
uint96
The strike price
vestingStartTime
uint256
The vesting start time
cliffTime
uint256
The cliff time
vestingEndTime
uint256
The vesting end time
invalidateOptionTokenInternal
Invalidate an option token
function invalidateOptionTokenInternal(bytes32 tokenId) internal;
Parameters
tokenId
bytes32
The token ID to invalidate
exerciseOptionInternal
Exercise options (reduce quantity)
function exerciseOptionInternal(bytes32 tokenId, uint96 exerciseQuantity) internal returns (uint96 remainingQuantity);
Parameters
tokenId
bytes32
The token ID
exerciseQuantity
uint96
The quantity to exercise
Returns
remainingQuantity
uint96
The remaining quantity after exercise
getOptionTokenInternal
Get option token information
function getOptionTokenInternal(bytes32 tokenId) internal view returns (OptionToken memory);
Parameters
tokenId
bytes32
The token ID
Returns
<none>
OptionToken
The option token struct
isOptionTokenValidInternal
Check if an option token is valid
function isOptionTokenValidInternal(bytes32 tokenId) internal view returns (bool);
Parameters
tokenId
bytes32
The token ID
Returns
<none>
bool
True if valid
getOwnerOptionsInternal
Get all option tokens for an owner
function getOwnerOptionsInternal(address owner) internal view returns (bytes32[] memory);
Parameters
owner
address
The owner address
Returns
<none>
bytes32[]
Array of token IDs
getOwnerOptionCountInternal
Get the number of option tokens for an owner
function getOwnerOptionCountInternal(address owner) internal view returns (uint256);
Parameters
owner
address
The owner address
Returns
<none>
uint256
The count of option tokens
calculateVestedQuantityInternal
Calculate vested quantity for an option token
function calculateVestedQuantityInternal(bytes32 tokenId) internal view returns (uint96);
Parameters
tokenId
bytes32
The token ID
Returns
<none>
uint96
The vested quantity as of current time
calculateVestedQuantityAtTimeInternal
Calculate vested quantity at a specific time
function calculateVestedQuantityAtTimeInternal(bytes32 tokenId, uint256 timestamp) internal view returns (uint96);
Parameters
tokenId
bytes32
The token ID
timestamp
uint256
The timestamp to calculate vesting for
Returns
<none>
uint96
The vested quantity at the specified time
generateOptionTokenIdInternal
Generate an option token ID
function generateOptionTokenIdInternal(
address owner,
uint96 quantity,
address paymentCurrency,
uint96 strikePrice,
uint256 vestingStartTime,
uint256 cliffTime,
uint256 vestingEndTime
) internal view returns (bytes32);
Parameters
owner
address
The owner address
quantity
uint96
The quantity
paymentCurrency
address
The payment currency
strikePrice
uint96
The strike price
vestingStartTime
uint256
The vesting start time
cliffTime
uint256
The cliff time
vestingEndTime
uint256
The vesting end time
Returns
<none>
bytes32
The generated token ID
isEsoInitialized
Check if ESO is initialized
function isEsoInitialized() internal view returns (bool);
Returns
<none>
bool
True if initialized
updateOptionTokenOwnerInternal
Update option token owner (for transfers)
function updateOptionTokenOwnerInternal(bytes32 tokenId, address newOwner) internal;
Parameters
tokenId
bytes32
The token ID
newOwner
address
The new owner address
getOwnerTotalQuantityInternal
Get total quantity of options for an owner
function getOwnerTotalQuantityInternal(address owner) internal view returns (uint256);
Parameters
owner
address
The owner address
Returns
<none>
uint256
The total quantity
getOwnerTotalVestedQuantityInternal
Get total vested quantity for an owner
function getOwnerTotalVestedQuantityInternal(address owner) internal view returns (uint256);
Parameters
owner
address
The owner address
Returns
<none>
uint256
The total vested quantity
getOwnerTotalExerciseValueInternal
Get total exercise value for an owner
function getOwnerTotalExerciseValueInternal(address owner, uint96 currentPrice) internal view returns (uint256);
Parameters
owner
address
The owner address
currentPrice
uint96
The current stock price
Returns
<none>
uint256
The total exercise value
calculateExerciseValueInternal
Calculate exercise value for an option token
function calculateExerciseValueInternal(bytes32 tokenId, uint96 currentPrice) internal view returns (uint256);
Parameters
tokenId
bytes32
The token ID
currentPrice
uint96
The current stock price
Returns
<none>
uint256
The exercise value
isInTheMoneyInternal
Check if option is in the money
function isInTheMoneyInternal(bytes32 tokenId, uint96 currentPrice) internal view returns (bool);
Parameters
tokenId
bytes32
The token ID
currentPrice
uint96
The current stock price
Returns
<none>
bool
True if current price > strike price
Structs
OptionToken
struct OptionToken {
bool isValid;
address owner;
uint96 quantity;
address paymentCurrency;
uint96 strikePrice;
uint96 totalGrantAmount;
uint256 vestingStartTime;
uint256 cliffTime;
uint256 vestingEndTime;
}
Layout
struct Layout {
mapping(bytes32 => OptionToken) optionTokens;
mapping(address => bytes32[]) ownerOptions;
bool esoInitialized;
address compensationFactory;
address rule701Diamond;
}
Last updated
Was this helpful?