Inherits:
A base abstract contract for any kind of offering (public or exempt). Derived contracts must implement 'invest' logic and any finishing steps.
State Variables
status
Status public status;
issuer
address public issuer;
asset
paymentToken
IERC20 public paymentToken;
totalInvested
uint256 public totalInvested;
pricePerToken
uint256 public pricePerToken;
minInvestment
uint256 public minInvestment;
investmentDeadline
uint256 public investmentDeadline;
targetAmount
uint256 public targetAmount;
maxAmount
uint256 public maxAmount;
uri
nextInvestmentId
uint256 public nextInvestmentId;
investments
mapping(uint256 => Investment) public investments;
investmentInvestors
mapping(uint256 => address) public investmentInvestors;
Functions
constructor
constructor(
address _issuer,
address _asset,
address _paymentToken,
uint256 _pricePerToken,
uint256 _minInvestment,
uint256 _investmentDeadline,
uint256 _targetAmount,
uint256 _maxAmount,
string memory _uri
);
invest
Allows an investor to invest in this offering. Implementation differs for public vs exempt offerings.
function invest(uint256 _amount, uint256 _pricePerToken) external virtual;
countersign
*Countersign the investment for a specific investor, which:
createLots tokens to the investor
Transfers their funds from escrow to issuer*
function countersign(uint256 investmentId) external virtual;
Parameters
The ID of the investment to countersign
_beforeCountersign
function _beforeCountersign(address) internal virtual;
_afterCountersign
function _afterCountersign(address) internal virtual;
_createLotTokensToInvestor
Internal function to createLot tokens to investor. Must be implemented by derived contracts.
function _createLotTokensToInvestor(address investor, uint256 amount) internal virtual;
closeOffering
Closes the offering, preventing further investments.
function closeOffering() external virtual;
setPricePerToken
Set the price per token for this offering.
function setPricePerToken(uint256 newPrice) external;
_validateInvestment
Helper function to validate investment constraints. Child contracts should call this in their invest() implementation.
function _validateInvestment(uint256 amount) internal view;
setMinInvestment
Set the minimum investment per investor.
function setMinInvestment(uint256 newMin) external;
setInvestmentDeadline
Set an investment deadline (UTC timestamp). Setting this to 0 effectively removes the deadline.
function setInvestmentDeadline(uint256 newDeadline) external;
extendInvestmentDeadline
Extend the current investment deadline to newDeadline (which must be later).
function extendInvestmentDeadline(uint256 newDeadline) external;
setTargetAmount
Set a target amount for this offering (informational/tracking only).
function setTargetAmount(uint256 newTarget) external;
setMaxAmount
Set a maximum total investment allowed in this offering. Setting this to 0 removes any max limit.
function setMaxAmount(uint256 newMax) external;
cancelOffering
The issuer can explicitly cancel the offering. No more investments or countersigns allowed.
function cancelOffering() external;
setURI
The issuer can update the URI pointing to any relevant data (e.g. promotional image or JSON).
function setURI(string calldata newURI) external;
_completeOfferingInternal
function _completeOfferingInternal() internal;
Events
OfferingCreated
Events
event OfferingCreated(
address indexed issuer,
address indexed asset,
address indexed paymentToken,
uint256 pricePerToken,
uint256 minInvestment,
uint256 investmentDeadline,
uint256 targetAmount,
uint256 maxAmount,
string uri
);
OfferingInvested
event OfferingInvested(address indexed investor, uint256 investmentId, uint256 amount, uint256 pricePerToken);
OfferingInvestmentCountersigned
event OfferingInvestmentCountersigned(address indexed investor, uint256 investmentId, uint256 amount);
OfferingPricePerTokenUpdated
event OfferingPricePerTokenUpdated(uint256 newPrice);
OfferingMinInvestmentUpdated
event OfferingMinInvestmentUpdated(uint256 newMin);
OfferingInvestmentDeadlineUpdated
event OfferingInvestmentDeadlineUpdated(uint256 newDeadline);
OfferingTargetAmountUpdated
event OfferingTargetAmountUpdated(uint256 newTarget);
OfferingMaxAmountUpdated
event OfferingMaxAmountUpdated(uint256 newMax);
OfferingURIUpdated
event OfferingURIUpdated(string newURI);
OfferingCancelled
event OfferingCancelled();
OfferingClosed
event OfferingClosed();
Structs
Investment
struct Investment {
uint256 amount;
bool countersigned;
uint256 pricePerToken;
}
Enums
Status
enum Status {
Active,
Completed,
Cancelled
}