Skip to main content

Pegasys V3 Staker Contract

Below is the technical reference for the staker contract, PegasysV3Staker.sol. A technical guide for interacting with this staking contract will be released soon.

Functions

stakes

  function stakes(
uint256 tokenId,
bytes32 incentiveId
) public view override returns (uint160 secondsPerLiquidityInsideInitialX128, uint128 liquidity)

Returns information about a staked liquidity NFT

Parameters:

NameTypeDescription
tokenIduint256The ID of the staked token
incentiveIdbytes32The ID of the incentive for which the token is staked

Return Values:

NameTypeDescription
secondsPerLiquidityInsideInitialX128uint160secondsPerLiquidity represented as a UQ32.128
liquiditybytes32The amount of liquidity in the NFT as of the last time the rewards were computed

constructor

  function constructor(
contract IPegasysV3Factory _factory,
contract INonfungiblePositionManager _nonfungiblePositionManager,
uint256 _maxIncentiveStartLeadTime,
uint256 _maxIncentiveDuration
) public

Parameters:

NameTypeDescription
_factorycontract IPegasysV3Factorythe Pegasys V3 factory
_nonfungiblePositionManagercontract INonfungiblePositionManagerthe NFT position manager contract address
_maxIncentiveStartLeadTimeuint256the max duration of an incentive in seconds
_maxIncentiveDurationuint256the max amount of seconds into the future the incentive startTime can be set

createIncentive

  function createIncentive(
struct IPegasysV3Staker.IncentiveKey key,
uint256 reward
) external

Creates a new liquidity mining incentive program

Parameters:

NameTypeDescription
keystruct IPegasysV3Staker.IncentiveKeyDetails of the incentive to create
rewarduint256The amount of reward tokens to be distributed

endIncentive

  function endIncentive(
struct IPegasysV3Staker.IncentiveKey key
) external returns (uint256 refund)

Ends an incentive after the incentive end time has passed and all stakes have been withdrawn

Parameters:

NameTypeDescription
keystruct IPegasysV3Staker.IncentiveKeyDetails of the incentive to end

Return Values:

NameTypeDescription
refunduint256The remaining reward tokens when the incentive is ended

onERC721Received

  function onERC721Received(
) external returns (bytes4)

Upon receiving a Pegasys V3 ERC721, creates the token deposit setting owner to from. Also stakes token in one or more incentives if properly formatted data has a length > 0.

Whenever an {IERC721} tokenId token is transferred to this contract via {IERC721-safeTransferFrom} by operator from from, this function is called. It must return its Solidity selector to confirm the token transfer. If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. The selector can be obtained in Solidity with IERC721.onERC721Received.selector.

transferDeposit

  function transferDeposit(
uint256 tokenId,
address to
) external

Transfers ownership of a deposit from the sender to the given recipient

Parameters:

NameTypeDescription
tokenIduint256The ID of the token (and the deposit) to transfer
toaddressThe new owner of the deposit

withdrawToken

  function withdrawToken(
uint256 tokenId,
address to,
bytes data
) external

Withdraws a Pegasys V3 LP token tokenId from this contract to the recipient to

Parameters:

NameTypeDescription
tokenIduint256The unique identifier of an Pegasys V3 LP token
toaddressThe address where the LP token will be sent
databytesAn optional data array that will be passed along to the to address via the NFT safeTransferFrom

stakeToken

  function stakeToken(
struct IPegasysV3Staker.IncentiveKey key,
uint256 tokenId
) external

Stakes a Pegasys V3 LP token

Parameters:

NameTypeDescription
keystruct IPegasysV3Staker.IncentiveKeyThe key of the incentive for which to stake the NFT
tokenIduint256The ID of the token to stake

unstakeToken

  function unstakeToken(
struct IPegasysV3Staker.IncentiveKey key,
uint256 tokenId
) external

Unstakes a Pegasys V3 LP token

Parameters:

NameTypeDescription
keystruct IPegasysV3Staker.IncentiveKeyThe key of the incentive for which to unstake the NFT
tokenIduint256The ID of the token to unstake

claimReward

  function claimReward(
contract IERC20Minimal rewardToken,
address to,
uint256 amountRequested
) external override returns (uint256 reward)

Transfers amountRequested of accrued rewardToken rewards from the contract to the recipient to

Parameters:

NameTypeDescription
rewardTokencontract IERC20MinimalThe token being distributed as a reward
toaddressThe address where claimed rewards will be sent to
amountRequesteduint256The amount of reward tokens to claim. Claims entire reward amount if set to 0.

Return Values:

NameTypeDescription
rewarduint256The amount of reward tokens claimed

getRewardInfo

  function getRewardInfo(
struct IPegasysV3Staker.IncentiveKey key,
uint256 tokenId
) external view override returns (uint256 reward, uint160 secondsInsideX128)

Calculates the reward amount that will be received for the given stake

Parameters:

NameTypeDescription
keystruct IPegasysV3Staker.IncentiveKeyThe key of the incentive
tokenIduint256The ID of the token

Return Values:

NameTypeDescription
rewarduint256The reward accrued to the NFT for the given incentive thus far
secondsInsideX128uint160The seconds inside the tick range