Distribution V4
DistributionV4.sol
is the core contract of the Techno Capital Machine. It allows Capital Providers to stake stETH (Lido Staked ETH) on Ethereum and claim MOR rewards to Arbitrum.
DistributionV4
utilizes L1Sender
to bridge stETH yield and relay MOR claims to Arbitrum. LinearDistributionIntervalDecrease
is used to calculate pool rewards.
This contract is also used to track other MOR emissions through private pools. For instance, pool 1
is a private pool used to track Code emissions, where deposit "amounts" correspond to weights.
Version history
The V3 version of the contract introduces the ability to lock MOR emissions for a chosen period of time. During this period, emissions cannot be claimed; however a multiplier of up to 10.7x is applied.
The V4 version of the contract introduces two new lock periods claimLockPeriodAfterClaim
and claimLockPeriodAfterStake
for each pool. Initially, these are set to 90 days for the capital pool (pool 0
) and 0 for all other pools. During this period after claiming or staking, emissions are locked and cannot be claimed.
Public Variables
depositToken
address
The address of the deposit token on Ethereum (stETH).
l1Sender
address
The address of the L1Sender
contract.
pools
Pool[]
Configurations for all pools through which rewards are allocated.
poolsData
mapping(uint256 => PoolData
)
Ongoing tracking data for all pools.
usersData
mapping(address => mapping(uint256 => UserData
))
Ongoing tracking data for user participation in pools.
totalDepositedInPublicPools
uint256
The total amount of the deposit token in all public pools.
totalVirtualDeposited
uint256
The total "virtual" amount of the deposit token in all pools after accounting for claim lock multipliers.
claimLockPeriodAfterClaim
uint128
The period in seconds during which emissions cannot be claimed after claiming.
claimLockPeriodAfterStake
uint128
The period in seconds during which emissions cannot be claimed after staking.
Functions
stake
Allows users to stake the deposit token (stETH) in a public pool.
Parameters
poolId_
uint256
The ID of the public pool to stake in.
amount_
uint256
The amount of deposit tokens to stake.
lockClaim
Locks the user's claim for a specified period, during which a multiplier is applied. This incentivizes users to delay claiming emissions for higher returns.
Parameters
poolId_
uint256
The ID of the public pool to lock for.
claimLockEnd_
uint128
The timestamp until which the claim is locked. Must be in the future.
claim
Enables users to claim their MOR rewards from a specific pool. After verifying claims internally, minting instructions are sent to L2MessageReceiver
on Arbitrum via L1Sender
.
Rewards can only be claimed after the claimLockPeriod
.
Parameters
poolId_
uint256
The ID of the pool to claim rewards from.
receiver_
address
The address where rewards are sent.
withdraw
Allows users to withdraw their staked tokens from a public pool.
Withdrawals can only be made after the withdrawLockPeriod
and withdrawLockPeriodAfterStake
.
Parameters
poolId_
uint256
The ID of the pool to withdraw from.
amount_
uint256
The amount of tokens to withdraw.
getCurrentUserReward
Calculates and returns the current unclaimed reward amount for a user in a specified pool.
Parameters
poolId_
uint256
The ID of the pool.
user_
address
The address of the user.
Return Values
uint256
The current unclaimed reward amount for the specified user.
Distribution_init
Initializes the contract with the deposit token (stETH) address, L1Sender
address, and initial pools.
Parameters
depositToken_
address
The address of the deposit token.
l1Sender_
address
The address of the L1Sender
contract.
poolsInfo_
Pool[]
An array of pools to be initialized.
createPool
Creates a new pool based on the provided pool configuration. This function can only be called by the owner of the contract.
Parameters
pool_
Pool
The configuration of the new pool.
editPool
Edits an existing pool's configuration. This function can only be called by the owner of the contract.
Parameters
poolId_
uint256
The ID of the pool to be edited.
pool_
Pool
The new configuration for the pool.
getPeriodReward
Calculates the reward for a specified pool and period. Uses the LinearDistributionIntervalDecrease
library.
Parameters
poolId_
uint256
The ID of the pool.
startTime_
uint128
The start timestamp of the period.
endTime_
uint128
The end timestamp of the period.
Return Values
uint256
The total reward amount for the period.
getClaimLockPeriodMultiplier
Calculates the multiplier based on the duration between the start and end of the claim lock period. This multiplier is applied to the user’s stake (or weights) for emissions calculations.
Parameters
poolId_
uint256
The ID of the pool.
claimLockStart_
uint128
The start timestamp of the claim lock period.
claimLockEnd_
uint128
The end timestamp of the claim lock period.
Return Values
uint256
The multiplier applied to the user's virtual deposit.
getCurrentUserMultiplier
Returns the current reward multiplier for a user based on their claim lock period.
Parameters
poolId_
uint256
The ID of the pool.
user_
address
The address of the user.
Return Values
uint256
The reward multiplier currently applied to the user.
manageUsersInPrivatePool
Manages user stakes in a private pool used for non-Capital emissions by adjusting their deposited "amounts" based on a specified array. This function can only be called by the owner of the contract.
In the case of Code emissions (e.g. pool 1
), amounts correspond to weights.
Parameters
poolId_
uint256
The ID of the private pool to manage users in.
users_
address[]
An array of user addresses to manage stakes for.
amounts_
uint256[]
An array of amounts corresponding to each user.
overplus
Calculates the amount of surplus deposit tokens (stETH yield) in the contract that are not deposited in any pools. These tokens can be bridged to Arbitrum to provision Protocol-Owned Liquidity.
Return Values
uint256
The amount of surplus deposit tokens in the contract.
bridgeOverplus
Bridges surplus deposit tokens (stETH yield) to Arbitrum via L1Sender
. This function can only be called by the owner of the contract.
Parameters
gasLimit_
uint256
The gas limit for the bridging transaction.
maxFeePerGas_
uint256
The maximum fee per gas unit willing to be paid.
maxSubmissionCost_
uint256
The maximum cost willing to be paid for submission.
Return Values
bytes
The ABI-encoded Arbitrum inbox sequence number.
Events
PoolCreated
Emitted when a new pool is created.
Parameters
poolId
uint256
The unique identifier of the created pool.
pool
Pool
The pool configuration.
PoolEdited
Emitted when an existing pool's configuration is edited.
Parameters
poolId
uint256
The unique identifier of the pool that was edited.
pool
Pool
The pool configuration.
UserStaked
Emitted when a user stakes tokens in a pool.
Parameters
poolId
uint256
The ID of the pool in which tokens are staked.
user
address
The address of the user who staked tokens.
amount
uint256
The amount of tokens staked by the user.
UserClaimed
Emitted when a user claims rewards from a pool.
Parameters
poolId
uint256
The ID of the pool from which rewards are claimed.
user
address
The address of the user claiming rewards.
receiver
address
The address where the claimed rewards are sent on Arbitrum.
amount
uint256
The amount of rewards claimed by the user.
UserWithdrawn
Emitted when a user withdraws from a pool.
poolId
uint256
The ID of the pool from which tokens are withdrawn.
user
address
The address of the user withdrawing tokens.
amount
uint256
The amount of tokens withdrawn by the user.
OverplusBridged
Emitted when surplus deposit tokens are bridged to Arbitrum.
Parameters
amount
uint256
The amount of surplus deposit tokens that were bridged.
uniqueId
bytes
The ABI-encoded Arbitrum inbox sequence number.
Structs
Pool
Configuration data for a pool, including reward distribution schedules and lock periods.
Also see LinearDistributionIntervalDecrease
.
Fields
payoutStart
uint128
The timestamp at which the distribution schedule starts.
decreaseInterval
uint128
The duration of each interval in seconds.
withdrawLockPeriod
uint128
The period in seconds during which stake cannot be withdrawn.
claimLockPeriod
uint128
The period in seconds during which rewards cannot be claimed.
withdrawLockPeriodAfterStake
uint128
The lock period after staking during which stake cannot be withdrawn.
initialReward
uint256
The initial reward amount per interval.
rewardDecrease
uint256
The amount by which the reward decreases each interval.
minimalStake
uint256
The minimum stake amount required for participation in the pool.
isPublic
bool
Indicates if the pool is open to the public or private.
PoolData
Fields
lastUpdate
uint128
The timestamp of the last update to the pool's data.
rate
uint256
The current reward rate for the pool.
totalDeposited
uint256
The total amount of tokens deposited in the pool.
UserData
Fields
lastStake
uint128
The timestamp when the user last staked tokens in the pool.
deposited
uint256
The amount of tokens the user has deposited in the pool.
rate
uint256
The current reward rate applicable to the user.
pendingRewards
uint256
The amount of rewards that the user can claim.
Last updated
Was this helpful?