DepositPool
Introduction
The DepositPool
contract serves as the primary staking and reward tracking layer in the protocol. It manages user deposits of a specific ERC20 token, tracks staking positions and lock periods, handles reward rate logic, and provides mechanisms for secure and modular reward claiming — including support for referrers and delegated claims. This contract operates as a satellite to the central Distributor
and RewardPool
contracts, and can be deployed per reward pool on Ethereum.
Key Responsibilities
Staking and Withdrawal Logic
Accepts ERC20 deposits from users into specific reward pools.
Supports both public and private reward pools (public allow permissionless staking; private are managed by the owner).
Enables staking with custom lock periods and optional referrer assignment.
Allows secure withdrawal with respect to lock rules and minimum stake constraints.
Reward Calculation Integration
Interfaces with the
RewardPool
contract to validate pool configurations (e.g., public/private).Works with the
Distributor
to request reward updates before any user action.Computes a “virtual deposit” value factoring in lock duration and referral tiers.
Uses internal logic to calculate each user’s current pending rewards and referrer yield.
Claim and Delegation System
Supports direct reward claiming by stakers.
Enables delegated reward claiming via
claimSender
andclaimReceiver
mappings.Supports separate claiming of referrer rewards.
Ensures secure access control on all delegated operations.
Cross-Contract Coordination
Verifies pool status from the
RewardPool
contract.Uses the
Distributor
to distribute rewards and transfer yield tokens as needed.Relies on shared PRECISION constants and math utilities from
LockMultiplierMath
andReferrerLib
.
Storage
isNotUpgradeable
Returns true
if the contract no longer supports upgrades to a new version.
bool public isNotUpgradeable;
depositToken
The stETH token address, see the LIDO doc.
address public depositToken;
rewardPoolsData
Contain additional internal information about MOR reward pools for buckets. poolsData[<poolId>]
.
mapping(uint256 => RewardPoolData) public rewardPoolsData;
struct RewardPoolData {
uint128 lastUpdate;
uint256 rate;
uint256 totalVirtualDeposited;
}
lastUpdate
The unix epoch timestamp in seconds when the rate was updated.
rate
The current pool coefficient, used to calculate awards.
totalVirtualDeposited
The total amount of stETH deposited in the pool with multiplier, wei.
usersData
Stores all staking-related data for users. usersData[<stakerAddress>][<poolId>].
mapping(address => mapping(uint256 => UserData)) public usersData;
struct UserData {
uint128 lastStake;
uint256 deposited;
uint256 rate;
uint256 pendingRewards;
uint128 claimLockStart;
uint128 claimLockEnd;
uint256 virtualDeposited;
uint128 lastClaim;
address referrer;
}
lastStake
The unix epoch timestamp in seconds when the user stake was last.
deposited
The amount of staked stETH, wei.
rate
The last user reward rate, used to calculate awards.
pendingRewards
The last saved MOR rewards for the user. This value is updated when stake, withdraw or claim from the user account occurs. It is not the final award. Wei.
claimLockStart
MOR rewards lock period starts at this timestamp. Seconds.
claimLockEnd
MOR rewards lock period end at this timestamp. Seconds.
virtualDeposited
The amount of staked stETH, with multipliers. Wei.
lastClaim
The last claim timestamp in seconds.
referrer
The referrer address.
totalDepositedInPublicPools
Tracks the total amount of stETH deposited in the public pools (specifically the capital bucket). Wei.
referrerTiers
Stores referral reward tiers per pool. referrerTiers[<poolId>][<tierIndex>]
.
mapping(uint256 => ReferrerTier[]) public referrerTiers;
struct ReferrerTier {
uint256 amount;
uint256 multiplier;
}
amount
The minimal token amount for the tier, wei.
multiplier
The multiplier for the tier, where 1% = 0.01 * 1025.
referrersData
Tracks referral activity per user and pool. referrersData[<stakerAddress>][<poolId>]
.
mapping(address => mapping(uint256 => ReferrerData)) public referrersData;
struct ReferrerData {
uint256 amountStaked;
uint256 virtualAmountStaked;
uint256 rate;
uint256 pendingRewards;
uint128 lastClaim;
}
amountStaked
The amount of referred stETH, wei.
virtualAmountStaked
The amount of referred stETH, with multipliers, wei.
rate
The last referrer reward rate, used to calculate awards.
pendingRewards
The last saved MOR rewards for the referrer. It is not the final award, wei.
lastClaim
The last claim timestamp, secodns.
claimSender
Defines which addresses are allowed to claim rewards on behalf of another user in a given reward claimSender[<rewardPoolIndex>][<caller>][<allowedSender>]
mapping(uint256 => mapping(address => mapping(address => bool))) public claimSender;
claimReceiver
Defines the receiver address for a user’s rewards, enabling redirection of claims. claimReceiver[<rewardPoolIndex>][<caller>][<l2Receiver>]
mapping(uint256 => mapping(address => address)) public claimReceiver;
isMigrationOver
Indicates whether the migrate
function called.
bool public isMigrationOver;
distributor
The address of the Distributor
contract.
address public distributor;
rewardPoolsProtocolDetails
Setup limits configuration parameters used during reward calculations and user interactions.
mapping(uint256 => RewardPoolProtocolDetails) public rewardPoolsProtocolDetails;
struct RewardPoolProtocolDetails {
uint128 withdrawLockPeriodAfterStake;
uint128 claimLockPeriodAfterStake;
uint128 claimLockPeriodAfterClaim;
uint256 minimalStake;
uint256 distributedRewards;
}
withdrawLockPeriodAfterStake_
Lock period for withdrawals after staking, seconds.
claimLockPeriodAfterStake_
Lock period for claims after staking, seconds.
claimLockPeriodAfterClaim_
Lock period after a claim before next claim, seconds.
minimalStake_
Minimum staking amount required, wei.
distributedRewards
Distributed reward pool rewards, wei.
Write functions for the contract owner
DepositPool_init
Initializes the DepositPool
contract with the deposit token and distributor address.
function DepositPool_init(
address depositToken_,
address distributor_
) external initializer
depositToken_
Address of the stETH token.
distributor_
Address of the Distributor
contract.
setDistributor
Updates the Distributor
contract address.
function setDistributor(address value_) public onlyOwner
value_
Address of the Distributor
contract.
setRewardPoolProtocolDetails
Sets configuration details for a specific reward pool.
function setRewardPoolProtocolDetails(
uint256 rewardPoolIndex_,
uint128 withdrawLockPeriodAfterStake_,
uint128 claimLockPeriodAfterStake_,
uint128 claimLockPeriodAfterClaim_,
uint256 minimalStake_
) public onlyOwner
rewardPoolIndex_
The reward pool ID.
withdrawLockPeriodAfterStake_
Lock period for withdrawals after staking, seconds.
claimLockPeriodAfterStake_
Lock period for claims after staking, seconds.
claimLockPeriodAfterClaim_
Lock period after a claim before next claim, seconds.
minimalStake_
Minimum staking amount required, wei.
migrate
Transfers pending stETH yield to the Distributor
and run supply
logic. Used once for old DistributionV5
.
function migrate(uint256 rewardPoolIndex_) external onlyOwner
rewardPoolIndex_
The capital reward pool ID.
editReferrerTiers
The function to setup tiers for the refferal system.
function editReferrerTiers(
uint256 rewardPoolIndex_,
ReferrerTier[] calldata referrerTiers_
) external onlyOwner poolExists(poolId_)
rewardPoolIndex_
The reward pool ID.
referrerTiers_
The referrer tiers structs.
manageUsersInPrivatePool
The function to manage users in the private pool (non capital bucket). This function specifically controls the user shares in the other buckets. Each user has its own index in the array of users_
, additional data for that user (amounts_
, claimLockEnds_
, referrers_
) should have the same index.
function manageUsersInPrivatePool(
uint256 rewardPoolIndex_,
address[] calldata users_,
uint256[] calldata amounts_,
uint128[] calldata claimLockEnds_,
address[] calldata referrers_
) external onlyOwner poolExists(poolId_);
rewardPoolIndex_
The reward pool ID.
users_
The users addresses.
amounts_
The virtual staked amount values for users_
. Wei.
claimLockEnds_
The claim lock end values for users_
. Default values - [0, 0, 0...]
. Seconds.
referrers_
The referrer values for users_
.Default values - [0х000..., 0х000..., 0х000...]
removeUpgradeability
Permanently disables contract upgradeability. Only callable by owner.
function removeUpgradeability() external onlyOwner
Write functions for stakers
setClaimSender
Enables specified addresses to claim on behalf of the sender.
function setClaimSender(
uint256 rewardPoolIndex_,
address[] calldata senders_,
bool[] calldata isAllowed_
) external
rewardPoolIndex_
The reward pool ID.
senders_
List of addresses allowed/disallowed.
isAllowed_
Boolean flags per address for allow/disallow.
setClaimReceiver
Sets a dedicated address to receive claims on behalf of the caller.
function setClaimReceiver(
uint256 rewardPoolIndex_,
address receiver_
) external
rewardPoolIndex_
The reward pool ID.
receiver_
Address to receive rewards.
stake
The stake function allows users to deposit stETH into the protocol from the Ethereum network, then the staker will get a share of the rewards.
stake(
uint256 rewardPoolIndex_,
uint256 amount_,
uint128 claimLockEnd_,
address referrer_
) external;
rewardPoolIndex_
The reward pool ID.
amount_
The stETH amount to stake, where 1 stETH = 1018.
claimLockEnd_
The unix epoch timestamp in seconds. Use the default zero value. Secodns.
referrer_
The referrer address. Use the default zero address - 0x0000000000000000000000000000000000000000
withdraw
The withdraw function allows users to retrieve their staked stETH after a withdraw lock period.
function withdraw(
uint256 poolId_,
uint256 amount_
) external;
rewardPoolIndex_
The reward pool ID.
amount_
The stETH amount to withdraw, where 1 stETH = 1018.
claim
The claim function enables stakers to receive the MOR tokens they’ve accrued.
function claim(
uint256 rewardPoolIndex_,
address receiver_
) external payable;
rewardPoolIndex_
The reward pool ID.
receiver_
The address who will receive MOR on L2.
claimFor
Claims rewards for a staker_
on caller behalf. The caller should be whitelisted by staker_
on setClaimSender
call. Or claimReceiver
should exists on setClaimReceiver
call.
function claimFor(
uint256 rewardPoolIndex_,
address staker_,
address receiver_
) external payable
rewardPoolIndex_
The reward pool ID.
staker_
Address of the user being claimed for.
receiver_
Address receiving the rewards.
claimReferrerTier
The function enables referrer to receive the MOR tokens they’ve accrued.
function claimReferrerTier(
uint256 rewardPoolIndex_,
address receiver_
) external payable poolExists(poolId_);
rewardPoolIndex_
The reward pool ID.
receiver_
The address who will receive MOR on L2.
claimReferrerTierFor
Claims referrer-tier rewards for another referrer. The caller should be whitelisted by referrer_
on setClaimSender
call.
function claimReferrerTierFor(
uint256 rewardPoolIndex_,
address referrer_,
address receiver_
) external payable
rewardPoolIndex_
The reward pool ID.
referrer_
Referrer whose reward is claimed.
receiver_
Address to receive reward.
lockClaim
The function to lock rewards and receive claim lock multiplier (power factor). Used when a user has an active stake and wants to receive a multiplier without triggering a new staking transaction.
function lockClaim(
uint256 rewardPoolIndex_,
uint128 claimLockEnd_
) external poolExists(poolId_);
rewardPoolIndex_
The reward pool ID.
claimLockEnd_
The unix epoch timestamp in seconds.
Read functions
getLatestUserReward
This function calculates the total claimable MOR token rewards for a given staker within a specific bucket, based on their current stake and multipliers. Where 1 MOR = 1018.
function getLatestUserReward(
uint256 rewardPoolIndex_,
address user_
) external view returns (uint256);
rewardPoolIndex_
The reward pool ID.
user_
The staker address.
getLatestReferrerReward
This function calculates the total claimable MOR token rewards for a given referrer within a specific bucket, based on referrals and tier multipliers. Where 1 MOR = 1018.
function getLatestReferrerReward(
uint256 rewardPoolIndex_,
address user_
) public view returns (uint256)
rewardPoolIndex_
The reward pool ID.
user_
The referrer address.
getCurrentUserMultiplier
The function to calculate the power factor and referrer multiplier for the specified staker. Returns the multiplier, where x1 = 1025.
function getCurrentUserMultiplier(
uint256 rewardPoolIndex_,
address user_
) public view returns (uint256)
rewardPoolIndex_
The reward pool ID.
user_
The staker address.
getReferrerMultiplier
The function to calculate the tier multiplier for the specified referrer. Returns the multiplier, where x1 = 1025.
function getReferrerMultiplier(
uint256 rewardPoolIndex_,
address referrer_
) public view returns (uint256)
rewardPoolIndex_
The reward pool ID.
referrer_
The referrer address.
supportsInterface
Used for interface detection (ERC165). Returns true if the contract supports a specific interfaceId_
. Supports IChainLinkDataConsumer
, IERC165
.
function supportsInterface(bytes4 interfaceId_) external pure returns (bool)
version
Returns the current version of the contract.
function version() external pure returns (uint256
Last updated
Was this helpful?