UniswapV3Staker
UniswapV3Staker.sol
A forked version of the UniswapV3Staker contract for use with the NFTX AMM.
Table of Contents
Constants
factory
The address of the NFTX AMM's pool factory.
nonfungiblePositionManager
The address of the NFTX AMM's NonfungiblePositionManager.
maxIncentiveDuration
The maximum duration of an incentive, in seconds.
maxIncentiveStartLeadTime
The maximum amount of seconds into the future the incentive startTime can be set.
Variables
incentives
Represents a staking incentive.
Parameters | Type | Description |
---|---|---|
incentiveId |
| The ID of the incentive computed from its parameters. |
Return values | Type | Description |
---|---|---|
totalRewardUnclaimed |
| The amount of reward token not yet claimed by users |
totalSecondsClaimedX128 |
| Total liquidity-seconds claimed, represented as a |
numberOfStakes |
| The count of deposits that are currently staked for the incentive. |
deposits
Returns information about a deposited liquidity NFT.
Parameters | Type | Description |
---|---|---|
tokenId |
| The token ID of the liquidity NFT. |
Return values | Type | Description |
---|---|---|
owner |
| The owner of the deposited liquidity NFT. |
numberOfStakes |
| Counter of how many incentives for which the liquidity is staked. |
tickLower |
| The lower tick of the range. |
tickUpper |
| The upper tick of the range. |
rewards
Returns amounts of reward tokens owed to a given address according to the last time all stakes were updated.
Parameters | Type | Description |
---|---|---|
rewardToken |
| The address of the token for which to check rewards. |
owner |
| The owner for which the rewards owed are checked. |
Return values | Type | Description |
---|---|---|
tokenId |
| The amount of the reward token claimable by the owner. |
Events
IncentiveCreated
Event emitted when a liquidity mining incentive has been created.
Parameters | Type | Description |
---|---|---|
rewardToken |
| The token being distributed as a reward. |
pool |
| The NFTX AMM pool. |
startTime |
| The time when the incentive program begins. |
endTime |
| The time when rewards stop accruing. |
refundee |
| The address that receives any remaining reward tokens after the end time. |
reward |
| The amount of reward tokens to be distributed. |
IncentiveEnded
Event that can be emitted when a liquidity mining incentive has ended.
Parameters | Type | Description |
---|---|---|
incentiveId |
| ID of the incentive that is ending. |
refund |
| The amount of reward tokens refunded. |
DepositTransferred
Emitted when ownership of a deposit changes
Parameters | Type | Description |
---|---|---|
tokenId |
| The token ID of the deposited liquidity NFT that is being transferred. |
oldOwner |
| The owner before the deposit was transferred. |
newOwner |
| The owner after the deposit was transferred. |
TokenStaked
Event emitted when an NFTX AMM LP token has been staked.
Parameters | Type | Description |
---|---|---|
tokenId |
| The token ID of the staked liquidity NFT. |
incentiveId |
| ID of the incentive being staked on. |
liquidity |
| The amount of liquidity staked. |
TokenUnstaked
Event emitted when an NFTX AMM liquidity NFT has been unstaked.
Parameters | Type | Description |
---|---|---|
tokenId |
| The token ID of the unstaked liquidity NFT. |
incentiveId |
| ID of the incentive being unstaked from. |
RewardClaimed
Event emitted when a reward token has been claimed.
Parameters | Type | Description |
---|---|---|
to |
| The address that claimed rewards were sent to. |
reward |
| The amount of reward token claimed. |
Write Functions
constructor
Parameters | Type | Description |
---|---|---|
_factory |
| The Uniswap V3 factory. |
_nonfungiblePositionManager |
| The NFT position manager contract address. |
_maxIncentiveStartLeadTime |
| The max duration of an incentive in seconds. |
_maxIncentiveDuration |
| The max amount of seconds into the future the incentive startTime can be set. |
createIncentive
Creates a new liquidity mining incentive program.
Parameters | Type | Description |
---|---|---|
key |
| Details of the incentive to create. |
reward |
| The amount of reward tokens to be distributed. |
endIncentive
Ends an incentive after the incentive end time has passed and all stakes have been withdrawn.
Parameters | Type | Description |
---|---|---|
key |
| Details of the incentive to end. |
Return values | Type | Description |
---|---|---|
refund |
| The remaining reward tokens when the incentive is ended. |
onERC721Received
Upon receiving a NFTX V3 LP 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
.
Parameters | Type | Description |
---|---|---|
unnamed |
| The address which called the transfer function. |
from |
| The address which previously owned the token. |
tokenId |
| ID of the NFT. |
data |
| Additional data with no specified format. |
Return values | Type | Description |
---|---|---|
unnamed |
| A keccak256 hash of the function call and arguments. |
transferDeposit
Transfers ownership of a deposit from the sender to the given recipient.
Parameters | Type | Description |
---|---|---|
tokenId |
| The ID of the token (and the deposit) to transfer. |
to |
| The new owner of the deposit. |
withdrawToken
Withdraws an NFTX V3 LP token tokenId
from this contract to the recipient to
.
Parameters | Type | Description |
---|---|---|
tokenId |
| The unique identifier of an Uniswap V3 LP token. |
to |
| The address where the LP token will be sent. |
data |
| An optional data array that will be passed along to the |
stakeToken
Stakes an NFTX V3 LP token.
Parameters | Type | Description |
---|---|---|
key |
| The key of the incentive for which to stake the NFT. |
tokenId |
| The ID of the token to stake. |
unstakeToken
Unstakes an NFTX V3 LP token.
Parameters | Type | Description |
---|---|---|
key |
| The key of the incentive for which to unstake the NFT. |
tokenId |
| The ID of the token to unstake. |
claimReward
Transfers amountRequested
of accrued rewardToken
rewards from the contract to the recipient to
.
Parameters | Type | Description |
---|---|---|
rewardToken |
| The token being distributed as a reward. |
to |
| The address where claimed rewards will be sent. |
amountRequested |
| The amount of reward token to claim. If set to 0, then the entire reward amount is claimed. |
Return values | Type | Description |
---|---|---|
reward |
| The amount of reward token claimed. |
Read Functions
stakes
Returns information about a staked liquidity NFT.
Parameters | Type | Description |
---|---|---|
tokenId |
| The ID of the staked token. |
incentiveId |
| The ID of the incentive for which the token is staked. |
Return values | Type | Description |
---|---|---|
secondsPerLiquidityInsideInitialX128 |
| secondsPerLiquidity represented as a UQ32.128. |
liquidity |
| The amount of liquidity in the NFT as of the last time the rewards were computed. |
getRewardInfo
Calculates the reward amount that will be received for the given stake.
Parameters | Type | Description |
---|---|---|
key |
| The ID of the incentive. |
tokenId |
| The token ID of the staked liquidity NFT. |
Return values | Type | Description |
---|---|---|
reward |
| The reward accrued to the NFT for the given incentive thus far. |
secondsInsideX128 |
| The seconds inside the tick range. |
Last updated