UniswapV3Staker

UniswapV3Staker.sol

A forked version of the UniswapV3Staker contract for use with the NFTX AMM.

Table of Contents

Constants
Variables
Events
Public Write Functions
Read Functions

Constants

factory

function factory() external view returns (IUniswapV3Factory)

The address of the NFTX AMM's pool factory.

nonfungiblePositionManager

function nonfungiblePositionManager() 
    external 
    view 
    returns (INonfungiblePositionManager)

The address of the NFTX AMM's NonfungiblePositionManager.

maxIncentiveDuration

function maxIncentiveDuration() external view returns (uint256)

The maximum duration of an incentive, in seconds.

maxIncentiveStartLeadTime

function maxIncentiveStartLeadTime() external view returns (uint256)

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

Variables

incentives

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

Represents a staking incentive.

deposits

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

Returns information about a deposited liquidity NFT.

rewards

function rewards(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.

Events

IncentiveCreated

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

Event emitted when a liquidity mining incentive has been created.

IncentiveEnded

event IncentiveEnded(bytes32 indexed incentiveId, uint256 refund)

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

DepositTransferred

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

Emitted when ownership of a deposit changes

TokenStaked

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

Event emitted when an NFTX AMM LP token has been staked.

TokenUnstaked

event TokenUnstaked(uint256 indexed tokenId, bytes32 indexed incentiveId)

Event emitted when an NFTX AMM liquidity NFT has been unstaked.

RewardClaimed

event RewardClaimed(address indexed to, uint256 reward)

Event emitted when a reward token has been claimed.

Write Functions

constructor

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

createIncentive

function createIncentive(IncentiveKey memory key, uint256 reward) external 

Creates a new liquidity mining incentive program.

endIncentive

function endIncentive(IncentiveKey memory key) 
    external 
    returns (uint256 refund)

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

onERC721Received

function onERC721Received(
    address,
    address from,
    uint256 tokenId,
    bytes calldata data
) external returns (bytes4)

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.

transferDeposit

function transferDeposit(uint256 tokenId, address to) external

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

withdrawToken

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

Withdraws an NFTX V3 LP token tokenId from this contract to the recipient to.

stakeToken

function stakeToken(IncentiveKey memory key, uint256 tokenId) external override

Stakes an NFTX V3 LP token.

unstakeToken

function unstakeToken(IncentiveKey memory key, uint256 tokenId) external override

Unstakes an NFTX V3 LP token.

claimReward

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

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

Read Functions

stakes

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

Returns information about a staked liquidity NFT.

getRewardInfo

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

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

Last updated