- You can have multiple bonus levels in your contract to provide a bonus based on different time durations, for example, 30% for the first day, 15% for the second day, and 5% for the third day.
- A struct can be used to save the bonus duration for each day:
// Custom data type to store bonus parameterstruct Bonus { uint startTime; uint endTime; uint bonusPercent}// Array of fixed length to store 3 bonus levelsBonus[3] bonus;
- The values can be initialized through the constructor. Based on the bonus logic, you can either use an iteration or assign values individually. For simplicity, we are assigning each bonus duration individually:
constructor() { bonus[0].startTime = openingTime; bonus[0].endTime = openingTime + 1 days; bonus[0].bonusPercent ...