SafeFacet
Facet providing SAFE (Simple Agreement for Future Equity) functionality
Diamond facet for SAFE terms management, MFN protection, and conversion logic
Functions
_isValidLot
Helper function to check if a lot is valid
function _isValidLot(bytes32 lotId) internal view returns (bool);
Parameters
lotId
bytes32
The lot ID to check
Returns
<none>
bool
True if lot is valid
initializeSafe
Initialize the SAFE functionality
function initializeSafe() external;
setDefaultTerms
Set default terms for all new SAFEs in this offering
function setDefaultTerms(
uint256 valuationCap,
uint256 discountRate,
address targetEquityToken,
bool proRataRight,
bool hasMFN
) external;
Parameters
valuationCap
uint256
The valuation cap (0 for no cap)
discountRate
uint256
The discount rate in basis points (2000 = 20%)
targetEquityToken
address
The target equity token address
proRataRight
bool
Whether investor has pro-rata rights
hasMFN
bool
Whether lots have MFN protection
createSafeLot
Create a lot with default SAFE terms
function createSafeLot(
address to,
uint256 quantity,
address paymentCurrency,
uint256 costBasis,
uint256 acquisitionDate,
string memory uri,
bytes memory data,
uint256 customId
) external returns (bytes32 lotId, uint256 assignedCustomId);
Parameters
to
address
The owner of the lot
quantity
uint256
The quantity of the lot
paymentCurrency
address
The payment currency
costBasis
uint256
The cost basis per unit
acquisitionDate
uint256
The acquisition date
uri
string
The URI for the lot
data
bytes
Additional data
customId
uint256
Optional custom ID (0 for auto-assignment)
Returns
lotId
bytes32
The unique ID of the new lot
assignedCustomId
uint256
The assigned custom ID
createSafeLotWithTerms
Create a lot with custom SAFE terms
function createSafeLotWithTerms(
address to,
uint256 quantity,
address paymentCurrency,
uint256 costBasis,
uint256 acquisitionDate,
string memory uri,
bytes memory data,
SafeStorage.Terms memory terms
) external returns (bytes32 lotId, uint256 assignedCustomId);
Parameters
to
address
The owner of the lot
quantity
uint256
The quantity of the lot
paymentCurrency
address
The payment currency
costBasis
uint256
The cost basis per unit
acquisitionDate
uint256
The acquisition date
uri
string
The URI for the lot
data
bytes
Additional data
terms
SafeStorage.Terms
The SAFE terms for this lot
Returns
lotId
bytes32
The unique ID of the new lot
assignedCustomId
uint256
The assigned custom ID
convertToEquity
Convert SAFE to equity
function convertToEquity(bytes32 lotId, uint256 pricePerShare, uint256 valuationAmount)
external
returns (bytes32 equityLotId);
Parameters
lotId
bytes32
The SAFE lot ID to convert
pricePerShare
uint256
The current price per share
valuationAmount
uint256
The current valuation
Returns
equityLotId
bytes32
The ID of the new equity lot
processMFNForNewTerms
Process MFN updates for new terms without creating a lot
function processMFNForNewTerms(SafeStorage.Terms memory terms) external returns (bytes32[] memory updatedLots);
Parameters
terms
SafeStorage.Terms
The new terms to compare against existing MFN lots
Returns
updatedLots
bytes32[]
Array of lot IDs that were updated
getLotTerms
Get SAFE terms for a specific lot
function getLotTerms(bytes32 lotId) external view returns (SafeStorage.Terms memory);
Parameters
lotId
bytes32
The lot ID
Returns
<none>
SafeStorage.Terms
The SAFE terms
getDefaultTerms
Get default SAFE terms
function getDefaultTerms() external view returns (SafeStorage.Terms memory);
Returns
<none>
SafeStorage.Terms
The default SAFE terms
isLotConverted
Check if a lot is converted
function isLotConverted(bytes32 lotId) external view returns (bool);
Parameters
lotId
bytes32
The lot ID
Returns
<none>
bool
True if converted
isMFNProtected
Check if a lot has MFN protection
function isMFNProtected(bytes32 lotId) external view returns (bool);
Parameters
lotId
bytes32
The lot ID
Returns
<none>
bool
True if MFN protected
getMFNLots
Get all MFN protected lot IDs
function getMFNLots() external view returns (bytes32[] memory);
Returns
<none>
bytes32[]
Array of MFN protected lot IDs
getMFNLotsCount
Get number of MFN protected lots
function getMFNLotsCount() external view returns (uint256);
Returns
<none>
uint256
The count of MFN protected lots
calculateConversionPrice
Calculate conversion price for a SAFE lot
function calculateConversionPrice(bytes32 lotId, uint256 pricePerShare, uint256 valuationAmount)
external
view
returns (uint256);
Parameters
lotId
bytes32
The lot ID
pricePerShare
uint256
The current price per share
valuationAmount
uint256
The current valuation
Returns
<none>
uint256
The conversion price
calculateEquityAmount
Calculate equity amount for a SAFE conversion
function calculateEquityAmount(bytes32 lotId, uint256 pricePerShare, uint256 valuationAmount)
external
view
returns (uint256);
Parameters
lotId
bytes32
The lot ID
pricePerShare
uint256
The current price per share
valuationAmount
uint256
The current valuation
Returns
<none>
uint256
The equity amount that would be received
isSafeInitialized
Check if SAFE is initialized
function isSafeInitialized() external view returns (bool);
Returns
<none>
bool
True if initialized
getSafeLotInfo
Get lot information with conversion status
function getSafeLotInfo(bytes32 lotId)
external
view
returns (
bytes32 parentLotId,
bool isValid,
uint256 quantity,
address paymentCurrency,
uint256 costBasis,
uint256 acquisitionDate,
uint256 lastUpdate,
IIssuedAsset.TransferType tType,
string memory uri,
bytes memory data,
bool isConverted,
SafeStorage.Terms memory terms
);
Parameters
lotId
bytes32
The lot ID
Returns
parentLotId
bytes32
The parent lot ID
isValid
bool
Whether the lot is valid
quantity
uint256
The quantity
paymentCurrency
address
The payment currency
costBasis
uint256
The cost basis
acquisitionDate
uint256
The acquisition date
lastUpdate
uint256
The last update timestamp
tType
IIssuedAsset.TransferType
The transfer type
uri
string
The URI
data
bytes
Additional data
isConverted
bool
Whether the SAFE is converted
terms
SafeStorage.Terms
The SAFE terms
_validateCompliance
Validate compliance through ComplianceFacet
function _validateCompliance(address from, address to, bytes32 lotId, uint256 quantity) internal view;
Parameters
from
address
The sender address
to
address
The recipient address
lotId
bytes32
The lot ID being transferred
quantity
uint256
The quantity being transferred
_processIssuance
Process issuance through ComplianceFacet
function _processIssuance(address to, bytes32 lotId, uint256 quantity, bytes memory data) internal;
Parameters
to
address
The recipient address
lotId
bytes32
The lot ID being issued
quantity
uint256
The quantity being issued
data
bytes
Additional issuance data
Events
DefaultTermsSet
event DefaultTermsSet(
uint256 valuationCap, uint256 discountRate, address targetEquityToken, bool proRataRight, bool hasMFN
);
LotTermsSet
event LotTermsSet(bytes32 indexed lotId, uint256 valuationCap, uint256 discountRate);
SafeConverted
event SafeConverted(bytes32 indexed lotId, address indexed investor, bytes32 indexed equityLotId);
MFNTermsUpdated
event MFNTermsUpdated(bytes32 indexed lotId, uint256 newValuationCap, uint256 newDiscountRate);
Last updated
Was this helpful?