Skip to content

Commit

Permalink
[Update] Added struct inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyPoslavskiy committed May 3, 2024
1 parent 2e4011f commit b8970b5
Show file tree
Hide file tree
Showing 8 changed files with 352 additions and 390 deletions.
67 changes: 66 additions & 1 deletion contracts/interfaces/IERC20BasePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,63 @@
pragma solidity 0.8.25;

interface IERC20BasePool {
struct BaseUserInfo {
uint256 amount; // Amount of tokens staked
uint256 claimed; // Amount of claimed rewards
uint256 rewardDebt; // Reward debt
uint256 pending; // Pending rewards
}

struct BasePoolInfo {
address stakeToken; // ERC20 token being staked
address rewardToken; // ERC20 token used for rewards
uint256 startTime; // Start time of the staking pool
uint256 endTime; // End time of the staking pool
uint256 rewardTokenPerSecond; // Rate of rewards per second
uint256 totalStaked; // Total amount of tokens staked
uint256 totalClaimed; // Total amount of claimed rewards
uint256 lastRewardTimestamp; // Timestamp of the last reward update
uint256 accRewardPerShare; // Accumulated rewards per share
bool isActive; // Flag indicating if the pool is active
address adminWallet; // Address of the admin
}

/**
* ERROR MESSAGES
*/

/// @dev Error to indicate an invalid staking period
error InvalidStakingPeriod();

/// @dev Error to indicate an invalid start time for the staking pool
error InvalidStartTime();

/// @dev Error to indicate an invalid input amount for the staking and unstaking operations in the pool
error InvalidAmount();

/// @dev Error to indicate insufficient amount of tokens
/// @param reqAmount The amount of tokens that is required
/// @param currentAmount The current amount of tokens
error InsufficientAmount(uint256 reqAmount, uint256 currentAmount);

/// @dev Error to indicate that the user has no available rewards to claim
error NothingToClaim();

/// @dev Error to indicate that the staking pool has not started yet
error PoolNotStarted();

/// @dev Error to indicate that the staking pool has already ended
error PoolHasEnded();

/// @dev Error to indicate that the staking pool is not active
error PoolNotActive();

/// @dev Error to indicate that the staking pool is already active
error PoolIsActive();

/// @dev Error to indicate that the caller is not the admin
error NotAdmin();

/**
* EVENTS
*/
Expand Down Expand Up @@ -76,5 +133,13 @@ interface IERC20BasePool {
* @param userAddress Address of the user
* @return pending rewards
*/
function pendingRewards(address userAddress) external view returns (uint256);
function pendingRewards(
address userAddress
) external view returns (uint256);

/**
* @notice Function to activate the staking pool
* @dev Protected by onlyAdmin modifier. Only platform admin can activate pools
*/
function activate() external;
}
23 changes: 23 additions & 0 deletions contracts/interfaces/IERC20LockUpPoolExtension.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;
import {IERC20BasePool} from "./IERC20BasePool.sol";

interface IERC20LockUpPoolExtension is IERC20BasePool {
struct LockUpPool {
BasePoolInfo baseInfo;
uint256 unstakeLockupTime; // Lockup period for unstaking
uint256 claimLockupTime; // Lockup period for claiming rewards
}

/**
* ERROR MESSAGES
*/

/// @dev Error to indicate that tokens are still in lockup and cannot be accessed
/// @param currentTime The current timestamp
/// @param unlockTime The timestamp when the tokens will be unlocked
error TokensInLockup(uint256 currentTime, uint256 unlockTime);

/// @dev Error to indicate an invalid lockup time for unstaking or claiming rewards
error InvalidLockupTime();
}
27 changes: 27 additions & 0 deletions contracts/interfaces/IERC20PenaltyPoolExtension.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;
import {IERC20BasePool} from "./IERC20BasePool.sol";

interface IERC20PenaltyPoolExtension is IERC20BasePool {
struct PenaltyPool {
BasePoolInfo baseParams;
uint256 penaltyPeriod;
uint256 totalPenalties;
}

struct PenaltyUser {
BaseUserInfo baseInfo;
uint256 penaltyEndTime;
bool penalized;
}

/**
* ERROR MESSAGES
*/
/// @dev Error to indicate that tokens are still in lockup and cannot be accessed
/// @param currentTime The current timestamp
/// @param unlockTime The timestamp when the tokens will be unlocked
error TokensInLockup(uint256 currentTime, uint256 unlockTime);
/// @dev Error to indicate an invalid penalty duration for unstaking
error InvalidPenaltyPeriod();
}
47 changes: 0 additions & 47 deletions contracts/interfaces/IErrors.sol

This file was deleted.

Loading

0 comments on commit b8970b5

Please sign in to comment.