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

Functions

stake

function stake(
    uint256 poolId_,
    uint256 amount_
    ) external poolExists(poolId_) poolPublic(poolId_)

Allows users to stake the deposit token (stETH) in a public pool.

Parameters

lockClaim

function lockClaim(
    uint256 poolId_,
    uint128 claimLockEnd_
    ) external poolExists(poolId_)

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

claim

function claim(
    uint256 poolId_,
    address receiver_
    ) external payable poolExists(poolId_)

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

withdraw

function withdraw(
    uint256 poolId_,
    uint256 amount_
    ) external poolExists(poolId_) poolPublic(poolId_)

Allows users to withdraw their staked tokens from a public pool.

Withdrawals can only be made after the withdrawLockPeriod and withdrawLockPeriodAfterStake.

Parameters

getCurrentUserReward

function getCurrentUserReward(
    uint256 poolId_,
    address user_
    ) external view returns (uint256)

Calculates and returns the current unclaimed reward amount for a user in a specified pool.

Parameters

Return Values

Distribution_init

function Distribution_init(
    address depositToken_,
    address l1Sender_,
    Pool[] calldata poolsInfo_
    ) external initializer

Initializes the contract with the deposit token (stETH) address, L1Sender address, and initial pools.

Parameters

createPool

function createPool(
    Pool calldata pool_
    ) public onlyOwner

Creates a new pool based on the provided pool configuration. This function can only be called by the owner of the contract.

Parameters

editPool

function editPool(
    uint256 poolId_,
    Pool calldata pool_
    ) external onlyOwner poolExists(poolId_)

Edits an existing pool's configuration. This function can only be called by the owner of the contract.

Parameters

getPeriodReward

function getPeriodReward(
    uint256 poolId_,
    uint128 startTime_,
    uint128 endTime_
    ) public view returns (uint256)

Calculates the reward for a specified pool and period. Uses the LinearDistributionIntervalDecrease library.

Parameters

Return Values

getClaimLockPeriodMultiplier

function getClaimLockPeriodMultiplier(
    uint256 poolId_,
    uint128 claimLockStart_,
    uint128 claimLockEnd_
    ) public view returns (uint256)

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

Return Values

getCurrentUserMultiplier

function getCurrentUserMultiplier(
    uint256 poolId_,
    address user_
    ) public view returns (uint256)

Returns the current reward multiplier for a user based on their claim lock period.

Parameters

Return Values

manageUsersInPrivatePool

function manageUsersInPrivatePool(
    uint256 poolId_,
    address[] calldata users_,
    uint256[] calldata amounts_
    ) external onlyOwner poolExists(poolId_)

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

overplus

function overplus(
    ) public view returns (uint256)

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

bridgeOverplus

function bridgeOverplus(
    uint256 gasLimit_,
    uint256 maxFeePerGas_,
    uint256 maxSubmissionCost_
    ) external payable onlyOwner returns (bytes memory)

Bridges surplus deposit tokens (stETH yield) to Arbitrum via L1Sender. This function can only be called by the owner of the contract.

Parameters

Return Values

Events

PoolCreated

event PoolCreated(
    uint256 indexed poolId,
    Pool pool
    )

Emitted when a new pool is created.

Parameters

PoolEdited

event PoolEdited(
    uint256 indexed poolId,
    Pool pool
    )

Emitted when an existing pool's configuration is edited.

Parameters

UserStaked

event UserStaked(
    uint256 indexed poolId,
    address indexed user,
    uint256 amount
    )

Emitted when a user stakes tokens in a pool.

Parameters

UserClaimed

event UserClaimed(
    uint256 indexed poolId,
    address indexed user,
    address receiver,
    uint256 amount
    )

Emitted when a user claims rewards from a pool.

Parameters

UserWithdrawn

event UserWithdrawn(
    uint256 indexed poolId,
    address indexed user,
    uint256 amount
    )

Emitted when a user withdraws from a pool.

OverplusBridged

event OverplusBridged(
    uint256 amount,
    bytes uniqueId
    )

Emitted when surplus deposit tokens are bridged to Arbitrum.

Parameters

Structs

Pool

struct Pool {
    uint128 payoutStart;
    uint128 decreaseInterval;
    uint128 withdrawLockPeriod;
    uint128 claimLockPeriod;
    uint128 withdrawLockPeriodAfterStake;
    uint256 initialReward;
    uint256 rewardDecrease;
    uint256 minimalStake;
    bool isPublic;
    }

Configuration data for a pool, including reward distribution schedules and lock periods. Also see LinearDistributionIntervalDecrease.

Fields

PoolData

struct PoolData {
    uint128 lastUpdate;
    uint256 rate;
    uint256 totalDeposited;
    }

Fields

UserData

struct UserData {
    uint128 lastStake;
    uint256 deposited;
    uint256 rate;
    uint256 pendingRewards;
    }

Fields

Last updated

Was this helpful?