Skip to main content
Helpful?

IUniswapV3Staker

Allows staking nonfungible liquidity tokens in exchange for reward tokens

Functions

factory

  function factory(
) external view returns (contract IUniswapV3Factory)

The Uniswap V3 Factory

nonfungiblePositionManager

  function nonfungiblePositionManager(
) external view returns (contract INonfungiblePositionManager)

The nonfungible position manager with which this staking contract is compatible

maxIncentiveDuration

  function maxIncentiveDuration(
) external view returns (uint256)

The max duration of an incentive in seconds

maxIncentiveStartLeadTime

  function maxIncentiveStartLeadTime(
) external view returns (uint256)

The max amount of seconds into the future the incentive startTime can be set

incentives

  function incentives(
bytes32 incentiveId
) external view returns (uint256 totalRewardUnclaimed, uint160 totalSecondsClaimedX128, uint96 numberOfStakes)

Represents a staking incentive

Parameters:

NameTypeDescription
incentiveIdbytes32The ID of the incentive computed from its parameters

Return Values:

NameTypeDescription
totalRewardUnclaimeduint256The amount of reward token not yet claimed by users
totalSecondsClaimedX128uint160Total liquidity-seconds claimed, represented as a UQ32.128
numberOfStakesuint96The count of deposits that are currently staked for the incentive

deposits

  function deposits(
) external view returns (address owner, uint48 numberOfStakes, int24 tickLower, int24 tickUpper)

Returns information about a deposited NFT

Return Values:

NameTypeDescription
owneraddressThe owner of the deposited NFT
numberOfStakesuint48Counter of how many incentives for which the liquidity is staked
tickLowerint24The lower tick of the range
tickUpperint24The upper tick of the range

stakes

  function stakes(
uint256 tokenId,
bytes32 incentiveId
) external view 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
liquidityuint128The amount of liquidity in the NFT as of the last time the rewards were computed

rewards

  function rewards(
contract IERC20Minimal rewardToken,
address owner
) external view returns (uint256 rewardsOwed)

Returns amounts of reward tokens owed to a given address according to the last time all stakes were updated

Parameters:

NameTypeDescription
rewardTokencontract IERC20MinimalThe token for which to check rewards
owneraddressThe owner for which the rewards owed are checked

Return Values:

NameTypeDescription
rewardsOweduint256The amount of the reward token claimable by the owner

createIncentive

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

Creates a new liquidity mining incentive program

Parameters:

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

endIncentive

  function endIncentive(
struct IUniswapV3Staker.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 IUniswapV3Staker.IncentiveKeyDetails of the incentive to end

Return Values:

NameTypeDescription
refunduint256The remaining reward tokens when the incentive is ended

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 Uniswap V3 LP token tokenId from this contract to the recipient to

Parameters:

NameTypeDescription
tokenIduint256The unique identifier of an Uniswap 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 IUniswapV3Staker.IncentiveKey key,
uint256 tokenId
) external

Stakes a Uniswap V3 LP token

Parameters:

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

unstakeToken

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

Unstakes a Uniswap V3 LP token

Parameters:

NameTypeDescription
keystruct IUniswapV3Staker.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 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 IUniswapV3Staker.IncentiveKey key,
uint256 tokenId
) external returns (uint256 reward, uint160 secondsInsideX128)

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

Parameters:

NameTypeDescription
keystruct IUniswapV3Staker.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

Events

IncentiveCreated

  event IncentiveCreated(
contract IERC20Minimal rewardToken,
contract IUniswapV3Pool pool,
uint256 startTime,
uint256 endTime,
address refundee,
uint256 reward
)

Event emitted when a liquidity mining incentive has been created

Parameters:

NameTypeDescription
rewardTokencontract IERC20MinimalThe token being distributed as a reward
poolcontract IUniswapV3PoolThe Uniswap V3 pool
startTimeuint256The time when the incentive program begins
endTimeuint256The time when rewards stop accruing
refundeeaddressThe address which receives any remaining reward tokens after the end time
rewarduint256The amount of reward tokens to be distributed

IncentiveEnded

  event IncentiveEnded(
bytes32 incentiveId,
uint256 refund
)

Event that can be emitted when a liquidity mining incentive has ended

Parameters:

NameTypeDescription
incentiveIdbytes32The incentive which is ending
refunduint256The amount of reward tokens refunded

DepositTransferred

  event DepositTransferred(
uint256 tokenId,
address oldOwner,
address newOwner
)

Emitted when ownership of a deposit changes

Parameters:

NameTypeDescription
tokenIduint256The ID of the deposit (and token) that is being transferred
oldOwneraddressThe owner before the deposit was transferred
newOwneraddressThe owner after the deposit was transferred

TokenStaked

  event TokenStaked(
uint256 tokenId,
bytes32 liquidity,
uint128 incentiveId
)

Event emitted when a Uniswap V3 LP token has been staked

Parameters:

NameTypeDescription
tokenIduint256The unique identifier of an Uniswap V3 LP token
liquiditybytes32The amount of liquidity staked
incentiveIduint128The incentive in which the token is staking

TokenUnstaked

  event TokenUnstaked(
uint256 tokenId,
bytes32 incentiveId
)

Event emitted when a Uniswap V3 LP token has been unstaked

Parameters:

NameTypeDescription
tokenIduint256The unique identifier of an Uniswap V3 LP token
incentiveIdbytes32The incentive in which the token is staking

RewardClaimed

  event RewardClaimed(
address to,
uint256 reward
)

Event emitted when a reward token has been claimed

Parameters:

NameTypeDescription
toaddressThe address where claimed rewards were sent to
rewarduint256The amount of reward tokens claimed
Helpful?