PerpRewardDistributor
Inherits: RewardDistributor, IPerpRewardDistributor
Author: webthethird
Handles reward accrual and distribution for liquidity providers in Perpetual markets
State Variables
clearingHouse
Clearing House contract
_earlyWithdrawalThreshold
Amount of time after which LPs can remove liquidity without penalties
_withdrawTimerStartByUserByMarket
Last timestamp when user changed their position in a market
First address is user, second is the market
Functions
onlyClearingHouse
Modifier for functions that can only be called by the ClearingHouse, i.e., updatePosition
constructor
PerpRewardDistributor constructor
Parameters
updatePosition
Accrues rewards and updates the stored LP position of a user and the total LP of a market
Only callable by the clearing house, executes whenever a user's liquidity is updated for any reason
Parameters
earlyWithdrawalThreshold
Gets the number of seconds that a user must leave their liquidity in the market to avoid the early withdrawal penalty
Returns
withdrawTimerStartByUserByMarket
Start time of the user's early withdrawal timer for a specific market, i.e., when they last changed their position in the market
The user can withdraw their liquidity without penalty after withdrawTimerStartByUserByMarket(user, market) + earlyWithdrawalThreshold
Parameters
Returns
paused
Indicates whether claiming rewards is currently paused
Contract is paused if either this contract or the ClearingHouse has been paused
Returns
initMarketStartTime
Sets the start time for accruing rewards to a market which has not been initialized yet
Only callable by governance
Parameters
setEarlyWithdrawalThreshold
Sets the number of seconds that a user must leave their liquidity in the market to avoid the early withdrawal penalty
Only callable by governance
Parameters
_getNumMarkets
Gets the number of markets to be used for reward distribution
Markets are the perpetual markets (for the PerpRewardDistributor) or staked tokens (for the SafetyModule)
Returns
_getMarketAddress
Gets the address of a market at a given index
Markets are the perpetual markets (for the PerpRewardDistributor) or staked tokens (for the SafetyModule)
Parameters
Returns
_getMarketIdx
Gets the index of an allowlisted market
Markets are the perpetual markets (for the PerpRewardDistributor) or staked tokens (for the SafetyModule)
Parameters
Returns
_getCurrentPosition
Returns the current position of the user in the market (i.e., perpetual market or staked token)
Parameters
Returns
_accrueRewards
Accrues rewards and updates the stored LP position of a user and the total liquidity in the market
Called by updatePosition
, which can only be called by the ClearingHouse when an LP's position changes, and claimRewards
, which always passes msg.sender
as the user
Parameters
Last updated