Good evening
The contract (IncreasingPriceCrowdsale.sol) allows to have the functionality of a gradual price increase. My question is: is there a way to increase the price on certain dates? for example, every 5 days the price increases. Can this be done? Could you share an example with me?
Thank you very much.
1 Like
Hi @jeissoni ,
Yes you can create price increases on certain dates.
You could take the ideas from IncreasingPriceCrowdsale, extend Crowdsale and in a getCurrentRate
function specify the rate after specific times.
*/
function finalRate() public view returns (uint256) {
return _finalRate;
}
/**
* @dev Returns the rate of tokens per wei at the present time.
* Note that, as price _increases_ with time, the rate _decreases_.
* @return The number of tokens a buyer gets per wei at a given time
*/
function getCurrentRate() public view returns (uint256) {
if (!isOpen()) {
return 0;
}
// solhint-disable-next-line not-rely-on-time
uint256 elapsedTime = block.timestamp.sub(openingTime());
uint256 timeRange = closingTime().sub(openingTime());
uint256 rateRange = _initialRate.sub(_finalRate);
return _initialRate.sub(elapsedTime.mul(rateRange).div(timeRange));
}
The Crowdsales documentation can be found here: https://docs.openzeppelin.com/contracts/2.x/crowdsales
Hi @jeissoni ,
Let me know if you have any questions.