SafeStorage
Diamond storage library for SAFE (Simple Agreement for Future Equity) functionality
Uses deterministic storage slots to avoid storage collisions with IssuedAsset
State Variables
SAFE_STORAGE_POSITION
bytes32 constant SAFE_STORAGE_POSITION = keccak256("capsign.storage.safe");
Functions
layout
Get the SAFE storage layout
function layout() internal pure returns (Layout storage l);
Returns
l
Layout
The storage layout struct
initializeSafeStorage
Initialize the SAFE storage with default values
function initializeSafeStorage() internal;
setDefaultTermsInternal
Set default terms for all new SAFEs in this offering
function setDefaultTermsInternal(
uint256 valuationCap,
uint256 discountRate,
address targetEquityToken,
bool proRataRight,
bool hasMFN
) internal;
Parameters
valuationCap
uint256
The valuation cap (0 for no cap)
discountRate
uint256
The discount rate in basis points
targetEquityToken
address
The target equity token address
proRataRight
bool
Whether investor has pro-rata rights
hasMFN
bool
Whether lots have MFN protection
setLotTermsInternal
Set terms for a specific lot
function setLotTermsInternal(bytes32 lotId, Terms memory terms) internal;
Parameters
lotId
bytes32
The lot ID
terms
Terms
The terms to set
setLotTermsFromDefaultInternal
Set terms for a lot using default terms
function setLotTermsFromDefaultInternal(bytes32 lotId) internal;
Parameters
lotId
bytes32
The lot ID
markLotConvertedInternal
Mark a lot as converted
function markLotConvertedInternal(bytes32 lotId) internal;
Parameters
lotId
bytes32
The lot ID
isLotConvertedInternal
Check if a lot is converted
function isLotConvertedInternal(bytes32 lotId) internal view returns (bool);
Parameters
lotId
bytes32
The lot ID
Returns
<none>
bool
True if converted
getLotTermsInternal
Get terms for a specific lot
function getLotTermsInternal(bytes32 lotId) internal view returns (Terms memory);
Parameters
lotId
bytes32
The lot ID
Returns
<none>
Terms
The terms for the lot
getDefaultTermsInternal
Get default terms
function getDefaultTermsInternal() internal view returns (Terms memory);
Returns
<none>
Terms
The default terms
isMFNProtectedInternal
Check if a lot has MFN protection
function isMFNProtectedInternal(bytes32 lotId) internal view returns (bool);
Parameters
lotId
bytes32
The lot ID
Returns
<none>
bool
True if MFN protected
getMFNLotsInternal
Get all MFN protected lot IDs
function getMFNLotsInternal() internal view returns (bytes32[] memory);
Returns
<none>
bytes32[]
Array of MFN protected lot IDs
checkAndUpdateMFNTermsInternal
Check if new terms are more favorable and update MFN lots
function checkAndUpdateMFNTermsInternal(
Terms memory newTerms,
function(bytes32) internal view returns (bool) isLotValid
) internal returns (bytes32[] memory updatedLots);
Parameters
newTerms
Terms
The new terms to compare
isLotValid
function (bytes32) internal view returns (bool)
Function to check if lot is valid
Returns
updatedLots
bytes32[]
Array of lot IDs that were updated
calculateConversionPriceInternal
Calculate conversion price based on SAFE terms
function calculateConversionPriceInternal(Terms memory terms, uint256 pricePerShare, uint256 valuationAmount)
internal
pure
returns (uint256);
Parameters
terms
Terms
The SAFE terms
pricePerShare
uint256
The current price per share
valuationAmount
uint256
The current valuation
Returns
<none>
uint256
The conversion price
calculateEquityAmountInternal
Calculate equity amount for conversion
function calculateEquityAmountInternal(uint256 investmentAmount, uint256 conversionPrice, uint8 decimals)
internal
pure
returns (uint256);
Parameters
investmentAmount
uint256
The SAFE investment amount
conversionPrice
uint256
The conversion price
decimals
uint8
The decimals of the target equity token
Returns
<none>
uint256
The equity amount
isSafeInitialized
Check if SAFE is initialized
function isSafeInitialized() internal view returns (bool);
Returns
<none>
bool
True if initialized
getMFNLotsCountInternal
Get MFN lots count
function getMFNLotsCountInternal() internal view returns (uint256);
Returns
<none>
uint256
The number of MFN protected lots
removeMFNLotInternal
Remove a lot from MFN tracking (when lot becomes invalid)
function removeMFNLotInternal(bytes32 lotId) internal;
Parameters
lotId
bytes32
The lot ID to remove
Structs
Terms
struct Terms {
uint256 valuationCap;
uint256 discountRate;
address targetEquityToken;
bool proRataRight;
uint256 maturityDate;
bool hasMFN;
}
Layout
struct Layout {
Terms defaultTerms;
mapping(bytes32 => Terms) lotTerms;
mapping(bytes32 => bool) lotConverted;
mapping(bytes32 => bool) mfnProtectedLots;
bytes32[] mfnLots;
bool safeInitialized;
}
Last updated
Was this helpful?